lantern-engine 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +101 -0
- package/LICENSE +21 -0
- package/README.md +113 -2
- package/dist/assets/takeCleanerWorker-DTcI_Jqr.js +31 -0
- package/dist/assets/takeCleanerWorker-DTcI_Jqr.js.map +1 -0
- package/dist/constants-CjYVdFid.js +252 -0
- package/dist/constants-CjYVdFid.js.map +1 -0
- package/dist/lantern-engine.js +3473 -0
- package/dist/lantern-engine.js.map +1 -0
- package/dist/pixel.js +1404 -0
- package/dist/pixel.js.map +1 -0
- package/dist/types/anim/Animator.d.ts +50 -0
- package/dist/types/anim/Animator.d.ts.map +1 -0
- package/dist/types/anim/animationSystem.d.ts +13 -0
- package/dist/types/anim/animationSystem.d.ts.map +1 -0
- package/dist/types/assets/AssetLoader.d.ts +85 -0
- package/dist/types/assets/AssetLoader.d.ts.map +1 -0
- package/dist/types/audio/MusicPlayer.d.ts +57 -0
- package/dist/types/audio/MusicPlayer.d.ts.map +1 -0
- package/dist/types/audio/SoundEngine.d.ts +42 -0
- package/dist/types/audio/SoundEngine.d.ts.map +1 -0
- package/dist/types/audio/cleanTake.d.ts +3 -0
- package/dist/types/audio/cleanTake.d.ts.map +1 -0
- package/dist/types/audio/sampleBank.d.ts +27 -0
- package/dist/types/audio/sampleBank.d.ts.map +1 -0
- package/dist/types/audio/soundTable.d.ts +14 -0
- package/dist/types/audio/soundTable.d.ts.map +1 -0
- package/dist/types/audio/synth.d.ts +34 -0
- package/dist/types/audio/synth.d.ts.map +1 -0
- package/dist/types/audio/takeCleanerWorker.d.ts +2 -0
- package/dist/types/audio/takeCleanerWorker.d.ts.map +1 -0
- package/dist/types/core/BitmapLabel.d.ts +26 -0
- package/dist/types/core/BitmapLabel.d.ts.map +1 -0
- package/dist/types/core/Camera.d.ts +90 -0
- package/dist/types/core/Camera.d.ts.map +1 -0
- package/dist/types/core/Clock.d.ts +11 -0
- package/dist/types/core/Clock.d.ts.map +1 -0
- package/dist/types/core/Graphics.d.ts +37 -0
- package/dist/types/core/Graphics.d.ts.map +1 -0
- package/dist/types/core/Group.d.ts +15 -0
- package/dist/types/core/Group.d.ts.map +1 -0
- package/dist/types/core/Image.d.ts +25 -0
- package/dist/types/core/Image.d.ts.map +1 -0
- package/dist/types/core/ObjectFactory.d.ts +34 -0
- package/dist/types/core/ObjectFactory.d.ts.map +1 -0
- package/dist/types/core/Pointer.d.ts +27 -0
- package/dist/types/core/Pointer.d.ts.map +1 -0
- package/dist/types/core/Rectangle.d.ts +26 -0
- package/dist/types/core/Rectangle.d.ts.map +1 -0
- package/dist/types/core/Stage.d.ts +58 -0
- package/dist/types/core/Stage.d.ts.map +1 -0
- package/dist/types/core/Text.d.ts +22 -0
- package/dist/types/core/Text.d.ts.map +1 -0
- package/dist/types/core/TextureRegistry.d.ts +51 -0
- package/dist/types/core/TextureRegistry.d.ts.map +1 -0
- package/dist/types/core/Tweener.d.ts +53 -0
- package/dist/types/core/Tweener.d.ts.map +1 -0
- package/dist/types/core/atlas.d.ts +16 -0
- package/dist/types/core/atlas.d.ts.map +1 -0
- package/dist/types/core/atlasPlan.d.ts +34 -0
- package/dist/types/core/atlasPlan.d.ts.map +1 -0
- package/dist/types/core/eases.d.ts +3 -0
- package/dist/types/core/eases.d.ts.map +1 -0
- package/dist/types/core/gameObject.d.ts +42 -0
- package/dist/types/core/gameObject.d.ts.map +1 -0
- package/dist/types/core/pixiPatches.d.ts +9 -0
- package/dist/types/core/pixiPatches.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +4 -0
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/types/ecs/SparseSet.d.ts +25 -0
- package/dist/types/ecs/SparseSet.d.ts.map +1 -0
- package/dist/types/ecs/World.d.ts +133 -0
- package/dist/types/ecs/World.d.ts.map +1 -0
- package/dist/types/ecs/fields.d.ts +34 -0
- package/dist/types/ecs/fields.d.ts.map +1 -0
- package/dist/types/engine/Engine.d.ts +80 -0
- package/dist/types/engine/Engine.d.ts.map +1 -0
- package/dist/types/engine/FixedLoop.d.ts +32 -0
- package/dist/types/engine/FixedLoop.d.ts.map +1 -0
- package/dist/types/engine/Scene.d.ts +37 -0
- package/dist/types/engine/Scene.d.ts.map +1 -0
- package/dist/types/engine/SceneManager.d.ts +31 -0
- package/dist/types/engine/SceneManager.d.ts.map +1 -0
- package/dist/types/events/EventBus.d.ts +20 -0
- package/dist/types/events/EventBus.d.ts.map +1 -0
- package/dist/types/fx/hitStop.d.ts +20 -0
- package/dist/types/fx/hitStop.d.ts.map +1 -0
- package/dist/types/fx/viewCull.d.ts +14 -0
- package/dist/types/fx/viewCull.d.ts.map +1 -0
- package/dist/types/index.d.ts +68 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/input/Actions.d.ts +75 -0
- package/dist/types/input/Actions.d.ts.map +1 -0
- package/dist/types/input/Keyboard.d.ts +25 -0
- package/dist/types/input/Keyboard.d.ts.map +1 -0
- package/dist/types/input/aimAxis.d.ts +9 -0
- package/dist/types/input/aimAxis.d.ts.map +1 -0
- package/dist/types/input/longPress.d.ts +21 -0
- package/dist/types/input/longPress.d.ts.map +1 -0
- package/dist/types/input/stickAxis.d.ts +26 -0
- package/dist/types/input/stickAxis.d.ts.map +1 -0
- package/dist/types/input/touchDetect.d.ts +18 -0
- package/dist/types/input/touchDetect.d.ts.map +1 -0
- package/dist/types/light/LightLayer.d.ts +65 -0
- package/dist/types/light/LightLayer.d.ts.map +1 -0
- package/dist/types/net/Connection.d.ts +66 -0
- package/dist/types/net/Connection.d.ts.map +1 -0
- package/dist/types/net/InterpolationBuffer.d.ts +36 -0
- package/dist/types/net/InterpolationBuffer.d.ts.map +1 -0
- package/dist/types/net/PredictedMover.d.ts +43 -0
- package/dist/types/net/PredictedMover.d.ts.map +1 -0
- package/dist/types/net/Room.d.ts +69 -0
- package/dist/types/net/Room.d.ts.map +1 -0
- package/dist/types/net/RoomHost.d.ts +74 -0
- package/dist/types/net/RoomHost.d.ts.map +1 -0
- package/dist/types/net/cadence.d.ts +22 -0
- package/dist/types/net/cadence.d.ts.map +1 -0
- package/dist/types/net/constants.d.ts +24 -0
- package/dist/types/net/constants.d.ts.map +1 -0
- package/dist/types/net/movement.d.ts +50 -0
- package/dist/types/net/movement.d.ts.map +1 -0
- package/dist/types/net/protocol.d.ts +59 -0
- package/dist/types/net/protocol.d.ts.map +1 -0
- package/dist/types/net/serverClock.d.ts +14 -0
- package/dist/types/net/serverClock.d.ts.map +1 -0
- package/dist/types/net/snapshotCodec.d.ts +55 -0
- package/dist/types/net/snapshotCodec.d.ts.map +1 -0
- package/dist/types/pixel/Darkness.d.ts +78 -0
- package/dist/types/pixel/Darkness.d.ts.map +1 -0
- package/dist/types/pixel/Evaporation.d.ts +30 -0
- package/dist/types/pixel/Evaporation.d.ts.map +1 -0
- package/dist/types/pixel/PixelLayer.d.ts +85 -0
- package/dist/types/pixel/PixelLayer.d.ts.map +1 -0
- package/dist/types/pixel/index.d.ts +22 -0
- package/dist/types/pixel/index.d.ts.map +1 -0
- package/dist/types/pixel/lights.d.ts +34 -0
- package/dist/types/pixel/lights.d.ts.map +1 -0
- package/dist/types/pixel/palette.d.ts +54 -0
- package/dist/types/pixel/palette.d.ts.map +1 -0
- package/dist/types/pixel/pixel.d.ts +80 -0
- package/dist/types/pixel/pixel.d.ts.map +1 -0
- package/dist/types/pixel/pixelPaint.d.ts +43 -0
- package/dist/types/pixel/pixelPaint.d.ts.map +1 -0
- package/dist/types/pixel/pixelTone.d.ts +49 -0
- package/dist/types/pixel/pixelTone.d.ts.map +1 -0
- package/dist/types/pixel/propKit.d.ts +26 -0
- package/dist/types/pixel/propKit.d.ts.map +1 -0
- package/dist/types/pixel/ramp.d.ts +31 -0
- package/dist/types/pixel/ramp.d.ts.map +1 -0
- package/dist/types/pixel/selout.d.ts +3 -0
- package/dist/types/pixel/selout.d.ts.map +1 -0
- package/dist/types/pixel/spritePixels.d.ts +29 -0
- package/dist/types/pixel/spritePixels.d.ts.map +1 -0
- package/dist/types/platform/touch.d.ts +5 -0
- package/dist/types/platform/touch.d.ts.map +1 -0
- package/dist/types/rig/PosePlayer.d.ts +64 -0
- package/dist/types/rig/PosePlayer.d.ts.map +1 -0
- package/dist/types/rig/RigView.d.ts +68 -0
- package/dist/types/rig/RigView.d.ts.map +1 -0
- package/dist/types/rig/Skeleton.d.ts +14 -0
- package/dist/types/rig/Skeleton.d.ts.map +1 -0
- package/dist/types/rig/humanoid.d.ts +4 -0
- package/dist/types/rig/humanoid.d.ts.map +1 -0
- package/dist/types/rig/humanoidPoses.d.ts +117 -0
- package/dist/types/rig/humanoidPoses.d.ts.map +1 -0
- package/dist/types/rig/poseMath.d.ts +14 -0
- package/dist/types/rig/poseMath.d.ts.map +1 -0
- package/dist/types/rig/rigTypes.d.ts +82 -0
- package/dist/types/rig/rigTypes.d.ts.map +1 -0
- package/dist/types/settings.d.ts +25 -0
- package/dist/types/settings.d.ts.map +1 -0
- package/dist/types/tilemap/TilemapView.d.ts +42 -0
- package/dist/types/tilemap/TilemapView.d.ts.map +1 -0
- package/dist/types/tilemap/collision.d.ts +16 -0
- package/dist/types/tilemap/collision.d.ts.map +1 -0
- package/dist/types/tilemap/tiled.d.ts +104 -0
- package/dist/types/tilemap/tiled.d.ts.map +1 -0
- package/package.json +82 -4
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Graphics } from '../core/Graphics.js';
|
|
2
|
+
import type { Stage } from '../core/Stage.js';
|
|
3
|
+
/**
|
|
4
|
+
* A `Graphics` for the pixel effects: every `fillRect` of a frame is written into a small RGBA buffer
|
|
5
|
+
* and shown as **one** sprite, instead of becoming a rect Pixi must tessellate, batch and upload. An effect's frame is
|
|
6
|
+
* hundreds to thousands of one-pixel runs (a poison cloud, a status mark round every body in a pack), and as rects they
|
|
7
|
+
* were most of a fight's CPU on a phone (profiled). The pixels are the same: whole
|
|
8
|
+
* world pixels, a translucent fill blended over what was painted before it in the same frame, as a Graphics did.
|
|
9
|
+
*
|
|
10
|
+
* Paint between `clear()` and `present()`; anything other than `fillStyle`/`fillRect` still draws through the
|
|
11
|
+
* Graphics underneath, so a painter using another shape keeps working. Solid pixels may also be **staged**
|
|
12
|
+
* (`stage`, from `pixelTone`'s batch) and laid in one go by `commit`, which is what a batch's flush does.
|
|
13
|
+
*
|
|
14
|
+
* Buffers and their textures are pooled by size class (a texture per effect ran to ~114 a second in a busy fight,
|
|
15
|
+
* and each one stayed in Pixi's batch tables), so a destroyed layer hands its texture
|
|
16
|
+
* to the next one; `PixelLayer.drainPool` lets them all go when the map changes.
|
|
17
|
+
*/
|
|
18
|
+
/** A new `PixelLayer` on the stage's world layer. */
|
|
19
|
+
export declare function addPixelLayer(stage: Stage): PixelLayer;
|
|
20
|
+
export declare class PixelLayer extends Graphics {
|
|
21
|
+
/** This frame's rects: x, y, w, h, colour, alpha — six numbers each. */
|
|
22
|
+
private readonly rects;
|
|
23
|
+
/** Staged solid runs not yet committed: x, y, w, colour — four numbers each; later ones win. */
|
|
24
|
+
private readonly staged;
|
|
25
|
+
private ink;
|
|
26
|
+
private inkAlpha;
|
|
27
|
+
private readonly sprite;
|
|
28
|
+
private surface;
|
|
29
|
+
/** Where the buffer's first pixel sits in the layer, as of the last `present`. */
|
|
30
|
+
private originX;
|
|
31
|
+
private originY;
|
|
32
|
+
/** The last frame's size, and how many presents in a row it stayed well inside a quarter of the buffer. */
|
|
33
|
+
private lastW;
|
|
34
|
+
private lastH;
|
|
35
|
+
private small;
|
|
36
|
+
constructor();
|
|
37
|
+
/** Textures made, spent buffers waiting in the pool and their bytes (the leak tools read it). */
|
|
38
|
+
static stats(): {
|
|
39
|
+
made: number;
|
|
40
|
+
pooled: number;
|
|
41
|
+
pooledBytes: number;
|
|
42
|
+
};
|
|
43
|
+
/** Lets every pooled buffer go (the world changed map): the next map's effects start a pool of their own. */
|
|
44
|
+
static drainPool(): void;
|
|
45
|
+
fillStyle(color: number, alpha?: number): this;
|
|
46
|
+
fillRect(x: number, y: number, w: number, h: number): this;
|
|
47
|
+
/** `fillStyle` + `fillRect` on whole pixels in one call, leaving the fill style alone (a hot loop's way in). */
|
|
48
|
+
rect(x: number, y: number, w: number, h: number, color: number, alpha?: number): void;
|
|
49
|
+
/**
|
|
50
|
+
* A solid run of `w` whole pixels at (x, y) in `color`, held until `commit` lays every staged run in the order given
|
|
51
|
+
* (the later winning where they cross), after whatever was drawn before the commit. What `pixelTone`'s batch writes
|
|
52
|
+
* instead of filing each pixel in a map and sorting it into rects.
|
|
53
|
+
*/
|
|
54
|
+
stage(x: number, y: number, w: number, color: number): void;
|
|
55
|
+
/** Lays the staged runs, as opaque rects, after everything drawn so far. */
|
|
56
|
+
commit(): void;
|
|
57
|
+
clear(): this;
|
|
58
|
+
/** How far the last frame reached from the layer's origin, in world pixels (0 when nothing showed). */
|
|
59
|
+
reach(): number;
|
|
60
|
+
/** Writes this frame's rects into the texture and shows it; call once the frame is painted. */
|
|
61
|
+
present(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Shows `other`'s last frame instead of painting one: its texture, placed where it placed it. A frame shared by
|
|
64
|
+
* several bodies (the same aura on two bodies) is painted once and shown by each of their layers.
|
|
65
|
+
*/
|
|
66
|
+
mirror(other: PixelLayer): void;
|
|
67
|
+
/** Shows nothing and lets go of the texture a `mirror` showed. */
|
|
68
|
+
hideMirror(): void;
|
|
69
|
+
/** The premultiplied [r, g, b, a] last presented at layer pixel (x, y); zeros where nothing was (tests read it). */
|
|
70
|
+
pixelAt(x: number, y: number): [number, number, number, number];
|
|
71
|
+
/** The buffer's size (tests read it). */
|
|
72
|
+
capacity(): {
|
|
73
|
+
w: number;
|
|
74
|
+
h: number;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* A buffer at least `w` × `h`: grown a size class at a time and kept while it fits, traded back to the pool for a
|
|
78
|
+
* smaller one only once the frames have stayed well inside it for `SHRINK_AFTER` presents (a long-lived layer — an
|
|
79
|
+
* aura, a status mark — that once swelled would otherwise hold and upload its largest buffer for good).
|
|
80
|
+
*/
|
|
81
|
+
private fit;
|
|
82
|
+
private dropSurface;
|
|
83
|
+
destroy(): void;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=PixelLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PixelLayer.d.ts","sourceRoot":"","sources":["../../../src/pixel/PixelLayer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAqF3C;;;;;;;;;;;;;;GAcG;AACH,qDAAqD;AACrD,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,UAAU,CAEtD;AAED,qBAAa,UAAW,SAAQ,QAAQ;IACtC,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,gGAAgG;IAChG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD,OAAO,CAAC,OAAO,CAAwB;IACvC,kFAAkF;IAClF,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;IACpB,2GAA2G;IAC3G,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,KAAK,CAAK;;IAQlB,iGAAiG;IACjG,MAAM,CAAC,KAAK,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;IAMrE,6GAA6G;IAC7G,MAAM,CAAC,SAAS,IAAI,IAAI;IAMf,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,IAAI;IAMzC,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IASnE,gHAAgH;IAChH,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,IAAI;IAKhF;;;;OAIG;IACH,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAI3D,4EAA4E;IAC5E,MAAM,IAAI,IAAI;IASL,KAAK,IAAI,IAAI;IAMtB,uGAAuG;IACvG,KAAK,IAAI,MAAM;IAKf,+FAA+F;IAC/F,OAAO,IAAI,IAAI;IAsFf;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAe/B,kEAAkE;IAClE,UAAU,IAAI,IAAI;IAKlB,oHAAoH;IACpH,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IAa/D,yCAAyC;IACzC,QAAQ,IAAI;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;IAIpC;;;;OAIG;IACH,OAAO,CAAC,GAAG;IAmBX,OAAO,CAAC,WAAW;IAMV,OAAO,IAAI,IAAI;CAKzB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dither, Lantern Engine's pixel-art module: `import { … } from 'lantern-engine/pixel'`.
|
|
3
|
+
*
|
|
4
|
+
* Everything here works on the world's own pixel grid: rects batched into one texture, shapes shaded by hue-shifted
|
|
5
|
+
* ramps and faded by ordered dither, dithered lighting, bodies that evaporate into their own pixels. Start the engine
|
|
6
|
+
* with `pixelPerfect: true` so textures stay sharp and the camera lands on whole pixels.
|
|
7
|
+
*/
|
|
8
|
+
export { PixelLayer, addPixelLayer } from './PixelLayer.js';
|
|
9
|
+
export { PixelGrid, PixelWindow, CLEAR, rgba, hex, channels, shade, mix, withAlpha, toCss, hash2, mulberry32, valueNoise, makeSheet, upscale, type Color, } from './pixel.js';
|
|
10
|
+
export { P as PALETTE } from './palette.js';
|
|
11
|
+
export { art, litOutline, groundShadow, shadeBox, type PropArt } from './propKit.js';
|
|
12
|
+
export { ramp, rampTones, hueShade, outlineOf, MATERIALS, type Material, type Ramp } from './ramp.js';
|
|
13
|
+
export { selectiveOutline } from './selout.js';
|
|
14
|
+
/** Pixel shapes on the 1-px world grid: `pixelPaint.ring(g, …)`, `pixelPaint.arc(g, …)`… */
|
|
15
|
+
export * as pixelPaint from './pixelPaint.js';
|
|
16
|
+
/** Colour ramps, grading, dithering and batching under `pixelPaint`. */
|
|
17
|
+
export * as pixelTone from './pixelTone.js';
|
|
18
|
+
export { Evaporation, type DeathPixels } from './Evaporation.js';
|
|
19
|
+
export { spritePixels, NO_PIXELS, PackedPixels, type SpritePixel } from './spritePixels.js';
|
|
20
|
+
export { Darkness, WARM_LIGHT, LAMP_DIM, CARRIED_LIGHT } from './Darkness.js';
|
|
21
|
+
export { flashLight, carriedLight, liveLights, clearLights, type TransientLight } from './lights.js';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pixel/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EACL,SAAS,EACT,WAAW,EACX,KAAK,EACL,IAAI,EACJ,GAAG,EACH,QAAQ,EACR,KAAK,EACL,GAAG,EACH,SAAS,EACT,KAAK,EACL,KAAK,EACL,UAAU,EACV,UAAU,EACV,SAAS,EACT,OAAO,EACP,KAAK,KAAK,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,CAAC,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,4FAA4F;AAC5F,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,wEAAwE;AACxE,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface TransientLight {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
/** Radius at its brightest, world px. */
|
|
5
|
+
r: number;
|
|
6
|
+
born: number;
|
|
7
|
+
/** When it is gone; a carried light's is pushed to `CARRIED_MAX_MS` and brought in by its `end()`. */
|
|
8
|
+
until: number;
|
|
9
|
+
/** A light riding a moving thing reads its place every frame. */
|
|
10
|
+
follow?: () => {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
/** A flash shrinks as it goes out; a carried light keeps its size. */
|
|
15
|
+
fades: boolean;
|
|
16
|
+
/** The colour it lays on what it lights: a fireball's orange, a spell's violet, a blade's white. */
|
|
17
|
+
color: number;
|
|
18
|
+
}
|
|
19
|
+
/** A flash at (x, y) in `color`: `r` px at once, shrinking to nothing over `ms`. */
|
|
20
|
+
export declare function flashLight(x: number, y: number, r: number, ms: number, color?: number, now?: number): void;
|
|
21
|
+
/** A light that rides `at` until `end()` is called (a shot in flight), and never past `CARRIED_MAX_MS`. */
|
|
22
|
+
export declare function carriedLight(at: () => {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
}, r: number, color?: number, now?: number): {
|
|
26
|
+
end: () => void;
|
|
27
|
+
};
|
|
28
|
+
/** The lights burning at `now`, each with its radius then; spent ones are dropped. None while combat lights are off. */
|
|
29
|
+
export declare function liveLights(now: number): readonly TransientLight[];
|
|
30
|
+
/** The radius `l` burns at `now`: a flash eases out from its full size, a carried light holds it. */
|
|
31
|
+
export declare function lightRadius(l: TransientLight, now: number): number;
|
|
32
|
+
/** A new map: nothing of the last one's fight is left burning. */
|
|
33
|
+
export declare function clearLights(): void;
|
|
34
|
+
//# sourceMappingURL=lights.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lights.d.ts","sourceRoot":"","sources":["../../../src/pixel/lights.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,cAAc;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,yCAAyC;IACzC,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,sGAAsG;IACtG,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,sEAAsE;IACtE,KAAK,EAAE,OAAO,CAAC;IACf,oGAAoG;IACpG,KAAK,EAAE,MAAM,CAAC;CACf;AASD,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,SAAQ,EAAE,GAAG,SAAoB,GAAG,IAAI,CAGpH;AAKD,2GAA2G;AAC3G,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,SAAQ,EAAE,GAAG,SAAoB,GAAG;IAAE,GAAG,EAAE,MAAM,IAAI,CAAA;CAAE,CAMvI;AAID,wHAAwH;AACxH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,cAAc,EAAE,CAoBjE;AAED,qGAAqG;AACrG,wBAAgB,WAAW,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIlE;AAED,kEAAkE;AAClE,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Shared colour palette: warm medieval fantasy tones, readable on green ground. */
|
|
2
|
+
export declare const P: {
|
|
3
|
+
readonly outline: number;
|
|
4
|
+
readonly outlineSoft: number;
|
|
5
|
+
readonly black: number;
|
|
6
|
+
readonly white: number;
|
|
7
|
+
readonly offWhite: number;
|
|
8
|
+
readonly skin: number;
|
|
9
|
+
readonly skinShade: number;
|
|
10
|
+
readonly skinTan: number;
|
|
11
|
+
readonly skinTanShade: number;
|
|
12
|
+
readonly blush: number;
|
|
13
|
+
readonly hairBlack: number;
|
|
14
|
+
readonly hairBrown: number;
|
|
15
|
+
readonly hairAuburn: number;
|
|
16
|
+
readonly hairWhite: number;
|
|
17
|
+
readonly hairGrey: number;
|
|
18
|
+
readonly red: number;
|
|
19
|
+
readonly redDark: number;
|
|
20
|
+
readonly crimson: number;
|
|
21
|
+
readonly orange: number;
|
|
22
|
+
readonly gold: number;
|
|
23
|
+
readonly goldDark: number;
|
|
24
|
+
readonly yellow: number;
|
|
25
|
+
readonly green: number;
|
|
26
|
+
readonly greenDark: number;
|
|
27
|
+
readonly jade: number;
|
|
28
|
+
readonly jadeDark: number;
|
|
29
|
+
readonly teal: number;
|
|
30
|
+
readonly sky: number;
|
|
31
|
+
readonly azure: number;
|
|
32
|
+
readonly blue: number;
|
|
33
|
+
readonly navy: number;
|
|
34
|
+
readonly indigo: number;
|
|
35
|
+
readonly purple: number;
|
|
36
|
+
readonly pink: number;
|
|
37
|
+
readonly brown: number;
|
|
38
|
+
readonly brownDark: number;
|
|
39
|
+
readonly brownLight: number;
|
|
40
|
+
readonly tan: number;
|
|
41
|
+
readonly cream: number;
|
|
42
|
+
readonly grey: number;
|
|
43
|
+
readonly greyDark: number;
|
|
44
|
+
readonly greyLight: number;
|
|
45
|
+
readonly steel: number;
|
|
46
|
+
readonly steelDark: number;
|
|
47
|
+
readonly iron: number;
|
|
48
|
+
readonly wood: number;
|
|
49
|
+
readonly woodDark: number;
|
|
50
|
+
readonly woodLight: number;
|
|
51
|
+
readonly straw: number;
|
|
52
|
+
readonly strawDark: number;
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../../src/pixel/palette.ts"],"names":[],"mappings":"AAEA,oFAAoF;AACpF,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDJ,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export type Color = number;
|
|
2
|
+
export declare const CLEAR: Color;
|
|
3
|
+
export declare function rgba(r: number, g: number, b: number, a?: number): Color;
|
|
4
|
+
export declare function hex(s: string): Color;
|
|
5
|
+
export declare function channels(c: Color): [number, number, number, number];
|
|
6
|
+
/** f < 1 darkens, f > 1 lightens toward white. */
|
|
7
|
+
export declare function shade(c: Color, f: number): Color;
|
|
8
|
+
export declare function mix(c1: Color, c2: Color, t: number): Color;
|
|
9
|
+
export declare function withAlpha(c: Color, alpha: number): Color;
|
|
10
|
+
export declare function toCss(c: Color): string;
|
|
11
|
+
export declare function hash2(x: number, y: number, seed?: number): number;
|
|
12
|
+
export declare function mulberry32(seed: number): () => number;
|
|
13
|
+
export declare function valueNoise(x: number, y: number, scale: number, seed: number): number;
|
|
14
|
+
export declare class PixelGrid {
|
|
15
|
+
readonly w: number;
|
|
16
|
+
readonly h: number;
|
|
17
|
+
readonly data: Uint32Array;
|
|
18
|
+
constructor(w: number, h: number);
|
|
19
|
+
inBounds(x: number, y: number): boolean;
|
|
20
|
+
px(x: number, y: number, c: Color): void;
|
|
21
|
+
get(x: number, y: number): Color;
|
|
22
|
+
alphaAt(x: number, y: number): number;
|
|
23
|
+
rect(x: number, y: number, w: number, h: number, c: Color): void;
|
|
24
|
+
hline(x0: number, x1: number, y: number, c: Color): void;
|
|
25
|
+
vline(x: number, y0: number, y1: number, c: Color): void;
|
|
26
|
+
/** Filled ellipse; a pixel is inside when its center lies inside the ellipse. */
|
|
27
|
+
ellipse(cx: number, cy: number, rx: number, ry: number, c: Color): void;
|
|
28
|
+
circle(cx: number, cy: number, r: number, c: Color): void;
|
|
29
|
+
ring(cx: number, cy: number, r: number, thickness: number, c: Color): void;
|
|
30
|
+
line(x0: number, y0: number, x1: number, y1: number, c: Color, thickness?: number): void;
|
|
31
|
+
/** Filled polygon (even-odd scanline on pixel centers). */
|
|
32
|
+
poly(points: [number, number][], c: Color): void;
|
|
33
|
+
/**
|
|
34
|
+
* Adds `width` pixels of outline around all opaque pixels, one ring at a time — the same result as calling it
|
|
35
|
+
* `width` times, but each ring only visits the neighbours of the ring before it instead of the whole grid again.
|
|
36
|
+
* (A pixel next to ring `k` is always filled by ring `k+1`, so nothing further back can still be waiting.)
|
|
37
|
+
*/
|
|
38
|
+
outline(c: Color, diagonal?: boolean, width?: number): void;
|
|
39
|
+
/** Replaces every pixel whose color matches `from`. */
|
|
40
|
+
recolor(from: Color, to: Color): void;
|
|
41
|
+
/** Multiplies brightness of opaque pixels matching `pred`. */
|
|
42
|
+
tint(f: number, pred: (x: number, y: number) => boolean): void;
|
|
43
|
+
blit(src: PixelGrid, dx: number, dy: number, flipX?: boolean): void;
|
|
44
|
+
/** Alpha-blends a color onto an existing pixel. */
|
|
45
|
+
blend(x: number, y: number, c: Color): void;
|
|
46
|
+
/** Reads a canvas back into a grid (a PNG layer of the paper doll joining the painted ones). */
|
|
47
|
+
static from(canvas: HTMLCanvasElement): PixelGrid;
|
|
48
|
+
/** The same picture on a grid `factor` times as fine, each pixel becoming a square block. */
|
|
49
|
+
upscaled(factor: number): PixelGrid;
|
|
50
|
+
/** Same size and same pixels. */
|
|
51
|
+
equals(other: PixelGrid): boolean;
|
|
52
|
+
/** Cheap hash of the pixels, for grouping identical frames before comparing them. */
|
|
53
|
+
key(): number;
|
|
54
|
+
clone(): PixelGrid;
|
|
55
|
+
toCanvas(): HTMLCanvasElement;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A grid that stands for one window of a larger picture: it is drawn on in the larger picture's coordinates and
|
|
59
|
+
* keeps only what falls inside `[x0, x0 + w) × [y0, y0 + h)`. A ground painter can paint a crop of a map into one, so the
|
|
60
|
+
* login screen does not paint the whole of two maps to show 17 tiles of each. Every drawing method goes through
|
|
61
|
+
* `px`/`get`/`inBounds`/`blend`; `outline`, `tint` and the whole-grid helpers work in window coordinates.
|
|
62
|
+
*/
|
|
63
|
+
export declare class PixelWindow extends PixelGrid {
|
|
64
|
+
readonly x0: number;
|
|
65
|
+
readonly y0: number;
|
|
66
|
+
constructor(x0: number, y0: number, w: number, h: number);
|
|
67
|
+
inBounds(x: number, y: number): boolean;
|
|
68
|
+
px(x: number, y: number, c: Color): void;
|
|
69
|
+
get(x: number, y: number): Color;
|
|
70
|
+
blend(x: number, y: number, c: Color): void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Packs same-sized frames into rows no wider than `maxWidth`. A browser refuses a canvas past about 16k pixels
|
|
74
|
+
* on a side and hands back a blank one, and a player sheet of six hundred frames at twice the detail is wider
|
|
75
|
+
* than that, so it wraps. Readers work the row out from the canvas width.
|
|
76
|
+
*/
|
|
77
|
+
export declare function makeSheet(frames: PixelGrid[], maxWidth?: number): HTMLCanvasElement;
|
|
78
|
+
/** Scales a canvas by an integer factor with nearest-neighbour filtering (for UI icons). */
|
|
79
|
+
export declare function upscale(src: HTMLCanvasElement, factor: number): HTMLCanvasElement;
|
|
80
|
+
//# sourceMappingURL=pixel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixel.d.ts","sourceRoot":"","sources":["../../../src/pixel/pixel.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B,eAAO,MAAM,KAAK,EAAE,KAAS,CAAC;AAE9B,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,SAAM,GAAG,KAAK,CAMpE;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,CAQpC;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAEnE;AAED,kDAAkD;AAClD,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK,CAOhD;AAED,wBAAgB,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK,CAI1D;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,iBAAiB,CASjF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Graphics } from '../core/Graphics.js';
|
|
2
|
+
export type Point = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const WHITE = 16774358;
|
|
7
|
+
export declare const snap: (n: number) => number;
|
|
8
|
+
/** A `size`-px square (1 by default: one art pixel) on the world grid, graded into the world palette. */
|
|
9
|
+
export declare function dot(g: Graphics, x: number, y: number, color: number, size?: number): void;
|
|
10
|
+
/** A horizontal run of `w` px from (x, y), one pixel tall; drawn pixel by pixel while a dither fade or outline is on. */
|
|
11
|
+
export declare function hline(g: Graphics, x: number, y: number, w: number, color: number): void;
|
|
12
|
+
/** Paints `draw` with a dark 1px outline round everything it drew, like the outline on character and prop sprites. */
|
|
13
|
+
export declare function outlined(g: Graphics, outline: number, draw: () => void): void;
|
|
14
|
+
/**
|
|
15
|
+
* A line `width` px thick built from 1px rows: the row on one side is lit, the far row deep, and a long stroke tapers
|
|
16
|
+
* to the deep tone at both ends and catches a glint a third of the way along.
|
|
17
|
+
*/
|
|
18
|
+
export declare function stroke(g: Graphics, a: Point, b: Point, color: number, width?: number): void;
|
|
19
|
+
/** A broken ellipse of radius `r` in the ground's 2:1 perspective, lit on the near side, turning with `phase`. */
|
|
20
|
+
export declare function ring(g: Graphics, r: number, color: number, phase?: number, cy?: number): void;
|
|
21
|
+
/** A faceted gem: light left face, base right face, deep lower tip and a glint on top once it is big enough. */
|
|
22
|
+
export declare function diamond(g: Graphics, x: number, y: number, r: number, color: number): void;
|
|
23
|
+
export declare function shards(g: Graphics, t: number, r: number, color: number, inward?: boolean): void;
|
|
24
|
+
/** A filled stepped disc of radius `r` (smoke, gas, puddles), in the ground's 2:1 perspective when `flat`. */
|
|
25
|
+
export declare function blob(g: Graphics, x: number, y: number, r: number, color: number, flat?: boolean): void;
|
|
26
|
+
/** A droplet thrown from (x, y) with velocity (vx, vy) px/s under gravity, `ms` after it left; null once it lands. */
|
|
27
|
+
export declare function drop(x: number, y: number, vx: number, vy: number, ms: number, ground?: number): Point | null;
|
|
28
|
+
/** A pixel X, `r` from its centre to a tip. */
|
|
29
|
+
export declare function xMark(g: Graphics, x: number, y: number, r: number, color: number): void;
|
|
30
|
+
/** A dash streak from `a` to `b`: a dark body with a bright core, eaten away from the start as `t` goes 0 to 1. */
|
|
31
|
+
export declare function dashStreak(g: Graphics, a: Point, b: Point, t: number, edge: number, core: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* A puff of smoke or gas: a small stepped disc whose rim is dithered (every other pixel) so it reads soft, with a
|
|
34
|
+
* lighter cap on its upper left. Solid discs the same size read as boulders or bushes.
|
|
35
|
+
*/
|
|
36
|
+
export declare function puffBlob(g: Graphics, x: number, y: number, r: number, body: number, light: number, frame?: number, opacity?: number): void;
|
|
37
|
+
/** An arc of dots on an ellipse from angle `a0` to `a1` (flat: in the ground's 2:1 perspective), `thick` rows deep. */
|
|
38
|
+
export declare function arc(g: Graphics, x: number, y: number, r: number, a0: number, a1: number, color: number, flat?: boolean, thick?: number): void;
|
|
39
|
+
/** Pale stepped dust puffs kicked up around (x, y) and settling over `t` 0..1. */
|
|
40
|
+
export declare function dust(g: Graphics, x: number, y: number, t: number, spread?: number, color?: number): void;
|
|
41
|
+
/** Pixel chunks flung out of (x, y) under gravity (rock, splinters): `ms` after the blow. */
|
|
42
|
+
export declare function debris(g: Graphics, x: number, y: number, count: number, speed: number, ms: number, colors: number[]): void;
|
|
43
|
+
//# sourceMappingURL=pixelPaint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixelPaint.d.ts","sourceRoot":"","sources":["../../../src/pixel/pixelPaint.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAUjD,MAAM,MAAM,KAAK,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;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E,IAAI,UAAO,EAAE,KAAK,SAAI,GAAG,IAAI,CAiBrI;AAED,kFAAkF;AAClF,wBAAgB,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,SAAK,EAAE,KAAK,SAAW,GAAG,IAAI,CAMtG;AAED,6FAA6F;AAC7F,wBAAgB,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAgB1H"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Graphics } from '../core/Graphics.js';
|
|
2
|
+
import { PixelLayer } from './PixelLayer.js';
|
|
3
|
+
export interface Ramp {
|
|
4
|
+
/** Darkest: under-shade and outline pixels. */
|
|
5
|
+
shade: number;
|
|
6
|
+
deep: number;
|
|
7
|
+
base: number;
|
|
8
|
+
light: number;
|
|
9
|
+
/** Near-white glint. */
|
|
10
|
+
hi: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function ramp(color: number): Ramp;
|
|
13
|
+
/** The formula's five tones for any colour: shadows cool and desaturate, highlights warm. */
|
|
14
|
+
export declare function derivedRamp(color: number): Ramp;
|
|
15
|
+
/**
|
|
16
|
+
* The colour a pixel is actually painted with: effects are authored in bright, saturated colours, and this pulls them
|
|
17
|
+
* into the world's palette (muted earth, grass and wood) — saturation down by a quarter, near-whites toned down and
|
|
18
|
+
* warmed, so an effect sits in the scene instead of glowing on top of it. Glints keep most of their lift.
|
|
19
|
+
*/
|
|
20
|
+
export declare function grade(color: number): number;
|
|
21
|
+
export declare function capturing(): Map<number, number> | null;
|
|
22
|
+
export declare function beginOutline(): void;
|
|
23
|
+
export declare function endOutline(g: Graphics, outline: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Lays pixels (keyed by `key`, each with its colour already graded) row by row, one rect for every run of one colour:
|
|
26
|
+
* the same pixels as one rect each, at a fraction of the rects (single-pixel rects ran to 5,000–9,000 a frame for one
|
|
27
|
+
* big ring or smoke, enough to be felt as lag).
|
|
28
|
+
*/
|
|
29
|
+
export declare function fillRuns(g: Graphics, pixels: Map<number, number>): void;
|
|
30
|
+
export declare function beginBatch(g: Graphics): void;
|
|
31
|
+
export declare function endBatch(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Where a solid pixel painted on `g` goes while its batch is open: the layer's staging, the batch's map, or nowhere
|
|
34
|
+
* (paint it now). `stagePixel` writes into whichever it is.
|
|
35
|
+
*/
|
|
36
|
+
export declare function batchFor(g: Graphics): Map<number, number> | PixelLayer | null;
|
|
37
|
+
/** Writes a solid run of `w` pixels at (x, y) into what `batchFor` returned. */
|
|
38
|
+
export declare function stageRun(held: Map<number, number> | PixelLayer, x: number, y: number, w: number, color: number): void;
|
|
39
|
+
/** Lays what the batch holds now, so a translucent fill that follows lies over it. */
|
|
40
|
+
export declare function flushBatch(): void;
|
|
41
|
+
/** The key `capturing()` and `fillRuns` file a world pixel under. */
|
|
42
|
+
export declare function pixelKey(x: number, y: number): number;
|
|
43
|
+
export declare function record(x: number, y: number, color: number): void;
|
|
44
|
+
export declare function setCoverage(value: number): void;
|
|
45
|
+
/** The current dither fade (1 while nothing fades), for translucent fills that fade with their layer. */
|
|
46
|
+
export declare function currentCoverage(): number;
|
|
47
|
+
/** Whether the world pixel at (x, y) is dropped by the current dither fade. */
|
|
48
|
+
export declare function dithered(x: number, y: number): boolean;
|
|
49
|
+
//# sourceMappingURL=pixelTone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixelTone.d.ts","sourceRoot":"","sources":["../../../src/pixel/pixelTone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD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,KAAK,EAAE,MAAM,GAAG,IAAI,CAMrH;AAED,sFAAsF;AACtF,wBAAgB,UAAU,IAAI,IAAI,CASjC;AA+BD,qEAAqE;AACrE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEhE;AAOD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED,yGAAyG;AACzG,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAKtD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Color, PixelGrid } from './pixel.js';
|
|
2
|
+
export interface PropArt {
|
|
3
|
+
canvas: HTMLCanvasElement;
|
|
4
|
+
anchorX: number;
|
|
5
|
+
anchorY: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function art(g: PixelGrid, anchorX: number, anchorY: number): PropArt;
|
|
8
|
+
/**
|
|
9
|
+
* The selective outline a prop takes, lit from the upper left like the map: the same ring a plain outline lays, but
|
|
10
|
+
* full dark only where the silhouette meets the ground (under it) and on its shadow side (the right); along the top
|
|
11
|
+
* and the left it is the darkest tone of the fill it borders (`outlineOf`), so a lit edge reads as the thing's own
|
|
12
|
+
* shade rather than a sticker's line. Translucent pixels (a cast
|
|
13
|
+
* shadow on the ground) are not part of the silhouette.
|
|
14
|
+
*/
|
|
15
|
+
export declare function litOutline(g: PixelGrid, dark?: Color): void;
|
|
16
|
+
/**
|
|
17
|
+
* A soft shadow thrown down and to the right onto the ground, laid only on empty pixels (call it after `litOutline`,
|
|
18
|
+
* or the outline would ring the shadow): a darker core and a fainter rim, the violet of the rocks' shadows.
|
|
19
|
+
*/
|
|
20
|
+
export declare function groundShadow(g: PixelGrid, cx: number, cy: number, rx: number, ry: number): void;
|
|
21
|
+
/**
|
|
22
|
+
* Moves every opaque pixel of a box one step into shadow (or, with `f > 1`, into light) along its own hue: the eave's
|
|
23
|
+
* shadow on a wall, the dark side of a chimney, a porch's shade. `mask` limits it to some pixels of the box.
|
|
24
|
+
*/
|
|
25
|
+
export declare function shadeBox(g: PixelGrid, x: number, y: number, w: number, h: number, f: number, mask?: (x: number, y: number) => boolean): void;
|
|
26
|
+
//# sourceMappingURL=propKit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propKit.d.ts","sourceRoot":"","sources":["../../../src/pixel/propKit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,SAAS,EAAQ,MAAM,SAAS,CAAC;AAQtD,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,GAAE,KAAiB,GAAG,IAAI,CAetE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAU/F;AAUD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAQ5I"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Color } from './pixel.js';
|
|
2
|
+
export type Material = 'cloth' | 'leather' | 'mail' | 'plate' | 'dragon' | 'fur' | 'skin' | 'hair' | 'gold' | 'gem' | 'shadow';
|
|
3
|
+
export declare const MATERIALS: readonly Material[];
|
|
4
|
+
/** Tones of one colour in one material, darkest to brightest. `base` is the colour itself. */
|
|
5
|
+
export interface Ramp {
|
|
6
|
+
/** Under-edges, rivets, seams: the darkest tone that is still the material. */
|
|
7
|
+
deep: Color;
|
|
8
|
+
dark: Color;
|
|
9
|
+
mid: Color;
|
|
10
|
+
base: Color;
|
|
11
|
+
light: Color;
|
|
12
|
+
/** One specular pixel: a plate's glint, a strand of hair, a buckle. */
|
|
13
|
+
glint: Color;
|
|
14
|
+
}
|
|
15
|
+
/** Every factor a ramp or a painter shades by — what a recolour or a fine-pass mask has to recognise. */
|
|
16
|
+
export declare const RAMP_FACTOR_SET: readonly number[];
|
|
17
|
+
/**
|
|
18
|
+
* `c` shaded by `f` the way `shade` would (f < 1 darkens, f > 1 lifts toward white), with the hue moved the way
|
|
19
|
+
* `material` moves it. `f === 1` returns `c` itself. A colour with too little saturation to have a hue (steel,
|
|
20
|
+
* grey wool, white linen) takes the material's hue outright, faintly, so a grey coat still has a violet shadow.
|
|
21
|
+
*/
|
|
22
|
+
export declare function hueShade(c: Color, f: number, material: Material): Color;
|
|
23
|
+
export declare function ramp(c: Color, material: Material): Ramp;
|
|
24
|
+
/** Every tone of `c`'s ramp, for masking a material cue to that material. */
|
|
25
|
+
export declare function rampTones(c: Color, material: Material): Color[];
|
|
26
|
+
/**
|
|
27
|
+
* The selective-outline tone of a fill: its own hue, cooled and pushed dark enough to hold an edge against grass
|
|
28
|
+
* (value at most 0.3), so the outline on the lit side is the fill's own darkest shade instead of flat black.
|
|
29
|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|
1
|
+
{"version":3,"file":"selout.d.ts","sourceRoot":"","sources":["../../../src/pixel/selout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAWzC,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,SAAI,GAAG,IAAI,CAmD9D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Image } from '../core/Image.js';
|
|
2
|
+
/** One opaque world pixel of a sprite frame: offset from the frame's feet (origin 0.5, 1) and its colour. */
|
|
3
|
+
export interface SpritePixel {
|
|
4
|
+
dx: number;
|
|
5
|
+
dy: number;
|
|
6
|
+
color: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A frame's opaque pixels packed in typed arrays (12 bytes a pixel instead of an object each). Iterating hands out one
|
|
10
|
+
* reused `SpritePixel`, so read it in the loop and keep nothing of it; `at(i)` reads one into a given object.
|
|
11
|
+
*/
|
|
12
|
+
export declare class PackedPixels implements Iterable<SpritePixel> {
|
|
13
|
+
readonly dx: Float32Array;
|
|
14
|
+
readonly dy: Float32Array;
|
|
15
|
+
readonly color: Uint32Array;
|
|
16
|
+
readonly length: number;
|
|
17
|
+
constructor(dx: Float32Array, dy: Float32Array, color: Uint32Array, length: number);
|
|
18
|
+
[Symbol.iterator](): Iterator<SpritePixel>;
|
|
19
|
+
}
|
|
20
|
+
/** No pixels: what a body hands over when there is nothing of it worth lifting (a death with nothing to evaporate). */
|
|
21
|
+
export declare const NO_PIXELS: PackedPixels;
|
|
22
|
+
/**
|
|
23
|
+
* The opaque pixels of an image's current frame, one per **world** pixel (`artScale` image pixels to one), as offsets
|
|
24
|
+
* from the frame's feet in unscaled, unflipped world pixels. Read straight off the texture's canvas, so it is the
|
|
25
|
+
* frame actually on screen. Atlas frames are shared by every body of one kind and cached (least recently read out
|
|
26
|
+
* first); a texture repainted while in use (a rig body) is read fresh.
|
|
27
|
+
*/
|
|
28
|
+
export declare function spritePixels(img: Image, artScale: number, live: boolean): PackedPixels;
|
|
29
|
+
//# sourceMappingURL=spritePixels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spritePixels.d.ts","sourceRoot":"","sources":["../../../src/pixel/spritePixels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C,6GAA6G;AAC7G,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,qBAAa,YAAa,YAAW,QAAQ,CAAC,WAAW,CAAC;IAEtD,QAAQ,CAAC,EAAE,EAAE,YAAY;IACzB,QAAQ,CAAC,EAAE,EAAE,YAAY;IACzB,QAAQ,CAAC,KAAK,EAAE,WAAW;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAHd,EAAE,EAAE,YAAY,EAChB,EAAE,EAAE,YAAY,EAChB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,MAAM;IAGxB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,WAAW,CAAC;CAS5C;AAGD,uHAAuH;AACvH,eAAO,MAAM,SAAS,cAAQ,CAAC;AAwB/B;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,YAAY,CA+CtF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** A native shell (Capacitor, Electron touch kiosk…) tells the engine it is one; browsers leave it false. */
|
|
2
|
+
export declare function setNativeShell(native: boolean): void;
|
|
3
|
+
/** True when the game is played with fingers (decided once per launch, `detectTouch`). */
|
|
4
|
+
export declare function isTouchUi(): boolean;
|
|
5
|
+
//# sourceMappingURL=touch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touch.d.ts","sourceRoot":"","sources":["../../../src/platform/touch.ts"],"names":[],"mappings":"AAKA,6GAA6G;AAC7G,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAGpD;AAqBD,0FAA0F;AAC1F,wBAAgB,SAAS,IAAI,OAAO,CAGnC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { RigPose } from './rigTypes.js';
|
|
2
|
+
/**
|
|
3
|
+
* A clip of key poses: by name (looked up in the player's library) or inline. The player blends between them, so a
|
|
4
|
+
* few keys make a smooth motion; `blend: false` steps from key to key instead (pixel-art timing, a tumble).
|
|
5
|
+
*/
|
|
6
|
+
export interface PoseClip {
|
|
7
|
+
poses: readonly (string | RigPose)[];
|
|
8
|
+
/** Keys per second (default 8). */
|
|
9
|
+
fps?: number;
|
|
10
|
+
/** Per-key lengths in ms, overriding `fps`. */
|
|
11
|
+
durations?: readonly number[];
|
|
12
|
+
/** Start over at the end, blending the last key into the first (default true). */
|
|
13
|
+
loop?: boolean;
|
|
14
|
+
/** Blend between keys (default true). */
|
|
15
|
+
blend?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Plays pose clips over time and answers the pose of this moment, blended between keys, with a crossfade when the
|
|
19
|
+
* clip changes. Pure: give it a library of poses and clips, call `update(dt)`, read `pose`.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const player = new PosePlayer(HUMANOID_POSES, HUMANOID_CLIPS, 'idle');
|
|
23
|
+
* player.play('walk', { fadeMs: 120 });
|
|
24
|
+
* player.update(dt);
|
|
25
|
+
* view.setPose(player.pose);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class PosePlayer<Name extends string = string> {
|
|
29
|
+
private readonly library;
|
|
30
|
+
private readonly clips;
|
|
31
|
+
private clip;
|
|
32
|
+
private name;
|
|
33
|
+
private elapsed;
|
|
34
|
+
private ended;
|
|
35
|
+
/** The pose being faded out of, and how long the fade lasts and has run. */
|
|
36
|
+
private from;
|
|
37
|
+
private fadeMs;
|
|
38
|
+
private fadeAt;
|
|
39
|
+
private cached;
|
|
40
|
+
speed: number;
|
|
41
|
+
/** Called when a clip that does not loop reaches its end. */
|
|
42
|
+
onComplete: ((clip: Name) => void) | null;
|
|
43
|
+
constructor(library: Readonly<Record<string, RigPose>>, clips: Record<Name, PoseClip>, initial: NoInfer<Name>);
|
|
44
|
+
get current(): Name;
|
|
45
|
+
get finished(): boolean;
|
|
46
|
+
/** Time into the current clip, ms. */
|
|
47
|
+
get time(): number;
|
|
48
|
+
/** Plays `name`, fading from the pose shown now over `fadeMs`. The clip already playing keeps going unless `restart`. */
|
|
49
|
+
play(name: Name, options?: {
|
|
50
|
+
fadeMs?: number;
|
|
51
|
+
restart?: boolean;
|
|
52
|
+
}): this;
|
|
53
|
+
/** Advances by `dt` seconds. */
|
|
54
|
+
update(dt: number): void;
|
|
55
|
+
/** The pose to show now. */
|
|
56
|
+
get pose(): RigPose;
|
|
57
|
+
/** The current clip's pose at `ms` into it. */
|
|
58
|
+
sample(ms: number): RigPose;
|
|
59
|
+
private totalMs;
|
|
60
|
+
private lengthOf;
|
|
61
|
+
private resolve;
|
|
62
|
+
private clipOf;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=PosePlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PosePlayer.d.ts","sourceRoot":"","sources":["../../../src/rig/PosePlayer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IACrC,mCAAmC;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,kFAA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