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
package/dist/pixel.js
ADDED
|
@@ -0,0 +1,1404 @@
|
|
|
1
|
+
import { Sprite as K, Texture as W, BufferImageSource as ae, RenderTexture as wt, Container as et } from "pixi.js";
|
|
2
|
+
import { a as re, p as he, e as Tt, T as ce, i as le } from "./constants-CjYVdFid.js";
|
|
3
|
+
he();
|
|
4
|
+
const xt = 1024, fe = [16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024], ue = 24, de = 24 * 1024 * 1024, Me = 60, Y = /* @__PURE__ */ new Map();
|
|
5
|
+
let V = 0, Ht = 0;
|
|
6
|
+
const yt = (o) => {
|
|
7
|
+
for (const t of fe) if (t >= o) return t;
|
|
8
|
+
return Math.ceil(o / 256) * 256;
|
|
9
|
+
}, Ct = (o, t) => o * 4096 + t;
|
|
10
|
+
function pe(o, t) {
|
|
11
|
+
let e = Y.get(Ct(o, t));
|
|
12
|
+
if (!e?.length) {
|
|
13
|
+
let i = 1 / 0;
|
|
14
|
+
for (const [r, h] of Y) {
|
|
15
|
+
if (!h.length) continue;
|
|
16
|
+
const c = Math.floor(r / 4096), l = r % 4096, d = c * l;
|
|
17
|
+
c >= o && l >= t && d <= o * t * 2 && d < i && (i = d, e = h);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const n = e?.pop();
|
|
21
|
+
if (n)
|
|
22
|
+
return V -= n.pixels.byteLength, n;
|
|
23
|
+
Ht++;
|
|
24
|
+
const s = new Uint8Array(o * t * 4), a = new ae({
|
|
25
|
+
resource: s,
|
|
26
|
+
width: o,
|
|
27
|
+
height: t,
|
|
28
|
+
format: "rgba8unorm",
|
|
29
|
+
alphaMode: "premultiplied-alpha",
|
|
30
|
+
scaleMode: "nearest"
|
|
31
|
+
});
|
|
32
|
+
return { pixels: s, words: new Uint32Array(s.buffer), source: a, texture: new W({ source: a }), capW: o, capH: t };
|
|
33
|
+
}
|
|
34
|
+
function ge(o) {
|
|
35
|
+
const t = Ct(o.capW, o.capH);
|
|
36
|
+
let e = Y.get(t);
|
|
37
|
+
if (e || Y.set(t, e = []), e.length >= ue || V + o.pixels.byteLength > de) {
|
|
38
|
+
o.texture.destroy(!0);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
e.push(o), V += o.pixels.byteLength;
|
|
42
|
+
}
|
|
43
|
+
function me(o) {
|
|
44
|
+
return o.add.existing(new J());
|
|
45
|
+
}
|
|
46
|
+
class J extends re {
|
|
47
|
+
/** This frame's rects: x, y, w, h, colour, alpha — six numbers each. */
|
|
48
|
+
rects = [];
|
|
49
|
+
/** Staged solid runs not yet committed: x, y, w, colour — four numbers each; later ones win. */
|
|
50
|
+
staged = [];
|
|
51
|
+
ink = 16777215;
|
|
52
|
+
inkAlpha = 1;
|
|
53
|
+
sprite = new K(W.EMPTY);
|
|
54
|
+
surface = null;
|
|
55
|
+
/** Where the buffer's first pixel sits in the layer, as of the last `present`. */
|
|
56
|
+
originX = 0;
|
|
57
|
+
originY = 0;
|
|
58
|
+
/** The last frame's size, and how many presents in a row it stayed well inside a quarter of the buffer. */
|
|
59
|
+
lastW = 0;
|
|
60
|
+
lastH = 0;
|
|
61
|
+
small = 0;
|
|
62
|
+
constructor() {
|
|
63
|
+
super(), this.sprite.visible = !1, this.addChild(this.sprite);
|
|
64
|
+
}
|
|
65
|
+
/** Textures made, spent buffers waiting in the pool and their bytes (the leak tools read it). */
|
|
66
|
+
static stats() {
|
|
67
|
+
let t = 0;
|
|
68
|
+
for (const e of Y.values()) t += e.length;
|
|
69
|
+
return { made: Ht, pooled: t, pooledBytes: V };
|
|
70
|
+
}
|
|
71
|
+
/** Lets every pooled buffer go (the world changed map): the next map's effects start a pool of their own. */
|
|
72
|
+
static drainPool() {
|
|
73
|
+
for (const t of Y.values()) for (const e of t) e.texture.destroy(!0);
|
|
74
|
+
Y.clear(), V = 0;
|
|
75
|
+
}
|
|
76
|
+
fillStyle(t, e = 1) {
|
|
77
|
+
return this.ink = t, this.inkAlpha = e, super.fillStyle(t, e);
|
|
78
|
+
}
|
|
79
|
+
fillRect(t, e, n, s) {
|
|
80
|
+
const a = Math.round(t), i = Math.round(e), r = Math.round(t + n) - a, h = Math.round(e + s) - i;
|
|
81
|
+
return r > 0 && h > 0 && this.inkAlpha > 0 && this.rects.push(a, i, r, h, this.ink, this.inkAlpha), this;
|
|
82
|
+
}
|
|
83
|
+
/** `fillStyle` + `fillRect` on whole pixels in one call, leaving the fill style alone (a hot loop's way in). */
|
|
84
|
+
rect(t, e, n, s, a, i = 1) {
|
|
85
|
+
n > 0 && s > 0 && i > 0 && Number.isFinite(t) && Number.isFinite(e) && Number.isFinite(n) && Number.isFinite(s) && this.rects.push(t, e, n, s, a, i);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A solid run of `w` whole pixels at (x, y) in `color`, held until `commit` lays every staged run in the order given
|
|
89
|
+
* (the later winning where they cross), after whatever was drawn before the commit. What `pixelTone`'s batch writes
|
|
90
|
+
* instead of filing each pixel in a map and sorting it into rects.
|
|
91
|
+
*/
|
|
92
|
+
stage(t, e, n, s) {
|
|
93
|
+
Number.isFinite(t) && Number.isFinite(e) && Number.isFinite(n) && this.staged.push(t, e, n, s);
|
|
94
|
+
}
|
|
95
|
+
/** Lays the staged runs, as opaque rects, after everything drawn so far. */
|
|
96
|
+
commit() {
|
|
97
|
+
const t = this.staged, e = t.length;
|
|
98
|
+
if (e === 0) return;
|
|
99
|
+
const n = this.rects;
|
|
100
|
+
for (let s = 0; s < e; s += 4) n.push(t[s], t[s + 1], t[s + 2], 1, t[s + 3], 1);
|
|
101
|
+
t.length = 0;
|
|
102
|
+
}
|
|
103
|
+
clear() {
|
|
104
|
+
return this.rects.length = 0, this.staged.length = 0, super.clear();
|
|
105
|
+
}
|
|
106
|
+
/** How far the last frame reached from the layer's origin, in world pixels (0 when nothing showed). */
|
|
107
|
+
reach() {
|
|
108
|
+
return this.sprite.visible ? Math.max(Math.abs(this.originX), Math.abs(this.originY), Math.abs(this.originX + this.lastW), Math.abs(this.originY + this.lastH)) : 0;
|
|
109
|
+
}
|
|
110
|
+
/** Writes this frame's rects into the texture and shows it; call once the frame is painted. */
|
|
111
|
+
present() {
|
|
112
|
+
this.commit();
|
|
113
|
+
const t = this.rects;
|
|
114
|
+
if (t.length === 0) {
|
|
115
|
+
this.sprite.visible = !1;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
let e = 1 / 0, n = 1 / 0, s = -1 / 0, a = -1 / 0;
|
|
119
|
+
for (let u = 0; u < t.length; u += 6)
|
|
120
|
+
t[u] < e && (e = t[u]), t[u + 1] < n && (n = t[u + 1]), t[u] + t[u + 2] > s && (s = t[u] + t[u + 2]), t[u + 1] + t[u + 3] > a && (a = t[u + 1] + t[u + 3]);
|
|
121
|
+
const i = s - e, r = a - n;
|
|
122
|
+
if (i > xt || r > xt) {
|
|
123
|
+
this.sprite.visible = !1;
|
|
124
|
+
const u = t.length;
|
|
125
|
+
for (let f = 0; f < u; f += 6)
|
|
126
|
+
super.fillStyle(t[f + 4], t[f + 5]), super.fillRect(t[f], t[f + 1], t[f + 2], t[f + 3]);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const h = this.fit(i, r), { words: c, pixels: l, capW: d } = h;
|
|
130
|
+
c.fill(0);
|
|
131
|
+
for (let u = 0; u < t.length; u += 6) {
|
|
132
|
+
const f = t[u] - e, M = t[u + 1] - n, p = t[u + 2], g = t[u + 3], b = t[u + 4], w = t[u + 5], x = b >> 16 & 255, y = b >> 8 & 255, A = b & 255;
|
|
133
|
+
if (w >= 1) {
|
|
134
|
+
const F = (4278190080 | A << 16 | y << 8 | x) >>> 0;
|
|
135
|
+
if (p === 1 && g === 1) {
|
|
136
|
+
c[M * d + f] = F;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
for (let k = M; k < M + g; k++) {
|
|
140
|
+
const X = k * d + f;
|
|
141
|
+
if (p < 8) for (let lt = X, ie = X + p; lt < ie; lt++) c[lt] = F;
|
|
142
|
+
else c.fill(F, X, X + p);
|
|
143
|
+
}
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const S = 1 - w, B = x * w, tt = y * w, se = A * w, oe = 255 * w;
|
|
147
|
+
for (let F = M; F < M + g; F++)
|
|
148
|
+
for (let k = (F * d + f) * 4, X = k + p * 4; k < X; k += 4)
|
|
149
|
+
l[k] = B + l[k] * S, l[k + 1] = tt + l[k + 1] * S, l[k + 2] = se + l[k + 2] * S, l[k + 3] = oe + l[k + 3] * S;
|
|
150
|
+
}
|
|
151
|
+
h.source.update(), this.sprite.texture = h.texture, this.sprite.position.set(e, n), this.sprite.visible = !0, this.originX = e, this.originY = n, this.lastW = i, this.lastH = r;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Shows `other`'s last frame instead of painting one: its texture, placed where it placed it. A frame shared by
|
|
155
|
+
* several bodies (the same aura on two bodies) is painted once and shown by each of their layers.
|
|
156
|
+
*/
|
|
157
|
+
mirror(t) {
|
|
158
|
+
const e = t.surface;
|
|
159
|
+
if (!e || !t.sprite.visible) {
|
|
160
|
+
this.hideMirror();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.sprite.texture = e.texture, this.sprite.position.set(t.originX, t.originY), this.sprite.visible = !0, this.originX = t.originX, this.originY = t.originY, this.lastW = t.lastW, this.lastH = t.lastH;
|
|
164
|
+
}
|
|
165
|
+
/** Shows nothing and lets go of the texture a `mirror` showed. */
|
|
166
|
+
hideMirror() {
|
|
167
|
+
this.sprite.visible = !1, this.sprite.texture = this.surface?.texture ?? W.EMPTY;
|
|
168
|
+
}
|
|
169
|
+
/** The premultiplied [r, g, b, a] last presented at layer pixel (x, y); zeros where nothing was (tests read it). */
|
|
170
|
+
pixelAt(t, e) {
|
|
171
|
+
const n = this.surface, s = n?.capW ?? 0, a = n?.capH ?? 0;
|
|
172
|
+
if (this.sprite.width !== s || this.sprite.height !== a) throw new Error("PixelLayer sprite is scaled");
|
|
173
|
+
const i = t - this.originX, r = e - this.originY;
|
|
174
|
+
if (!n || !this.sprite.visible || i < 0 || r < 0 || i >= s || r >= a) return [0, 0, 0, 0];
|
|
175
|
+
const h = (r * s + i) * 4;
|
|
176
|
+
return [n.pixels[h], n.pixels[h + 1], n.pixels[h + 2], n.pixels[h + 3]];
|
|
177
|
+
}
|
|
178
|
+
/** The buffer's size (tests read it). */
|
|
179
|
+
capacity() {
|
|
180
|
+
return { w: this.surface?.capW ?? 0, h: this.surface?.capH ?? 0 };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* 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
|
|
184
|
+
* smaller one only once the frames have stayed well inside it for `SHRINK_AFTER` presents (a long-lived layer — an
|
|
185
|
+
* aura, a status mark — that once swelled would otherwise hold and upload its largest buffer for good).
|
|
186
|
+
*/
|
|
187
|
+
fit(t, e) {
|
|
188
|
+
const n = this.surface;
|
|
189
|
+
if (n && t <= n.capW && e <= n.capH) {
|
|
190
|
+
const h = n.capW * n.capH >= 16384 && t * 4 <= n.capW && e * 4 <= n.capH;
|
|
191
|
+
if (this.small = h ? this.small + 1 : 0, this.small < Me) return n;
|
|
192
|
+
}
|
|
193
|
+
this.small = 0;
|
|
194
|
+
const s = !!n && (t > n.capW || e > n.capH), a = yt(Math.max(1, t, s ? n.capW : 0)), i = yt(Math.max(1, e, s ? n.capH : 0));
|
|
195
|
+
this.dropSurface();
|
|
196
|
+
const r = pe(a, i);
|
|
197
|
+
return this.surface = r, this.sprite.texture = r.texture, r;
|
|
198
|
+
}
|
|
199
|
+
dropSurface() {
|
|
200
|
+
this.sprite.texture = W.EMPTY, this.surface && ge(this.surface), this.surface = null;
|
|
201
|
+
}
|
|
202
|
+
destroy() {
|
|
203
|
+
this.destroyed || (this.dropSurface(), super.destroy());
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const bt = 0;
|
|
207
|
+
function L(o, t, e, n = 255) {
|
|
208
|
+
const s = Math.max(0, Math.min(255, Math.round(o))), a = Math.max(0, Math.min(255, Math.round(t))), i = Math.max(0, Math.min(255, Math.round(e)));
|
|
209
|
+
return (Math.max(0, Math.min(255, Math.round(n))) << 24 | i << 16 | a << 8 | s) >>> 0;
|
|
210
|
+
}
|
|
211
|
+
function m(o) {
|
|
212
|
+
let t = o.startsWith("#") ? o.slice(1) : o;
|
|
213
|
+
t.length === 3 && (t = [...t].map((i) => i + i).join(""));
|
|
214
|
+
const e = parseInt(t.slice(0, 2), 16), n = parseInt(t.slice(2, 4), 16), s = parseInt(t.slice(4, 6), 16), a = t.length >= 8 ? parseInt(t.slice(6, 8), 16) : 255;
|
|
215
|
+
return L(e, n, s, a);
|
|
216
|
+
}
|
|
217
|
+
function R(o) {
|
|
218
|
+
return [o & 255, o >>> 8 & 255, o >>> 16 & 255, o >>> 24 & 255];
|
|
219
|
+
}
|
|
220
|
+
function $t(o, t) {
|
|
221
|
+
const [e, n, s, a] = R(o);
|
|
222
|
+
if (t >= 1) {
|
|
223
|
+
const i = Math.min(1, t - 1);
|
|
224
|
+
return L(e + (255 - e) * i, n + (255 - n) * i, s + (255 - s) * i, a);
|
|
225
|
+
}
|
|
226
|
+
return L(e * t, n * t, s * t, a);
|
|
227
|
+
}
|
|
228
|
+
function we(o, t, e) {
|
|
229
|
+
const n = R(o), s = R(t);
|
|
230
|
+
return L(n[0] + (s[0] - n[0]) * e, n[1] + (s[1] - n[1]) * e, n[2] + (s[2] - n[2]) * e, n[3] + (s[3] - n[3]) * e);
|
|
231
|
+
}
|
|
232
|
+
function un(o, t) {
|
|
233
|
+
const [e, n, s] = R(o);
|
|
234
|
+
return L(e, n, s, t);
|
|
235
|
+
}
|
|
236
|
+
function dn(o) {
|
|
237
|
+
const [t, e, n, s] = R(o);
|
|
238
|
+
return `rgba(${t},${e},${n},${(s / 255).toFixed(3)})`;
|
|
239
|
+
}
|
|
240
|
+
function nt(o, t, e = 0) {
|
|
241
|
+
let n = o * 374761393 + t * 668265263 + e * 2147483647 | 0;
|
|
242
|
+
return n = Math.imul(n ^ n >>> 13, 1274126177), ((n ^ n >>> 16) >>> 0) / 4294967296;
|
|
243
|
+
}
|
|
244
|
+
function Mn(o) {
|
|
245
|
+
let t = o >>> 0;
|
|
246
|
+
return () => {
|
|
247
|
+
t = t + 1831565813 >>> 0;
|
|
248
|
+
let e = t;
|
|
249
|
+
return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function pn(o, t, e, n) {
|
|
253
|
+
const s = o / e, a = t / e, i = Math.floor(s), r = Math.floor(a), h = s - i, c = a - r, l = h * h * (3 - 2 * h), d = c * c * (3 - 2 * c), u = nt(i, r, n), f = nt(i + 1, r, n), M = nt(i, r + 1, n), p = nt(i + 1, r + 1, n);
|
|
254
|
+
return u + (f - u) * l + (M - u) * d + (u - f - M + p) * l * d;
|
|
255
|
+
}
|
|
256
|
+
class G {
|
|
257
|
+
constructor(t, e) {
|
|
258
|
+
this.w = t, this.h = e, this.data = new Uint32Array(t * e);
|
|
259
|
+
}
|
|
260
|
+
w;
|
|
261
|
+
h;
|
|
262
|
+
data;
|
|
263
|
+
inBounds(t, e) {
|
|
264
|
+
return t >= 0 && e >= 0 && t < this.w && e < this.h;
|
|
265
|
+
}
|
|
266
|
+
px(t, e, n) {
|
|
267
|
+
t = Math.floor(t), e = Math.floor(e), t >= 0 && e >= 0 && t < this.w && e < this.h && (this.data[e * this.w + t] = n);
|
|
268
|
+
}
|
|
269
|
+
get(t, e) {
|
|
270
|
+
return t < 0 || e < 0 || t >= this.w || e >= this.h ? bt : this.data[e * this.w + t] ?? bt;
|
|
271
|
+
}
|
|
272
|
+
alphaAt(t, e) {
|
|
273
|
+
return this.get(t, e) >>> 24;
|
|
274
|
+
}
|
|
275
|
+
rect(t, e, n, s, a) {
|
|
276
|
+
for (let i = Math.floor(e); i < e + s; i++) for (let r = Math.floor(t); r < t + n; r++) this.px(r, i, a);
|
|
277
|
+
}
|
|
278
|
+
hline(t, e, n, s) {
|
|
279
|
+
for (let a = Math.min(t, e); a <= Math.max(t, e); a++) this.px(a, n, s);
|
|
280
|
+
}
|
|
281
|
+
vline(t, e, n, s) {
|
|
282
|
+
for (let a = Math.min(e, n); a <= Math.max(e, n); a++) this.px(t, a, s);
|
|
283
|
+
}
|
|
284
|
+
/** Filled ellipse; a pixel is inside when its center lies inside the ellipse. */
|
|
285
|
+
ellipse(t, e, n, s, a) {
|
|
286
|
+
if (!(n <= 0 || s <= 0))
|
|
287
|
+
for (let i = Math.floor(e - s); i <= Math.ceil(e + s); i++)
|
|
288
|
+
for (let r = Math.floor(t - n); r <= Math.ceil(t + n); r++) {
|
|
289
|
+
const h = (r + 0.5 - t) / n, c = (i + 0.5 - e) / s;
|
|
290
|
+
h * h + c * c <= 1 && this.px(r, i, a);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
circle(t, e, n, s) {
|
|
294
|
+
this.ellipse(t, e, n, n, s);
|
|
295
|
+
}
|
|
296
|
+
ring(t, e, n, s, a) {
|
|
297
|
+
for (let i = Math.floor(e - n - 1); i <= Math.ceil(e + n + 1); i++)
|
|
298
|
+
for (let r = Math.floor(t - n - 1); r <= Math.ceil(t + n + 1); r++) {
|
|
299
|
+
const h = Math.hypot(r + 0.5 - t, i + 0.5 - e);
|
|
300
|
+
h <= n && h >= n - s && this.px(r, i, a);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
line(t, e, n, s, a, i = 1) {
|
|
304
|
+
t = Math.round(t), e = Math.round(e), n = Math.round(n), s = Math.round(s);
|
|
305
|
+
const r = Math.abs(n - t), h = -Math.abs(s - e), c = t < n ? 1 : -1, l = e < s ? 1 : -1;
|
|
306
|
+
let d = r + h;
|
|
307
|
+
for (; i <= 1 ? this.px(t, e, a) : this.rect(t - Math.floor((i - 1) / 2), e - Math.floor((i - 1) / 2), i, i, a), !(t === n && e === s); ) {
|
|
308
|
+
const u = 2 * d;
|
|
309
|
+
u >= h && (d += h, t += c), u <= r && (d += r, e += l);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/** Filled polygon (even-odd scanline on pixel centers). */
|
|
313
|
+
poly(t, e) {
|
|
314
|
+
if (t.length < 3) return;
|
|
315
|
+
const n = Math.floor(Math.min(...t.map((a) => a[1]))), s = Math.ceil(Math.max(...t.map((a) => a[1])));
|
|
316
|
+
for (let a = n; a <= s; a++) {
|
|
317
|
+
const i = a + 0.5, r = [];
|
|
318
|
+
for (let h = 0; h < t.length; h++) {
|
|
319
|
+
const c = t[h], l = t[(h + 1) % t.length];
|
|
320
|
+
(c[1] <= i && l[1] > i || l[1] <= i && c[1] > i) && r.push(c[0] + (i - c[1]) / (l[1] - c[1]) * (l[0] - c[0]));
|
|
321
|
+
}
|
|
322
|
+
r.sort((h, c) => h - c);
|
|
323
|
+
for (let h = 0; h + 1 < r.length; h += 2)
|
|
324
|
+
for (let c = Math.ceil(r[h] - 0.5); c <= Math.floor(r[h + 1] - 0.5); c++) this.px(c, a, e);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Adds `width` pixels of outline around all opaque pixels, one ring at a time — the same result as calling it
|
|
329
|
+
* `width` times, but each ring only visits the neighbours of the ring before it instead of the whole grid again.
|
|
330
|
+
* (A pixel next to ring `k` is always filled by ring `k+1`, so nothing further back can still be waiting.)
|
|
331
|
+
*/
|
|
332
|
+
outline(t, e = !1, n = 1) {
|
|
333
|
+
const s = this.w, a = this.h, i = new Uint8Array(this.data.length);
|
|
334
|
+
let r = s, h = a, c = -1, l = -1;
|
|
335
|
+
for (let f = 0; f < a; f++)
|
|
336
|
+
for (let M = 0; M < s; M++) {
|
|
337
|
+
const p = f * s + M;
|
|
338
|
+
this.data[p] >>> 24 && (i[p] = 1, M < r && (r = M), M > c && (c = M), f < h && (h = f), l = f);
|
|
339
|
+
}
|
|
340
|
+
if (c < 0) return;
|
|
341
|
+
const d = (f, M, p) => f >= 0 && M >= 0 && f < s && M < a && i[p] === 1;
|
|
342
|
+
let u = [];
|
|
343
|
+
for (let f = Math.max(0, h - 1); f <= Math.min(a - 1, l + 1); f++)
|
|
344
|
+
for (let M = Math.max(0, r - 1); M <= Math.min(s - 1, c + 1); M++) {
|
|
345
|
+
const p = f * s + M;
|
|
346
|
+
if (i[p]) continue;
|
|
347
|
+
let g = d(M - 1, f, p - 1) || d(M + 1, f, p + 1) || d(M, f - 1, p - s) || d(M, f + 1, p + s);
|
|
348
|
+
!g && e && (g = d(M - 1, f - 1, p - s - 1) || d(M + 1, f - 1, p - s + 1) || d(M - 1, f + 1, p + s - 1) || d(M + 1, f + 1, p + s + 1)), g && (this.data[p] = t, u.push(p));
|
|
349
|
+
}
|
|
350
|
+
for (const f of u) i[f] = 1;
|
|
351
|
+
for (let f = 1; f < n && u.length; f++) {
|
|
352
|
+
const M = [];
|
|
353
|
+
for (const p of u) {
|
|
354
|
+
const g = p % s, b = p / s | 0, w = (x, y, A) => {
|
|
355
|
+
x < 0 || y < 0 || x >= s || y >= a || i[A] || (i[A] = 1, this.data[A] = t, M.push(A));
|
|
356
|
+
};
|
|
357
|
+
w(g - 1, b, p - 1), w(g + 1, b, p + 1), w(g, b - 1, p - s), w(g, b + 1, p + s), e && (w(g - 1, b - 1, p - s - 1), w(g + 1, b - 1, p - s + 1), w(g - 1, b + 1, p + s - 1), w(g + 1, b + 1, p + s + 1));
|
|
358
|
+
}
|
|
359
|
+
u = M;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
/** Replaces every pixel whose color matches `from`. */
|
|
363
|
+
recolor(t, e) {
|
|
364
|
+
for (let n = 0; n < this.data.length; n++) this.data[n] === t && (this.data[n] = e);
|
|
365
|
+
}
|
|
366
|
+
/** Multiplies brightness of opaque pixels matching `pred`. */
|
|
367
|
+
tint(t, e) {
|
|
368
|
+
for (let n = 0; n < this.h; n++)
|
|
369
|
+
for (let s = 0; s < this.w; s++) {
|
|
370
|
+
const a = n * this.w + s, i = this.data[a] ?? 0;
|
|
371
|
+
i >>> 24 && e(s, n) && (this.data[a] = $t(i, t));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
blit(t, e, n, s = !1) {
|
|
375
|
+
for (let a = 0; a < t.h; a++)
|
|
376
|
+
for (let i = 0; i < t.w; i++) {
|
|
377
|
+
const r = t.data[a * t.w + i] ?? 0;
|
|
378
|
+
r >>> 24 && this.px(e + (s ? t.w - 1 - i : i), n + a, r);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/** Alpha-blends a color onto an existing pixel. */
|
|
382
|
+
blend(t, e, n) {
|
|
383
|
+
if (!this.inBounds(t, e)) return;
|
|
384
|
+
const s = e * this.w + t, a = this.data[s] ?? 0, [i, r, h, c] = R(n), l = c / 255, d = R(a);
|
|
385
|
+
this.data[s] = L(d[0] + (i - d[0]) * l, d[1] + (r - d[1]) * l, d[2] + (h - d[2]) * l, Math.max(d[3], c));
|
|
386
|
+
}
|
|
387
|
+
/** Reads a canvas back into a grid (a PNG layer of the paper doll joining the painted ones). */
|
|
388
|
+
static from(t) {
|
|
389
|
+
const e = new G(t.width, t.height), n = t.getContext("2d").getImageData(0, 0, t.width, t.height);
|
|
390
|
+
return e.data.set(new Uint32Array(n.data.buffer, n.data.byteOffset, t.width * t.height)), e;
|
|
391
|
+
}
|
|
392
|
+
/** The same picture on a grid `factor` times as fine, each pixel becoming a square block. */
|
|
393
|
+
upscaled(t) {
|
|
394
|
+
if (t === 1) return this;
|
|
395
|
+
const e = new G(this.w * t, this.h * t);
|
|
396
|
+
for (let n = 0; n < this.h; n++)
|
|
397
|
+
for (let s = 0; s < this.w; s++) {
|
|
398
|
+
const a = this.data[n * this.w + s] ?? 0;
|
|
399
|
+
a >>> 24 && e.rect(s * t, n * t, t, t, a);
|
|
400
|
+
}
|
|
401
|
+
return e;
|
|
402
|
+
}
|
|
403
|
+
/** Same size and same pixels. */
|
|
404
|
+
equals(t) {
|
|
405
|
+
if (t.w !== this.w || t.h !== this.h) return !1;
|
|
406
|
+
for (let e = 0; e < this.data.length; e++) if (this.data[e] !== t.data[e]) return !1;
|
|
407
|
+
return !0;
|
|
408
|
+
}
|
|
409
|
+
/** Cheap hash of the pixels, for grouping identical frames before comparing them. */
|
|
410
|
+
key() {
|
|
411
|
+
let t = 2166136261;
|
|
412
|
+
for (let e = 0; e < this.data.length; e++)
|
|
413
|
+
t ^= this.data[e], t = Math.imul(t, 16777619) >>> 0;
|
|
414
|
+
return t >>> 0;
|
|
415
|
+
}
|
|
416
|
+
clone() {
|
|
417
|
+
const t = new G(this.w, this.h);
|
|
418
|
+
return t.data.set(this.data), t;
|
|
419
|
+
}
|
|
420
|
+
toCanvas() {
|
|
421
|
+
const t = document.createElement("canvas");
|
|
422
|
+
t.width = this.w, t.height = this.h;
|
|
423
|
+
const e = t.getContext("2d");
|
|
424
|
+
if (!e) throw new Error("2D canvas not supported");
|
|
425
|
+
const n = new Uint8ClampedArray(this.w * this.h * 4);
|
|
426
|
+
n.set(new Uint8Array(this.data.buffer, this.data.byteOffset, this.data.byteLength));
|
|
427
|
+
const s = new ImageData(n, this.w, this.h);
|
|
428
|
+
return e.putImageData(s, 0, 0), t;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
class gn extends G {
|
|
432
|
+
constructor(t, e, n, s) {
|
|
433
|
+
super(n, s), this.x0 = t, this.y0 = e;
|
|
434
|
+
}
|
|
435
|
+
x0;
|
|
436
|
+
y0;
|
|
437
|
+
inBounds(t, e) {
|
|
438
|
+
return super.inBounds(t - this.x0, e - this.y0);
|
|
439
|
+
}
|
|
440
|
+
px(t, e, n) {
|
|
441
|
+
super.px(Math.floor(t) - this.x0, Math.floor(e) - this.y0, n);
|
|
442
|
+
}
|
|
443
|
+
get(t, e) {
|
|
444
|
+
return super.get(t - this.x0, e - this.y0);
|
|
445
|
+
}
|
|
446
|
+
blend(t, e, n) {
|
|
447
|
+
const s = t - this.x0, a = e - this.y0;
|
|
448
|
+
if (!super.inBounds(s, a)) return;
|
|
449
|
+
const i = a * this.w + s, r = this.data[i] ?? 0, [h, c, l, d] = R(n), u = d / 255, f = R(r);
|
|
450
|
+
this.data[i] = L(f[0] + (h - f[0]) * u, f[1] + (c - f[1]) * u, f[2] + (l - f[2]) * u, Math.max(f[3], d));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function mn(o, t = 16384) {
|
|
454
|
+
const e = o[0];
|
|
455
|
+
if (!e) throw new Error("makeSheet: no frames");
|
|
456
|
+
const n = Math.max(1, Math.min(o.length, Math.floor(t / e.w))), s = Math.ceil(o.length / n), a = new G(e.w * n, e.h * s);
|
|
457
|
+
return o.forEach((i, r) => a.blit(i, r % n * e.w, Math.floor(r / n) * e.h)), a.toCanvas();
|
|
458
|
+
}
|
|
459
|
+
function wn(o, t) {
|
|
460
|
+
const e = document.createElement("canvas");
|
|
461
|
+
e.width = o.width * t, e.height = o.height * t;
|
|
462
|
+
const n = e.getContext("2d");
|
|
463
|
+
if (!n) throw new Error("2D canvas not supported");
|
|
464
|
+
return n.imageSmoothingEnabled = !1, n.drawImage(o, 0, 0, e.width, e.height), e;
|
|
465
|
+
}
|
|
466
|
+
const Ft = {
|
|
467
|
+
outline: m("#1a1220"),
|
|
468
|
+
outlineSoft: m("#2e2233"),
|
|
469
|
+
black: m("#0e0b12"),
|
|
470
|
+
white: m("#f4f0e8"),
|
|
471
|
+
offWhite: m("#e2dccf"),
|
|
472
|
+
skin: m("#f2c59a"),
|
|
473
|
+
skinShade: m("#d99d74"),
|
|
474
|
+
skinTan: m("#cf9468"),
|
|
475
|
+
skinTanShade: m("#a86c48"),
|
|
476
|
+
blush: m("#e88c80"),
|
|
477
|
+
hairBlack: m("#2a2230"),
|
|
478
|
+
hairBrown: m("#5b3a29"),
|
|
479
|
+
hairAuburn: m("#7a3b2a"),
|
|
480
|
+
hairWhite: m("#e8e4dc"),
|
|
481
|
+
hairGrey: m("#9a96a0"),
|
|
482
|
+
red: m("#c8373a"),
|
|
483
|
+
redDark: m("#8e2331"),
|
|
484
|
+
crimson: m("#a3243b"),
|
|
485
|
+
orange: m("#e07a36"),
|
|
486
|
+
gold: m("#f2c84b"),
|
|
487
|
+
goldDark: m("#b88a2a"),
|
|
488
|
+
yellow: m("#f5e06a"),
|
|
489
|
+
green: m("#5aa04a"),
|
|
490
|
+
greenDark: m("#2f6b3a"),
|
|
491
|
+
jade: m("#4fbf8f"),
|
|
492
|
+
jadeDark: m("#2d8466"),
|
|
493
|
+
teal: m("#3aa6a0"),
|
|
494
|
+
sky: m("#7ec4f0"),
|
|
495
|
+
azure: m("#4a8ad4"),
|
|
496
|
+
blue: m("#3560b0"),
|
|
497
|
+
navy: m("#27335e"),
|
|
498
|
+
indigo: m("#3b2f6e"),
|
|
499
|
+
purple: m("#7a4bb0"),
|
|
500
|
+
pink: m("#e89aaa"),
|
|
501
|
+
brown: m("#7a5234"),
|
|
502
|
+
brownDark: m("#4e3222"),
|
|
503
|
+
brownLight: m("#a6784a"),
|
|
504
|
+
tan: m("#c9a26e"),
|
|
505
|
+
cream: m("#efe2c0"),
|
|
506
|
+
grey: m("#8a8690"),
|
|
507
|
+
greyDark: m("#57535e"),
|
|
508
|
+
greyLight: m("#bdb9c2"),
|
|
509
|
+
steel: m("#c8d2dc"),
|
|
510
|
+
steelDark: m("#7f8a98"),
|
|
511
|
+
iron: m("#9aa0a8"),
|
|
512
|
+
wood: m("#9a6a3c"),
|
|
513
|
+
woodDark: m("#6a4426"),
|
|
514
|
+
woodLight: m("#bd8c56"),
|
|
515
|
+
straw: m("#d8b060"),
|
|
516
|
+
strawDark: m("#a8823e")
|
|
517
|
+
}, xn = ["cloth", "leather", "mail", "plate", "dragon", "fur", "skin", "hair", "gold", "gem", "shadow"], xe = {
|
|
518
|
+
// wool and linen: violet shadows, faintly warm lights
|
|
519
|
+
cloth: { cool: 255, coolDeg: 14, coolSat: 0.06, warm: 50, warmDeg: 6 },
|
|
520
|
+
// hide: its shadows go red-brown, never grey
|
|
521
|
+
leather: { cool: 8, coolDeg: 12, coolSat: 0.08, warm: 45, warmDeg: 8 },
|
|
522
|
+
// steel: blue shadows, lights close to white
|
|
523
|
+
mail: { cool: 232, coolDeg: 16, coolSat: 0.07, warm: 52, warmDeg: 4 },
|
|
524
|
+
plate: { cool: 235, coolDeg: 18, coolSat: 0.08, warm: 50, warmDeg: 6 },
|
|
525
|
+
// scale: crimson-violet shadows, ember-orange lights
|
|
526
|
+
dragon: { cool: 330, coolDeg: 16, coolSat: 0.06, warm: 36, warmDeg: 12 },
|
|
527
|
+
fur: { cool: 262, coolDeg: 10, coolSat: 0.04, warm: 48, warmDeg: 6 },
|
|
528
|
+
// skin: shadows go to blood-red, never to grey or green
|
|
529
|
+
skin: { cool: 350, coolDeg: 14, coolSat: 0.09, warm: 42, warmDeg: 5 },
|
|
530
|
+
hair: { cool: 262, coolDeg: 14, coolSat: 0.05, warm: 46, warmDeg: 10 },
|
|
531
|
+
gold: { cool: 14, coolDeg: 14, coolSat: 0.05, warm: 58, warmDeg: 8 },
|
|
532
|
+
gem: { cool: 262, coolDeg: 8, coolSat: 0.02, warm: 50, warmDeg: 2 },
|
|
533
|
+
// the side turned away from the light, whatever it is made of (the far limbs)
|
|
534
|
+
shadow: { cool: 255, coolDeg: 12, coolSat: 0.04, warm: 50, warmDeg: 0 }
|
|
535
|
+
}, Ot = {
|
|
536
|
+
cloth: [0.5, 0.66, 0.82, 1.12, 1.25],
|
|
537
|
+
leather: [0.46, 0.62, 0.8, 1.16, 1.3],
|
|
538
|
+
mail: [0.44, 0.6, 0.78, 1.22, 1.42],
|
|
539
|
+
plate: [0.44, 0.56, 0.72, 1.2, 1.45],
|
|
540
|
+
dragon: [0.42, 0.56, 0.74, 1.14, 1.32],
|
|
541
|
+
fur: [0.56, 0.7, 0.84, 1.15, 1.26],
|
|
542
|
+
skin: [0.6, 0.72, 0.86, 1.12, 1.24],
|
|
543
|
+
hair: [0.5, 0.66, 0.8, 1.2, 1.36],
|
|
544
|
+
gold: [0.42, 0.62, 0.8, 1.3, 1.5],
|
|
545
|
+
gem: [0.32, 0.5, 0.78, 1.45, 1.65],
|
|
546
|
+
shadow: [0.5, 0.66, 0.82, 1.12, 1.25]
|
|
547
|
+
};
|
|
548
|
+
[...new Set(Object.values(Ot).flat())];
|
|
549
|
+
function dt(o) {
|
|
550
|
+
const [t, e, n] = R(o), s = Math.max(t, e, n), a = Math.min(t, e, n), i = s - a;
|
|
551
|
+
let r = 0;
|
|
552
|
+
return i > 0 && (s === t ? r = ((e - n) / i + 6) % 6 : s === e ? r = (n - t) / i + 2 : r = (t - e) / i + 4), [r * 60, s === 0 ? 0 : i / s, s / 255];
|
|
553
|
+
}
|
|
554
|
+
function j(o, t, e, n) {
|
|
555
|
+
const s = (o % 360 + 360) % 360 / 60, a = Math.floor(s), i = s - a, r = e * (1 - t), h = e * (1 - t * i), c = e * (1 - t * (1 - i)), [l, d, u] = [[e, c, r], [h, e, r], [r, e, c], [r, h, e], [c, r, e], [e, r, h]][a % 6];
|
|
556
|
+
return L(l * 255, d * 255, u * 255, n);
|
|
557
|
+
}
|
|
558
|
+
function At(o, t, e) {
|
|
559
|
+
let n = t - o;
|
|
560
|
+
return n > 180 && (n -= 360), n < -180 && (n += 360), o + Math.sign(n) * Math.min(Math.abs(n), e);
|
|
561
|
+
}
|
|
562
|
+
const U = (o) => Math.max(0, Math.min(1, o)), St = /* @__PURE__ */ new Map();
|
|
563
|
+
function pt(o, t, e) {
|
|
564
|
+
if (t === 1) return o;
|
|
565
|
+
const n = `${o}:${t}:${e}`;
|
|
566
|
+
let s = St.get(n);
|
|
567
|
+
if (s !== void 0) return s;
|
|
568
|
+
const a = xe[e], i = $t(o, t), [r, h, c] = dt(i), l = i >>> 24, d = U(1 - dt(o)[1] / 0.14);
|
|
569
|
+
let u, f;
|
|
570
|
+
if (t < 1) {
|
|
571
|
+
const M = (1 - t) / 0.5;
|
|
572
|
+
u = j(At(r, a.cool, a.coolDeg * M), U(h + a.coolSat * M), c, l), f = j(a.cool, U(h + a.coolSat * M * 1.2), c, l);
|
|
573
|
+
} else {
|
|
574
|
+
const M = Math.min(1.5, (t - 1) / 0.3);
|
|
575
|
+
u = j(At(r, a.warm, a.warmDeg * M), U(h * 1.08), c, l), f = j(a.warm, U(h + 0.03 * M), c, l);
|
|
576
|
+
}
|
|
577
|
+
return s = d > 0 ? we(u, f, d) : u, St.set(n, s), s;
|
|
578
|
+
}
|
|
579
|
+
const kt = /* @__PURE__ */ new Map();
|
|
580
|
+
function ye(o, t) {
|
|
581
|
+
const e = `${o}:${t}`;
|
|
582
|
+
let n = kt.get(e);
|
|
583
|
+
if (!n) {
|
|
584
|
+
const [s, a, i, r, h] = Ot[t].map((c) => pt(o, c, t));
|
|
585
|
+
n = { deep: s, dark: a, mid: i, base: o, light: r, glint: h }, kt.set(e, n);
|
|
586
|
+
}
|
|
587
|
+
return n;
|
|
588
|
+
}
|
|
589
|
+
function yn(o, t) {
|
|
590
|
+
const e = ye(o, t);
|
|
591
|
+
return [e.deep, e.dark, e.mid, e.base, e.light, e.glint];
|
|
592
|
+
}
|
|
593
|
+
const vt = /* @__PURE__ */ new Map();
|
|
594
|
+
function Wt(o) {
|
|
595
|
+
let t = vt.get(o);
|
|
596
|
+
if (t === void 0) {
|
|
597
|
+
const [e, n, s] = dt(pt(o, 0.42, "shadow"));
|
|
598
|
+
t = j(e, U(n * 1.1 + 0.08), Math.min(s, 0.3), 255), vt.set(o, t);
|
|
599
|
+
}
|
|
600
|
+
return t;
|
|
601
|
+
}
|
|
602
|
+
function bn(o, t, e) {
|
|
603
|
+
return { canvas: o.toCanvas(), anchorX: t, anchorY: e };
|
|
604
|
+
}
|
|
605
|
+
function An(o, t = Ft.outline) {
|
|
606
|
+
const { w: e, h: n } = o, s = new Uint8Array(e * n);
|
|
607
|
+
for (let i = 0; i < e * n; i++) s[i] = o.data[i] >>> 24 === 255 ? 1 : 0;
|
|
608
|
+
const a = (i, r) => i >= 0 && r >= 0 && i < e && r < n && s[r * e + i] === 1;
|
|
609
|
+
for (let i = 0; i < n; i++)
|
|
610
|
+
for (let r = 0; r < e; r++) {
|
|
611
|
+
if (s[i * e + r]) continue;
|
|
612
|
+
const h = a(r, i - 1), c = a(r - 1, i), l = a(r + 1, i), d = a(r, i + 1);
|
|
613
|
+
(h || c || l || d) && o.px(r, i, h || c ? t : Wt(o.get(l ? r + 1 : r, l ? i : i + 1)));
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
function Sn(o, t, e, n, s) {
|
|
617
|
+
for (let a = Math.floor(e - s); a <= Math.ceil(e + s); a++)
|
|
618
|
+
for (let i = Math.floor(t - n); i <= Math.ceil(t + n); i++) {
|
|
619
|
+
if (!o.inBounds(i, a) || o.alphaAt(i, a)) continue;
|
|
620
|
+
const r = (i + 0.5 - t) / n, h = (a + 0.5 - e) / s, c = r * r + h * h;
|
|
621
|
+
c <= 0.55 ? o.px(i, a, be) : c <= 1 && o.px(i, a, Ae);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
const be = L(26, 22, 44, 78), Ae = L(26, 22, 44, 40);
|
|
625
|
+
function kn(o, t, e, n, s, a, i) {
|
|
626
|
+
for (let r = e; r < e + s; r++)
|
|
627
|
+
for (let h = t; h < t + n; h++) {
|
|
628
|
+
if (!o.inBounds(h, r)) continue;
|
|
629
|
+
const c = o.get(h, r);
|
|
630
|
+
!(c >>> 24) || i && !i(h, r) || o.px(h, r, pt(c, a, "shadow"));
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
function vn(o, t = 1) {
|
|
634
|
+
const { w: e, h: n, data: s } = o, a = new Uint8Array(s.length);
|
|
635
|
+
let i = e, r = n, h = -1, c = -1;
|
|
636
|
+
for (let d = 0; d < n; d++) {
|
|
637
|
+
const u = d * e;
|
|
638
|
+
for (let f = 0; f < e; f++)
|
|
639
|
+
s[u + f] >>> 24 && (a[u + f] = 1, f < i && (i = f), f > h && (h = f), d < r && (r = d), c = d);
|
|
640
|
+
}
|
|
641
|
+
if (h < 0) return;
|
|
642
|
+
let l = [];
|
|
643
|
+
for (let d = Math.max(0, r - 1); d <= Math.min(n - 1, c + 1); d++)
|
|
644
|
+
for (let u = Math.max(0, i - 1); u <= Math.min(e - 1, h + 1); u++) {
|
|
645
|
+
const f = d * e + u;
|
|
646
|
+
if (a[f]) continue;
|
|
647
|
+
const M = d > 0 && a[f - e] === 1, p = u + 1 < e && a[f + 1] === 1, g = u > 0 && a[f - 1] === 1, b = d + 1 < n && a[f + e] === 1;
|
|
648
|
+
(M || p || g || b) && (s[f] = M || p ? Ft.outline : Wt(s[g ? f - 1 : f + e]), l.push(f));
|
|
649
|
+
}
|
|
650
|
+
for (const d of l) a[d] = 1;
|
|
651
|
+
for (let d = 1; d < t && l.length; d++) {
|
|
652
|
+
const u = [];
|
|
653
|
+
for (const f of l) {
|
|
654
|
+
const M = f % e, p = f / e | 0, g = s[f], b = (w, x) => {
|
|
655
|
+
!w || a[x] || (a[x] = 1, s[x] = g, u.push(x));
|
|
656
|
+
};
|
|
657
|
+
b(M > 0, f - 1), b(M + 1 < e, f + 1), b(p > 0, f - e), b(p + 1 < n, f + e);
|
|
658
|
+
}
|
|
659
|
+
l = u;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
const Dt = /* @__PURE__ */ new Map();
|
|
663
|
+
function Yt(o) {
|
|
664
|
+
const t = (o >> 16 & 255) / 255, e = (o >> 8 & 255) / 255, n = (o & 255) / 255, s = Math.max(t, e, n), a = Math.min(t, e, n), i = (s + a) / 2;
|
|
665
|
+
if (s === a) return [0, 0, i];
|
|
666
|
+
const r = s - a, h = i > 0.5 ? r / (2 - s - a) : r / (s + a);
|
|
667
|
+
return [(s === t ? (e - n) / r + (e < n ? 6 : 0) : s === e ? (n - t) / r + 2 : (t - e) / r + 4) / 6, h, i];
|
|
668
|
+
}
|
|
669
|
+
function z(o, t, e) {
|
|
670
|
+
const n = (r, h, c) => {
|
|
671
|
+
const l = (c + 1) % 1;
|
|
672
|
+
return l < 0.16666666666666666 ? r + (h - r) * 6 * l : l < 0.5 ? h : l < 0.6666666666666666 ? r + (h - r) * (0.6666666666666666 - l) * 6 : r;
|
|
673
|
+
}, s = e < 0.5 ? e * (1 + t) : e + t - e * t, a = 2 * e - s, i = (r) => Math.round(Math.max(0, Math.min(1, t === 0 ? e : n(a, s, r))) * 255);
|
|
674
|
+
return i(o + 1 / 3) << 16 | i(o) << 8 | i(o - 1 / 3);
|
|
675
|
+
}
|
|
676
|
+
function st(o, t, e) {
|
|
677
|
+
let n = t - o;
|
|
678
|
+
return n > 0.5 && (n -= 1), n < -0.5 && (n += 1), (o + Math.sign(n) * Math.min(Math.abs(n), e) + 1) % 1;
|
|
679
|
+
}
|
|
680
|
+
const Se = /* @__PURE__ */ new Map([
|
|
681
|
+
// arcane violet
|
|
682
|
+
[13148415, { hi: 16511231, light: 15126012, deep: 8672968, shade: 4072550 }],
|
|
683
|
+
// straw and bone (the hunters' arrows)
|
|
684
|
+
[15259808, { hi: 16776168, light: 16182468, deep: 11573858, shade: 5917232 }],
|
|
685
|
+
// dusk violet
|
|
686
|
+
[11563263, { hi: 16049919, light: 13938943, deep: 7356600, shade: 3152474 }],
|
|
687
|
+
// cold sky steel
|
|
688
|
+
[10479359, { hi: 16055551, light: 13694207, deep: 5937864, shade: 2375274 }],
|
|
689
|
+
// bright steel
|
|
690
|
+
[14737648, { hi: 16777215, light: 15921914, deep: 10132662, shade: 4868708 }],
|
|
691
|
+
// wind over grass
|
|
692
|
+
[11071680, { hi: 15794164, light: 13957856, deep: 6205576, shade: 2382406 }],
|
|
693
|
+
// holy gold
|
|
694
|
+
[16767370, { hi: 16776166, light: 16772280, deep: 13145662, shade: 6964260 }],
|
|
695
|
+
// judgement gold
|
|
696
|
+
[16769162, { hi: 16776162, light: 16773308, deep: 13672516, shade: 7359010 }],
|
|
697
|
+
// trap amber
|
|
698
|
+
[16760896, { hi: 16774352, light: 16769168, deep: 12614176, shade: 6961686 }],
|
|
699
|
+
// hunter's gold
|
|
700
|
+
[13676656, { hi: 16774876, light: 15521440, deep: 9334848, shade: 4864548 }],
|
|
701
|
+
// war-cry amber
|
|
702
|
+
[16757051, { hi: 16773324, light: 16766088, deep: 12611614, shade: 6829076 }],
|
|
703
|
+
// moonlit silver-blue
|
|
704
|
+
[10531071, { hi: 15922431, light: 13687039, deep: 6187720, shade: 2764394 }],
|
|
705
|
+
// blood
|
|
706
|
+
[16730682, { hi: 16769236, light: 16751238, deep: 11017762, shade: 5114902 }],
|
|
707
|
+
// pale violet steel
|
|
708
|
+
[14733567, { hi: 16512767, light: 15788287, deep: 10127048, shade: 4864622 }]
|
|
709
|
+
]), ke = new Map([...Se].map(([o, t]) => [o, { ...t, base: o }]));
|
|
710
|
+
function P(o) {
|
|
711
|
+
return ke.get(o) ?? Bt(o);
|
|
712
|
+
}
|
|
713
|
+
function Bt(o) {
|
|
714
|
+
let t = Dt.get(o);
|
|
715
|
+
if (t) return t;
|
|
716
|
+
const [e, n, s] = Yt(o), a = st(e, 0.72, 0.06), i = st(e, 0.14, 0.04);
|
|
717
|
+
return t = {
|
|
718
|
+
shade: z(a, Math.min(1, n * 0.85), Math.max(0.08, s * 0.38)),
|
|
719
|
+
deep: z(st(e, 0.72, 0.03), n, Math.max(0.14, s * 0.66)),
|
|
720
|
+
base: o,
|
|
721
|
+
light: z(i, n * 0.9, Math.min(0.9, s + (1 - s) * 0.45)),
|
|
722
|
+
hi: z(i, n * 0.5, Math.min(0.97, s + (1 - s) * 0.8))
|
|
723
|
+
}, Dt.set(o, t), t;
|
|
724
|
+
}
|
|
725
|
+
const Et = /* @__PURE__ */ new Map();
|
|
726
|
+
function $(o) {
|
|
727
|
+
let t = Et.get(o);
|
|
728
|
+
if (t !== void 0) return t;
|
|
729
|
+
const [e, n, s] = Yt(o), a = s > 0.82 ? 0.82 + (s - 0.82) * 0.55 : s;
|
|
730
|
+
return t = z(s > 0.82 ? st(e, 0.12, 0.05) : e, n * (s > 0.82 ? 0.55 : 0.74), a * 0.97), Et.set(o, t), t;
|
|
731
|
+
}
|
|
732
|
+
let Q = null;
|
|
733
|
+
const rt = (o, t) => o + 32768 << 16 | t + 32768 & 65535;
|
|
734
|
+
function ht() {
|
|
735
|
+
return Q;
|
|
736
|
+
}
|
|
737
|
+
const It = [1, 0, -1, 0, 0, 1, 0, -1];
|
|
738
|
+
function Xt() {
|
|
739
|
+
Q = /* @__PURE__ */ new Map();
|
|
740
|
+
}
|
|
741
|
+
function Nt(o, t) {
|
|
742
|
+
const e = Q;
|
|
743
|
+
if (Q = null, !e) return;
|
|
744
|
+
const n = /* @__PURE__ */ new Set();
|
|
745
|
+
for (const a of e.keys()) {
|
|
746
|
+
const i = (a >>> 16) - 32768, r = (a & 65535) - 32768;
|
|
747
|
+
for (let h = 0; h < 8; h += 2) {
|
|
748
|
+
const c = rt(i + It[h], r + It[h + 1]);
|
|
749
|
+
e.has(c) || n.add(c);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
const s = $(t);
|
|
753
|
+
it(o, new Map([...n].map((a) => [a, s]))), it(o, e);
|
|
754
|
+
}
|
|
755
|
+
function it(o, t) {
|
|
756
|
+
if (T !== null && o === T) {
|
|
757
|
+
if (_) for (const [e, n] of t) _.stage((e >>> 16) - 32768, (e & 65535) - 32768, 1, n);
|
|
758
|
+
else for (const [e, n] of t) I.set(e, n);
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
Gt(o, t);
|
|
762
|
+
}
|
|
763
|
+
let I = null, _ = null, T = null;
|
|
764
|
+
const Ut = [];
|
|
765
|
+
function ve(o) {
|
|
766
|
+
Ut.push({ batch: I, direct: _, g: T }), o instanceof J ? (I = null, _ = o) : (I = /* @__PURE__ */ new Map(), _ = null), T = o;
|
|
767
|
+
}
|
|
768
|
+
function De() {
|
|
769
|
+
mt();
|
|
770
|
+
const o = Ut.pop();
|
|
771
|
+
I = o?.batch ?? null, _ = o?.direct ?? null, T = o?.g ?? null;
|
|
772
|
+
}
|
|
773
|
+
function ct(o) {
|
|
774
|
+
return T === null || o !== T ? null : _ ?? I;
|
|
775
|
+
}
|
|
776
|
+
function gt(o, t, e, n, s) {
|
|
777
|
+
if (o instanceof J) {
|
|
778
|
+
o.stage(t, e, n, s);
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
for (let a = 0; a < n; a++) o.set(rt(t + a, e), s);
|
|
782
|
+
}
|
|
783
|
+
function mt() {
|
|
784
|
+
if (_) {
|
|
785
|
+
_.commit();
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
if (!I || !T || I.size === 0) return;
|
|
789
|
+
const o = I;
|
|
790
|
+
I = /* @__PURE__ */ new Map(), Gt(T, o);
|
|
791
|
+
}
|
|
792
|
+
function Gt(o, t) {
|
|
793
|
+
if (o instanceof J) {
|
|
794
|
+
for (const [r, h] of t) o.stage((r >>> 16) - 32768, (r & 65535) - 32768, 1, h);
|
|
795
|
+
o.commit();
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
const e = [...t.keys()].sort((r, h) => (r & 65535) - (h & 65535) || (r >>> 16) - (h >>> 16));
|
|
799
|
+
let n = 0, s = 0, a = 0, i = -1;
|
|
800
|
+
for (const r of e) {
|
|
801
|
+
const h = (r >>> 16) - 32768, c = (r & 65535) - 32768, l = t.get(r);
|
|
802
|
+
if (a > 0 && c === s && h === n + a && l === i) {
|
|
803
|
+
a++;
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
a > 0 && o.fillStyle(i, 1).fillRect(n, s, a, 1), n = h, s = c, a = 1, i = l;
|
|
807
|
+
}
|
|
808
|
+
a > 0 && o.fillStyle(i, 1).fillRect(n, s, a, 1);
|
|
809
|
+
}
|
|
810
|
+
function Kt(o, t) {
|
|
811
|
+
return rt(o, t);
|
|
812
|
+
}
|
|
813
|
+
function jt(o, t, e) {
|
|
814
|
+
Q?.set(rt(o, t), e);
|
|
815
|
+
}
|
|
816
|
+
const Ee = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5];
|
|
817
|
+
let at = 1;
|
|
818
|
+
function Ie(o) {
|
|
819
|
+
at = o;
|
|
820
|
+
}
|
|
821
|
+
function zt() {
|
|
822
|
+
return at;
|
|
823
|
+
}
|
|
824
|
+
function C(o, t) {
|
|
825
|
+
if (at >= 1) return !1;
|
|
826
|
+
const e = (Math.round(o) & 3) >>> 0, n = (Math.round(t) & 3) >>> 0;
|
|
827
|
+
return Ee[n * 4 + e] / 16 >= at;
|
|
828
|
+
}
|
|
829
|
+
const Dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
830
|
+
__proto__: null,
|
|
831
|
+
batchFor: ct,
|
|
832
|
+
beginBatch: ve,
|
|
833
|
+
beginOutline: Xt,
|
|
834
|
+
capturing: ht,
|
|
835
|
+
currentCoverage: zt,
|
|
836
|
+
derivedRamp: Bt,
|
|
837
|
+
dithered: C,
|
|
838
|
+
endBatch: De,
|
|
839
|
+
endOutline: Nt,
|
|
840
|
+
fillRuns: it,
|
|
841
|
+
flushBatch: mt,
|
|
842
|
+
grade: $,
|
|
843
|
+
pixelKey: Kt,
|
|
844
|
+
ramp: P,
|
|
845
|
+
record: jt,
|
|
846
|
+
setCoverage: Ie,
|
|
847
|
+
stageRun: gt
|
|
848
|
+
}, Symbol.toStringTag, { value: "Module" })), qt = 16774358, v = (o) => Math.round(o);
|
|
849
|
+
function E(o, t, e, n, s = 1) {
|
|
850
|
+
const a = v(t), i = v(e);
|
|
851
|
+
if (C(a, i)) return;
|
|
852
|
+
const r = $(n);
|
|
853
|
+
if (ht()) {
|
|
854
|
+
for (let c = 0; c < s; c++) for (let l = 0; l < s; l++) jt(a + l, i + c, r);
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
const h = ct(o);
|
|
858
|
+
if (h) {
|
|
859
|
+
for (let c = 0; c < s; c++) gt(h, a, i + c, s, r);
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
o.fillStyle(r, 1).fillRect(a, i, s, s);
|
|
863
|
+
}
|
|
864
|
+
class Vt {
|
|
865
|
+
at = /* @__PURE__ */ new Map();
|
|
866
|
+
set(t, e, n) {
|
|
867
|
+
this.at.set(Kt(v(t), v(e)), n);
|
|
868
|
+
}
|
|
869
|
+
lay(t) {
|
|
870
|
+
if (ht()) {
|
|
871
|
+
for (const [s, a] of this.at) E(t, (s >>> 16) - 32768, (s & 65535) - 32768, a);
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
const e = ct(t);
|
|
875
|
+
if (e instanceof J) {
|
|
876
|
+
for (const [s, a] of this.at) {
|
|
877
|
+
const i = (s >>> 16) - 32768, r = (s & 65535) - 32768;
|
|
878
|
+
C(i, r) || e.stage(i, r, 1, $(a));
|
|
879
|
+
}
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
const n = /* @__PURE__ */ new Map();
|
|
883
|
+
for (const [s, a] of this.at) C((s >>> 16) - 32768, (s & 65535) - 32768) || n.set(s, $(a));
|
|
884
|
+
it(t, n);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
function O(o, t, e, n, s) {
|
|
888
|
+
const a = v(t), i = v(n);
|
|
889
|
+
if (!(i <= 0)) {
|
|
890
|
+
if (!ht() && !C(a, e) && !C(a + 1, e) && !C(a + 2, e + 1) && !C(a + 3, e + 1)) {
|
|
891
|
+
const r = ct(o);
|
|
892
|
+
if (r) {
|
|
893
|
+
gt(r, a, v(e), i, $(s));
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
o.fillStyle($(s), 1).fillRect(a, v(e), i, 1);
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
for (let r = 0; r < i; r++) E(o, a + r, e, s);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
function Le(o, t, e) {
|
|
903
|
+
Xt();
|
|
904
|
+
try {
|
|
905
|
+
e();
|
|
906
|
+
} finally {
|
|
907
|
+
Nt(o, t);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
function Z(o, t, e, n, s = 2) {
|
|
911
|
+
const a = Math.hypot(e.x - t.x, e.y - t.y), i = Math.max(1, Math.ceil(a)), r = a ? -(e.y - t.y) / a : 0, h = a ? (e.x - t.x) / a : 1, c = P(n), l = Math.max(1, Math.round(s));
|
|
912
|
+
for (let d = 0; d <= i; d++) {
|
|
913
|
+
const u = i >= 10 && (d <= 1 || d >= i - 1), f = i >= 16 && Math.abs(d - Math.round(i / 3)) <= 1, M = t.x + (e.x - t.x) * d / i, p = t.y + (e.y - t.y) * d / i;
|
|
914
|
+
for (let g = 0; g < l; g++) {
|
|
915
|
+
const b = g - (l - 1) / 2, w = l >= 2 ? g === 0 ? c.light : g === l - 1 ? c.deep : n : n;
|
|
916
|
+
E(o, M + r * b, p + h * b, u ? c.deep : f && g === 0 ? c.hi : w);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
function Re(o, t, e, n = 0, s = 0) {
|
|
921
|
+
const a = P(e), i = Math.max(32, Math.ceil(t * 5)), r = new Vt();
|
|
922
|
+
for (let h = 0; h < i; h++) {
|
|
923
|
+
const c = ((h * 64 / i + n) % 16 + 16) % 16;
|
|
924
|
+
if (c < 3) continue;
|
|
925
|
+
const l = h * Math.PI * 2 / i, d = Math.sin(l), u = c < 4 ? a.hi : d > 0.35 ? a.light : d < -0.35 ? a.deep : e, f = Math.cos(l) * t, M = s + d * t * 0.5;
|
|
926
|
+
r.set(f, M, u), d > 0.5 && r.set(f, M + 1, a.deep);
|
|
927
|
+
}
|
|
928
|
+
r.lay(o);
|
|
929
|
+
}
|
|
930
|
+
function Pe(o, t, e, n, s) {
|
|
931
|
+
const a = P(s);
|
|
932
|
+
for (let i = -n; i <= n; i++) {
|
|
933
|
+
const r = Math.max(1, v(n - Math.abs(i))), h = v(t - r / 2);
|
|
934
|
+
if (i > n * 0.45) {
|
|
935
|
+
O(o, h, e + i, r, a.deep);
|
|
936
|
+
continue;
|
|
937
|
+
}
|
|
938
|
+
const c = Math.floor(r / 2);
|
|
939
|
+
n < 3 || c < 1 ? O(o, h, e + i, r, s) : (O(o, h, e + i, c, a.light), O(o, h + c, e + i, r - c, s));
|
|
940
|
+
}
|
|
941
|
+
n >= 5 && E(o, t - 1, e - n + 2, a.hi);
|
|
942
|
+
}
|
|
943
|
+
function _e(o, t, e, n, s = !1) {
|
|
944
|
+
for (let a = 0; a < 12; a++) {
|
|
945
|
+
const i = a * Math.PI / 6 + (s ? t * 1.8 : 0), r = e * (s ? 1 - t : t);
|
|
946
|
+
E(o, Math.cos(i) * r, -8 + Math.sin(i) * r * 0.6 - (s ? 0 : Math.sin(t * Math.PI) * 8), a % 3 ? n : qt, a % 3 ? 1 : 2);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
function Qt(o, t, e, n, s, a = !1) {
|
|
950
|
+
const i = Math.max(1, Math.round(a ? n * 0.5 : n)), r = P(s);
|
|
951
|
+
for (let h = -i; h <= i; h++) {
|
|
952
|
+
const c = v(n * Math.sqrt(Math.max(0, 1 - (h / i) ** 2)));
|
|
953
|
+
if (c <= 0) continue;
|
|
954
|
+
const l = (h + i) / (2 * i || 1);
|
|
955
|
+
O(o, t - c, e + h, c * 2, l > 0.7 && n >= 3 ? r.deep : s), n >= 3 && l < 0.35 && c >= 2 && O(o, t - c + 1, e + h, v(c * 0.6), r.light);
|
|
956
|
+
}
|
|
957
|
+
n >= 4 && E(o, t - n * 0.4, e - i * 0.55, r.hi);
|
|
958
|
+
}
|
|
959
|
+
function Zt(o, t, e, n, s, a = t + 8) {
|
|
960
|
+
const i = s / 1e3, r = t + n * i + 260 * i * i;
|
|
961
|
+
return r > a && n * i + 260 * i * i > 0 ? null : { x: o + e * i, y: r };
|
|
962
|
+
}
|
|
963
|
+
function Te(o, t, e, n, s) {
|
|
964
|
+
Z(o, { x: t - n, y: e - n }, { x: t + n, y: e + n }, s), Z(o, { x: t - n, y: e + n }, { x: t + n, y: e - n }, s);
|
|
965
|
+
}
|
|
966
|
+
function He(o, t, e, n, s, a) {
|
|
967
|
+
const i = { x: t.x + (e.x - t.x) * n, y: t.y + (e.y - t.y) * n };
|
|
968
|
+
Z(o, i, e, s, 4), Z(o, i, e, a, 2);
|
|
969
|
+
}
|
|
970
|
+
function Ce(o, t, e, n, s, a, i = 0, r = 0.7) {
|
|
971
|
+
if (n = Math.round(n), n < 2) return;
|
|
972
|
+
const h = P(s), c = Math.max(2, Math.round(n * 0.85)), l = r * zt();
|
|
973
|
+
mt();
|
|
974
|
+
const d = v(t);
|
|
975
|
+
for (let u = -c; u <= c; u++) {
|
|
976
|
+
const f = n * Math.sqrt(Math.max(0, 1 - (u / (c + 0.5)) ** 2));
|
|
977
|
+
let M = 0, p = 0, g = -1, b = 0;
|
|
978
|
+
const w = Math.ceil(f);
|
|
979
|
+
for (let x = -w; x <= w; x++) {
|
|
980
|
+
let y = -1, A = 0;
|
|
981
|
+
if (x < w) {
|
|
982
|
+
const S = f - Math.abs(x + 0.5), B = (x * 73856093 ^ u * 19349663 ^ i * 83492791) >>> 0;
|
|
983
|
+
S < 1 && B % 2 === 0 || (y = u < -c * 0.3 && x < f * 0.2 ? a : u > c * 0.4 ? h.deep : B % 9 === 0 ? h.light : s, A = S < 1 ? l * 0.6 : l);
|
|
984
|
+
}
|
|
985
|
+
if (y === g && A === b && y !== -1) {
|
|
986
|
+
p++;
|
|
987
|
+
continue;
|
|
988
|
+
}
|
|
989
|
+
g !== -1 && o.fillStyle($(g), b).fillRect(d + M, v(e + u), p, 1), M = x, p = 1, g = y, b = A;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
function $e(o, t, e, n, s, a, i, r = !0, h = 1) {
|
|
994
|
+
const c = Math.max(2, Math.ceil(Math.abs(a - s) * n)), l = P(i);
|
|
995
|
+
h *= 2;
|
|
996
|
+
const d = new Vt();
|
|
997
|
+
for (let u = 0; u < h; u++) {
|
|
998
|
+
const f = n - u, M = u === 0 ? l.light : u === h - 1 ? l.deep : i;
|
|
999
|
+
for (let p = 0; p <= c; p++) {
|
|
1000
|
+
const g = s + (a - s) * p / c, b = p >= c - 1 ? l.hi : h <= 2 && c >= 12 && p < c * 0.2 ? l.deep : M;
|
|
1001
|
+
d.set(t + Math.cos(g) * f, e + Math.sin(g) * f * (r ? 0.5 : 1), b);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
d.lay(o);
|
|
1005
|
+
}
|
|
1006
|
+
function Fe(o, t, e, n, s = 10, a = 13154458) {
|
|
1007
|
+
for (let i = 0; i < 4; i++) {
|
|
1008
|
+
const r = i * 1.7 + 0.3, h = Math.round(4 * (1 - n));
|
|
1009
|
+
h >= 1 && Qt(o, t + Math.cos(r) * s * n, e - 2 + Math.sin(r) * s * 0.4 * n - n * 4, h, i % 2 ? a : 14734524);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
function Oe(o, t, e, n, s, a, i) {
|
|
1013
|
+
for (let r = 0; r < n; r++) {
|
|
1014
|
+
const h = r / n * Math.PI * 2 + 0.3, c = s * (0.6 + r * 7 % 5 * 0.1), l = Zt(t, e, Math.cos(h) * c, -70 - r * 17 % 40, a, e + 6);
|
|
1015
|
+
if (!l) continue;
|
|
1016
|
+
const d = i[r % i.length], u = l.y + Math.sin(h) * c * 0.3 * a / 1e3;
|
|
1017
|
+
r % 3 ? E(o, l.x, u, d) : (E(o, l.x, u, d, 2), E(o, l.x, u + 2, P(d).deep, 2), E(o, l.x, u, P(d).hi));
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
const En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1021
|
+
__proto__: null,
|
|
1022
|
+
WHITE: qt,
|
|
1023
|
+
arc: $e,
|
|
1024
|
+
blob: Qt,
|
|
1025
|
+
dashStreak: He,
|
|
1026
|
+
debris: Oe,
|
|
1027
|
+
diamond: Pe,
|
|
1028
|
+
dot: E,
|
|
1029
|
+
drop: Zt,
|
|
1030
|
+
dust: Fe,
|
|
1031
|
+
hline: O,
|
|
1032
|
+
outlined: Le,
|
|
1033
|
+
puffBlob: Ce,
|
|
1034
|
+
ring: Re,
|
|
1035
|
+
shards: _e,
|
|
1036
|
+
snap: v,
|
|
1037
|
+
stroke: Z,
|
|
1038
|
+
xMark: Te
|
|
1039
|
+
}, Symbol.toStringTag, { value: "Module" })), Lt = 1e3 / 12, We = 1400, Ye = 150, Be = 420, Xe = 16, ft = { budget: 500, body: 60, big: 160 };
|
|
1040
|
+
class In {
|
|
1041
|
+
constructor(t, e) {
|
|
1042
|
+
this.scene = t, this.track = e;
|
|
1043
|
+
}
|
|
1044
|
+
scene;
|
|
1045
|
+
track;
|
|
1046
|
+
clouds = [];
|
|
1047
|
+
live = 0;
|
|
1048
|
+
play(t, e, n) {
|
|
1049
|
+
const s = Tt.getState(), a = s.reducedFx || s.batterySaver, i = Math.min(t.pixels.length, e ? a ? ft.big : Be : a ? ft.body : Ye), r = Math.min(i, Math.max(Xe, (a ? ft.budget : We) - this.live));
|
|
1050
|
+
if (r <= 0) return;
|
|
1051
|
+
const h = Math.max(1, Math.round(Math.abs(t.scaleY))), c = me(this.scene);
|
|
1052
|
+
this.track(c);
|
|
1053
|
+
const l = {
|
|
1054
|
+
g: c,
|
|
1055
|
+
x: Math.round(t.x),
|
|
1056
|
+
y: Math.round(t.y),
|
|
1057
|
+
born: n,
|
|
1058
|
+
end: n,
|
|
1059
|
+
size: h,
|
|
1060
|
+
n: r,
|
|
1061
|
+
frame: -1,
|
|
1062
|
+
x0: new Float32Array(r),
|
|
1063
|
+
y0: new Float32Array(r),
|
|
1064
|
+
delay: new Float32Array(r),
|
|
1065
|
+
life: new Float32Array(r),
|
|
1066
|
+
vx: new Float32Array(r),
|
|
1067
|
+
vy: new Float32Array(r),
|
|
1068
|
+
phase: new Float32Array(r),
|
|
1069
|
+
color: new Uint32Array(r)
|
|
1070
|
+
};
|
|
1071
|
+
let d = 0, u = -1 / 0, f = 1;
|
|
1072
|
+
const M = t.pixels;
|
|
1073
|
+
for (let y = 0; y < M.length; y++)
|
|
1074
|
+
d = Math.min(d, M.dy[y]), u = Math.max(u, M.dy[y]), f = Math.max(f, Math.abs(M.dx[y] * t.scaleX));
|
|
1075
|
+
const p = Math.max(1, u - d), g = e ? 520 : 260, b = e ? 900 : 620, w = r / M.length;
|
|
1076
|
+
let x = 0;
|
|
1077
|
+
for (let y = 0; y < M.length && x < r; y++) {
|
|
1078
|
+
if (w < 1 && Math.random() > w && M.length - y > r - x) continue;
|
|
1079
|
+
const A = M.dy[y], S = M.dx[y] * t.scaleX, B = A * Math.abs(t.scaleY), tt = (A - d) / p;
|
|
1080
|
+
l.x0[x] = S, l.y0[x] = B, l.delay[x] = tt * g * 0.6 + Math.random() * g * 0.4, l.life[x] = b * (0.6 + Math.random() * 0.6), l.vx[x] = S / f * 5 + (Math.random() - 0.5) * 10, l.vy[x] = -(10 + Math.random() * 16) * (e ? 1.3 : 1), l.phase[x] = Math.random() * Math.PI * 2, l.color[x] = M.color[y], l.end = Math.max(l.end, n + l.delay[x] + l.life[x]), x++;
|
|
1081
|
+
}
|
|
1082
|
+
l.n = x, this.live += l.n, this.clouds.push(l), this.draw(l, n);
|
|
1083
|
+
}
|
|
1084
|
+
update(t) {
|
|
1085
|
+
for (let e = this.clouds.length - 1; e >= 0; e--) {
|
|
1086
|
+
const n = this.clouds[e];
|
|
1087
|
+
if (!n.g.active || t >= n.end) {
|
|
1088
|
+
n.g.active && n.g.destroy(), this.live -= n.n, this.clouds.splice(e, 1);
|
|
1089
|
+
continue;
|
|
1090
|
+
}
|
|
1091
|
+
this.draw(n, t);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
draw(t, e) {
|
|
1095
|
+
const n = Math.floor((e - t.born) / Lt);
|
|
1096
|
+
if (n === t.frame) return;
|
|
1097
|
+
t.frame = n;
|
|
1098
|
+
const s = n * Lt, a = t.g;
|
|
1099
|
+
a.clear(), a.setPosition(t.x, t.y).setDepth(t.y + 2);
|
|
1100
|
+
const i = t.size;
|
|
1101
|
+
for (let r = 0; r < t.n; r++) {
|
|
1102
|
+
const h = s - t.delay[r];
|
|
1103
|
+
let c = t.x0[r], l = t.y0[r], d = t.color[r], u = 1;
|
|
1104
|
+
if (h > 0) {
|
|
1105
|
+
const f = h / t.life[r];
|
|
1106
|
+
if (f >= 1) continue;
|
|
1107
|
+
const M = h / 1e3;
|
|
1108
|
+
c += t.vx[r] * M + Math.sin(t.phase[r] + M * 9) * f * 1.5, l += t.vy[r] * M - 22 * M * M;
|
|
1109
|
+
const p = P(d);
|
|
1110
|
+
d = f < 0.3 ? d : f < 0.6 ? p.light : p.hi, u = f < 0.55 ? 1 : f < 0.8 ? 0.66 : 0.33;
|
|
1111
|
+
}
|
|
1112
|
+
a.rect(Math.round(c), Math.round(l), i, i, d, u);
|
|
1113
|
+
}
|
|
1114
|
+
a.present();
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
class Jt {
|
|
1118
|
+
constructor(t, e, n, s) {
|
|
1119
|
+
this.dx = t, this.dy = e, this.color = n, this.length = s;
|
|
1120
|
+
}
|
|
1121
|
+
dx;
|
|
1122
|
+
dy;
|
|
1123
|
+
color;
|
|
1124
|
+
length;
|
|
1125
|
+
*[Symbol.iterator]() {
|
|
1126
|
+
const t = { dx: 0, dy: 0, color: 0 };
|
|
1127
|
+
for (let e = 0; e < this.length; e++)
|
|
1128
|
+
t.dx = this.dx[e], t.dy = this.dy[e], t.color = this.color[e], yield t;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
const ot = new Jt(new Float32Array(0), new Float32Array(0), new Uint32Array(0), 0), Ln = ot, Ne = 512 * 512, Ue = 256, Ge = 3e5, H = /* @__PURE__ */ new Map();
|
|
1132
|
+
let ut = 0;
|
|
1133
|
+
function Ke(o, t) {
|
|
1134
|
+
for (H.set(o, t), ut += t.length; H.size > Ue || ut > Ge; ) {
|
|
1135
|
+
const e = H.keys().next();
|
|
1136
|
+
if (e.done) break;
|
|
1137
|
+
ut -= H.get(e.value).length, H.delete(e.value);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
function Rn(o, t, e) {
|
|
1141
|
+
const n = `${o.textureKey}|${o.frameName}|${t}`;
|
|
1142
|
+
if (!e) {
|
|
1143
|
+
const y = H.get(n);
|
|
1144
|
+
if (y)
|
|
1145
|
+
return H.delete(n), H.set(n, y), y;
|
|
1146
|
+
}
|
|
1147
|
+
const s = o.texture, a = s.source.resource;
|
|
1148
|
+
if (!(a instanceof HTMLCanvasElement)) return ot;
|
|
1149
|
+
const i = s.frame, r = Math.round(i.width), h = Math.round(i.height);
|
|
1150
|
+
if (r <= 0 || h <= 0 || r * h > Ne) return ot;
|
|
1151
|
+
let c;
|
|
1152
|
+
try {
|
|
1153
|
+
c = a.getContext("2d").getImageData(Math.round(i.x), Math.round(i.y), r, h).data;
|
|
1154
|
+
} catch {
|
|
1155
|
+
return ot;
|
|
1156
|
+
}
|
|
1157
|
+
const l = Math.max(1, Math.round(t)), d = Math.floor(r / l), u = Math.floor(h / l), f = Math.floor(l / 2);
|
|
1158
|
+
let M = 0;
|
|
1159
|
+
for (let y = 0; y < u; y++) for (let A = 0; A < d; A++) c[((y * l + f) * r + A * l + f) * 4 + 3] >= 128 && M++;
|
|
1160
|
+
const p = new Float32Array(M), g = new Float32Array(M), b = new Uint32Array(M);
|
|
1161
|
+
let w = 0;
|
|
1162
|
+
for (let y = 0; y < u; y++)
|
|
1163
|
+
for (let A = 0; A < d; A++) {
|
|
1164
|
+
const S = ((y * l + f) * r + A * l + f) * 4;
|
|
1165
|
+
c[S + 3] < 128 || (p[w] = A - d / 2, g[w] = y - u, b[w] = c[S] << 16 | c[S + 1] << 8 | c[S + 2], w++);
|
|
1166
|
+
}
|
|
1167
|
+
const x = new Jt(p, g, b, M);
|
|
1168
|
+
return e || Ke(n, x), x;
|
|
1169
|
+
}
|
|
1170
|
+
const te = 16773320, D = [], ee = 48;
|
|
1171
|
+
function Pn(o, t, e, n, s = te, a = performance.now()) {
|
|
1172
|
+
D.length >= ee && D.shift(), D.push({ x: o, y: t, r: e, born: a, until: a + n, fades: !0, color: s });
|
|
1173
|
+
}
|
|
1174
|
+
const je = 2e4;
|
|
1175
|
+
function _n(o, t, e = te, n = performance.now()) {
|
|
1176
|
+
const s = o(), a = { x: s.x, y: s.y, r: t, born: n, until: n + je, follow: o, fades: !1, color: e };
|
|
1177
|
+
return D.length >= ee && D.shift(), D.push(a), { end: () => a.until = 0 };
|
|
1178
|
+
}
|
|
1179
|
+
const ze = [];
|
|
1180
|
+
function qe(o) {
|
|
1181
|
+
for (let e = D.length - 1; e >= 0; e--) D[e].until <= o && D.splice(e, 1);
|
|
1182
|
+
const t = Tt.getState();
|
|
1183
|
+
if (t.combatLights === !1 || t.batterySaver) return ze;
|
|
1184
|
+
for (const e of D) {
|
|
1185
|
+
if (!e.follow) continue;
|
|
1186
|
+
let n;
|
|
1187
|
+
try {
|
|
1188
|
+
n = e.follow();
|
|
1189
|
+
} catch {
|
|
1190
|
+
e.until = 0, e.follow = void 0;
|
|
1191
|
+
continue;
|
|
1192
|
+
}
|
|
1193
|
+
e.x = n.x, e.y = n.y;
|
|
1194
|
+
}
|
|
1195
|
+
return D;
|
|
1196
|
+
}
|
|
1197
|
+
function Ve(o, t) {
|
|
1198
|
+
if (!o.fades) return o.r;
|
|
1199
|
+
const e = Math.min(1, (t - o.born) / Math.max(1, o.until - o.born));
|
|
1200
|
+
return o.r * Math.sqrt(1 - e);
|
|
1201
|
+
}
|
|
1202
|
+
function Tn() {
|
|
1203
|
+
D.length = 0;
|
|
1204
|
+
}
|
|
1205
|
+
const Qe = 66, Ze = 33, N = 8, Je = (o) => Math.min(1, Math.pow(Math.max(0, 1 - o * o), 1.5) * 1.15), tn = (o) => Math.pow(Math.max(0, 1 - o), 2), en = 4, nn = 3, sn = 0.3, Mt = 0.85, Rt = 16761466, on = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5].map((o) => (o + 0.5) / 16), ne = (o) => o <= 24 ? Math.max(2, Math.round(o / 2) * 2) : Math.round(o / 8) * 8, an = [...new Set(Array.from({ length: 160 }, (o, t) => ne(t + 1)))], rn = 33, Pt = /* @__PURE__ */ new Map();
|
|
1206
|
+
let _t = !1;
|
|
1207
|
+
function hn() {
|
|
1208
|
+
if (_t) return;
|
|
1209
|
+
_t = !0;
|
|
1210
|
+
const o = an.flatMap((e) => [["hole", e], ["wash", e]]), t = () => {
|
|
1211
|
+
const e = o.shift();
|
|
1212
|
+
e && (q(e[0], e[1]), setTimeout(t, 0));
|
|
1213
|
+
};
|
|
1214
|
+
setTimeout(t, 0);
|
|
1215
|
+
}
|
|
1216
|
+
function q(o, t) {
|
|
1217
|
+
const e = `${o}${t}`, n = Pt.get(e);
|
|
1218
|
+
if (n) return n;
|
|
1219
|
+
const s = t * 2, a = Math.max(2, Math.round(t * 2 * Mt)), i = o === "hole" ? en : nn, r = o === "hole" ? Je : tn, h = document.createElement("canvas");
|
|
1220
|
+
h.width = s, h.height = a;
|
|
1221
|
+
const c = h.getContext("2d");
|
|
1222
|
+
if (!c) return W.EMPTY;
|
|
1223
|
+
const l = c.createImageData(s, a);
|
|
1224
|
+
for (let u = 0; u < a; u++)
|
|
1225
|
+
for (let f = 0; f < s; f++) {
|
|
1226
|
+
const M = Math.hypot((f + 0.5 - s / 2) / t, (u + 0.5 - a / 2) / (t * Mt));
|
|
1227
|
+
if (M >= 1) continue;
|
|
1228
|
+
const p = Math.min(i, Math.floor(r(M) * i + on[u % 4 * 4 + f % 4])) / i, g = (u * s + f) * 4;
|
|
1229
|
+
l.data[g] = l.data[g + 1] = l.data[g + 2] = 255, l.data[g + 3] = Math.round(p * 255);
|
|
1230
|
+
}
|
|
1231
|
+
c.putImageData(l, 0, 0);
|
|
1232
|
+
const d = W.from(h);
|
|
1233
|
+
return d.source.scaleMode = "nearest", Pt.set(e, d), d;
|
|
1234
|
+
}
|
|
1235
|
+
class Hn {
|
|
1236
|
+
constructor(t, e, n) {
|
|
1237
|
+
this.stage = t, this.color = e, this.alpha = n, this.sheet = new K({ texture: W.WHITE }), this.scratch.addChild(this.sheet, this.holes, this.washes), this.carried = this.light(16773340), this.rt = wt.create({ width: 1, height: 1 }), this.view = new K({ texture: this.rt }), this.layer.addChild(this.view), t.screen.addChild(this.layer), t.cameras.main.follow(this.layer), this.unsubscribeResize = t.onResize(() => this.dirty = !0), hn();
|
|
1238
|
+
}
|
|
1239
|
+
stage;
|
|
1240
|
+
color;
|
|
1241
|
+
alpha;
|
|
1242
|
+
scratch = new et();
|
|
1243
|
+
sheet;
|
|
1244
|
+
/** Every hole is erased before any colour is laid, or a later hole would wipe an earlier light's colour away. */
|
|
1245
|
+
holes = new et();
|
|
1246
|
+
washes = new et();
|
|
1247
|
+
lamps = [];
|
|
1248
|
+
/** The transient lights (`lights.ts`), reused frame to frame. */
|
|
1249
|
+
flashes = [];
|
|
1250
|
+
rt;
|
|
1251
|
+
/**
|
|
1252
|
+
* On the screen layer, laid over the world with its exact transform by the camera (`Camera.follow`), shake included:
|
|
1253
|
+
* the night is drawn in world pixels round the unshaken camera and only this layer moves with a shake, so a shaking
|
|
1254
|
+
* screen does not redraw the night every frame.
|
|
1255
|
+
*/
|
|
1256
|
+
layer = new et();
|
|
1257
|
+
view;
|
|
1258
|
+
/** The light the player carries: the only one that follows them, and the last one they lose. */
|
|
1259
|
+
carried;
|
|
1260
|
+
unsubscribeResize;
|
|
1261
|
+
/** Lamps that flicker: while one does (or the player carries a light) every frame differs. */
|
|
1262
|
+
flickering = 0;
|
|
1263
|
+
/** Something other than the camera changed what the night looks like (a lamp added, dimmed, the window resized). */
|
|
1264
|
+
dirty = !0;
|
|
1265
|
+
/** What the last drawn frame was drawn from: the texture, the camera's texel and the shade. */
|
|
1266
|
+
drawn = "";
|
|
1267
|
+
/** The carried light's place at the last redraw (it follows the body). */
|
|
1268
|
+
carriedAt = "";
|
|
1269
|
+
/** When the sheet was last redrawn. */
|
|
1270
|
+
drawnAt = -1 / 0;
|
|
1271
|
+
/** The world pixel the night's top-left texel stands on. */
|
|
1272
|
+
ox = 0;
|
|
1273
|
+
oy = 0;
|
|
1274
|
+
/** The night texture's size in world pixels, and the zoom it was made for. */
|
|
1275
|
+
rtKey = "";
|
|
1276
|
+
/** The lamps' colour turned down (`setLampsDimmed`). */
|
|
1277
|
+
dimLamps = !1;
|
|
1278
|
+
/** A phone redraws the night at most `PHONE_MS` apart, whatever moves (`isTouchUi`). */
|
|
1279
|
+
phone = le();
|
|
1280
|
+
/** A hole and its colour, added to the night's layers. */
|
|
1281
|
+
light(t) {
|
|
1282
|
+
const e = new K({ texture: q("hole", 8) });
|
|
1283
|
+
e.blendMode = "erase", this.holes.addChild(e);
|
|
1284
|
+
const n = new K({ texture: q("wash", 8) });
|
|
1285
|
+
return n.tint = t, this.washes.addChild(n), { hole: e, wash: n };
|
|
1286
|
+
}
|
|
1287
|
+
/** A lamp fixed in the world: a torch on a wall, the seep in its chamber, a crystal in a seam, in its own colour. */
|
|
1288
|
+
addLamp(t, e, n, s = 0, a = Rt) {
|
|
1289
|
+
this.lamps.push({ sprites: this.light(a), x: t, y: e, r: n, flicker: s }), s && this.flickering++, this.dirty = !0;
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Changes how dark and what colour the sheet is (the outdoor night, `NightShade`, deepens and lifts with the
|
|
1293
|
+
* world clock). A sheet with no alpha left is neither drawn nor redrawn, so a map at noon pays nothing for its night.
|
|
1294
|
+
*/
|
|
1295
|
+
setShade(t, e) {
|
|
1296
|
+
this.color = t, this.alpha = e, this.layer.visible = e > 4e-3;
|
|
1297
|
+
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Dimmed lamps lay only `LAMP_DIM` of their colour on the dark (a "fewer ambient lights" setting). The holes they
|
|
1300
|
+
* cut stay as wide, so a dark place is still seen by them.
|
|
1301
|
+
*/
|
|
1302
|
+
setLampsDimmed(t) {
|
|
1303
|
+
t !== this.dimLamps && (this.dimLamps = t, this.dirty = !0);
|
|
1304
|
+
}
|
|
1305
|
+
/**
|
|
1306
|
+
* The night's own texture, one texel a world pixel and `MARGIN` to spare on each side (a shake, or a camera that
|
|
1307
|
+
* moved while a phone waits for its next redraw, never shows its edge), remade when the window or the zoom changes:
|
|
1308
|
+
* at zoom 2 or 3 it is a quarter or a ninth of the screen's pixels. True when it was remade.
|
|
1309
|
+
*/
|
|
1310
|
+
fit(t, e, n) {
|
|
1311
|
+
const s = Math.ceil(t / n) + N * 2, a = Math.ceil(e / n) + N * 2, i = `${s},${a},${n}`;
|
|
1312
|
+
return i === this.rtKey ? !1 : (this.rtKey = i, this.rt.destroy(!0), this.rt = wt.create({ width: s, height: a }), this.rt.source.scaleMode = "nearest", this.view.texture = this.rt, !0);
|
|
1313
|
+
}
|
|
1314
|
+
/** Redraws the night with this frame's holes in it, when anything in it changed. `px`/`py` is where the player stands. */
|
|
1315
|
+
update(t, e, n, s) {
|
|
1316
|
+
if (!this.layer.visible) return;
|
|
1317
|
+
const a = this.stage.cameras.main, i = a.zoom || 1, r = this.fit(this.stage.width, this.stage.height, i), h = Math.floor(a.scrollX) - N, c = Math.floor(a.scrollY) - N, l = `${h},${c},${this.rtKey},${this.color},${this.alpha}`, d = qe(t), u = s > 0 ? `${Math.round(e)},${Math.round(n)},${Math.round(s)}` : "", f = t - this.drawnAt;
|
|
1318
|
+
if (!(this.dirty || l !== this.drawn || u !== this.carriedAt || d.length > 0 && f >= rn || (s > 0 || this.flickering > 0) && f >= Qe)) return;
|
|
1319
|
+
const p = Math.abs(h - this.ox) >= N - 1 || Math.abs(c - this.oy) >= N - 1;
|
|
1320
|
+
if (this.phone && f < Ze && !r && !p) return;
|
|
1321
|
+
this.dirty = !1, this.drawn = l, this.carriedAt = u, this.drawnAt = t, this.ox = h, this.oy = c, this.view.position.set(h, c), this.sheet.width = this.rt.width, this.sheet.height = this.rt.height, this.sheet.position.set(0, 0), this.sheet.tint = this.color, this.sheet.alpha = this.alpha;
|
|
1322
|
+
const g = sn * Math.min(1, this.alpha * 1.4);
|
|
1323
|
+
s <= 0 ? this.hide(this.carried) : this.place(this.carried, e, n - 6, s * (1 + Math.sin(t / 260) * 0.03 + Math.sin(t / 90) * 0.015), g * 0.5);
|
|
1324
|
+
const b = this.dimLamps ? g * cn : g;
|
|
1325
|
+
for (const w of this.lamps) {
|
|
1326
|
+
const x = w.flicker ? 1 + Math.sin(t / 190 + w.flicker) * 0.05 + Math.sin(t / 71 + w.flicker) * 0.03 : 1;
|
|
1327
|
+
this.place(w.sprites, w.x, w.y, w.r * x, b * (w.flicker ? 0.9 + (x - 1) * 2 : 1));
|
|
1328
|
+
}
|
|
1329
|
+
for (; this.flashes.length < d.length; ) this.flashes.push(this.light(Rt));
|
|
1330
|
+
for (let w = 0; w < this.flashes.length; w++) {
|
|
1331
|
+
const x = d[w], y = this.flashes[w];
|
|
1332
|
+
if (!x) {
|
|
1333
|
+
this.hide(y);
|
|
1334
|
+
continue;
|
|
1335
|
+
}
|
|
1336
|
+
y.wash.tint = x.color, this.place(y, x.x, x.y, Ve(x, t), Math.min(0.6, g * 1.6));
|
|
1337
|
+
}
|
|
1338
|
+
this.stage.app.renderer.render({ container: this.scratch, target: this.rt, clear: !0 });
|
|
1339
|
+
}
|
|
1340
|
+
hide(t) {
|
|
1341
|
+
t.hole.visible = !1, t.wash.visible = !1;
|
|
1342
|
+
}
|
|
1343
|
+
/** Lays light `l` at world (wx, wy), `r` px across its radius, in the night's world-pixel grid. */
|
|
1344
|
+
place(t, e, n, s, a) {
|
|
1345
|
+
const i = ne(s), r = Math.round(e) - this.ox, h = Math.round(n) - this.oy;
|
|
1346
|
+
if (s < 1 || r < -i || h < -i || r > this.rt.width + i || h > this.rt.height + i) {
|
|
1347
|
+
this.hide(t);
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
t.hole.texture = q("hole", i), t.wash.texture = q("wash", i);
|
|
1351
|
+
for (const c of [t.hole, t.wash])
|
|
1352
|
+
c.visible = !0, c.position.set(r - i, h - Math.round(i * Mt));
|
|
1353
|
+
t.wash.alpha = a, t.wash.visible = a > 0.01;
|
|
1354
|
+
}
|
|
1355
|
+
destroy() {
|
|
1356
|
+
this.unsubscribeResize(), this.stage.cameras.main.unfollow(this.layer), this.layer.destroy({ children: !0 }), this.rt.destroy(!0), this.scratch.destroy({ children: !0, context: !0 });
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
const cn = 0.35, Cn = ce * 5;
|
|
1360
|
+
export {
|
|
1361
|
+
Cn as CARRIED_LIGHT,
|
|
1362
|
+
bt as CLEAR,
|
|
1363
|
+
Hn as Darkness,
|
|
1364
|
+
In as Evaporation,
|
|
1365
|
+
cn as LAMP_DIM,
|
|
1366
|
+
xn as MATERIALS,
|
|
1367
|
+
Ln as NO_PIXELS,
|
|
1368
|
+
Ft as PALETTE,
|
|
1369
|
+
Jt as PackedPixels,
|
|
1370
|
+
G as PixelGrid,
|
|
1371
|
+
J as PixelLayer,
|
|
1372
|
+
gn as PixelWindow,
|
|
1373
|
+
Rt as WARM_LIGHT,
|
|
1374
|
+
me as addPixelLayer,
|
|
1375
|
+
bn as art,
|
|
1376
|
+
_n as carriedLight,
|
|
1377
|
+
R as channels,
|
|
1378
|
+
Tn as clearLights,
|
|
1379
|
+
Pn as flashLight,
|
|
1380
|
+
Sn as groundShadow,
|
|
1381
|
+
nt as hash2,
|
|
1382
|
+
m as hex,
|
|
1383
|
+
pt as hueShade,
|
|
1384
|
+
An as litOutline,
|
|
1385
|
+
qe as liveLights,
|
|
1386
|
+
mn as makeSheet,
|
|
1387
|
+
we as mix,
|
|
1388
|
+
Mn as mulberry32,
|
|
1389
|
+
Wt as outlineOf,
|
|
1390
|
+
En as pixelPaint,
|
|
1391
|
+
Dn as pixelTone,
|
|
1392
|
+
ye as ramp,
|
|
1393
|
+
yn as rampTones,
|
|
1394
|
+
L as rgba,
|
|
1395
|
+
vn as selectiveOutline,
|
|
1396
|
+
$t as shade,
|
|
1397
|
+
kn as shadeBox,
|
|
1398
|
+
Rn as spritePixels,
|
|
1399
|
+
dn as toCss,
|
|
1400
|
+
wn as upscale,
|
|
1401
|
+
pn as valueNoise,
|
|
1402
|
+
un as withAlpha
|
|
1403
|
+
};
|
|
1404
|
+
//# sourceMappingURL=pixel.js.map
|