1681-engine 0.6.5 → 0.6.7

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 CHANGED
@@ -3,6 +3,36 @@
3
3
  All notable changes to this package are written here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
4
4
  and versions follow [Semantic Versioning](https://semver.org/); before 1.0 a minor version may break the API.
5
5
 
6
+ ## 0.6.7
7
+
8
+ ### Added
9
+
10
+ - `Group.keepAbove` / `keepBelow`: keep a child on one side of another, moved only when it is on the wrong side. Two
11
+ pieces each placed *directly* above one body with `moveAbove` (two blades, a fist on a hilt) pushed each other out
12
+ every frame, and every push rebuilt Pixi's draw instructions.
13
+
14
+ ### Changed
15
+
16
+ - The world layer sorts by depth once a frame (`deferDepthSort`, `flushDepthSorts`, run by `Stage.frame` after the
17
+ camera): a child's `zIndex` changing only notes the container, and the children are sorted — the render group's
18
+ structure marked changed — only when they are out of order. Pixi marked the structure changed at every `zIndex`
19
+ change, so a world sorted by its bodies' feet rebuilt every draw instruction every frame anything walked up or down
20
+ the screen. A container not handed over keeps Pixi's own behaviour.
21
+
22
+ ## 0.6.6
23
+
24
+ ### Added
25
+
26
+ - `TextureRegistry.addView(key, page, x, y, w, h)`: a key that is one rect of another texture, on that texture's own
27
+ source (`CanvasTexture`'s `view`), so pieces swapped every few frames batch together.
28
+
29
+ ### Changed
30
+
31
+ - `paintLifeArt` lays every piece of the ambient life (leaves, seeds, embers, motes, ash, butterflies, birds,
32
+ fireflies, smoke) on one page and registers each key as a view of it (`packShelves`). A canvas each made every flap
33
+ of a butterfly or puff of smoke a texture of another source, and Pixi rebuilt the world's draw instructions at each.
34
+ The keys and `LifeArt` are unchanged.
35
+
6
36
  ## 0.6.5
7
37
 
8
38
  ### Changed
@@ -22,6 +22,18 @@ class d extends r(i) {
22
22
  moveBelow(t, e) {
23
23
  return t.parent !== this || e.parent !== this || t === e ? this : this.getChildIndex(t) === this.getChildIndex(e) - 1 ? this : (this.removeChild(t), this.addChildAt(t, this.getChildIndex(e)), this);
24
24
  }
25
+ /**
26
+ * Keeps `child` drawn above `other`, anywhere above it: moved (directly above) only when it is below. What a weapon
27
+ * held over its body asks for. `moveAbove` from two pieces each wanting to sit *directly* above the same body (two
28
+ * blades, a fist on a hilt, a load) pushed the other out every frame, and every push rebuilt Pixi's instructions.
29
+ */
30
+ keepAbove(t, e) {
31
+ return t.parent !== this || e.parent !== this || t === e ? this : this.getChildIndex(t) > this.getChildIndex(e) ? this : this.moveAbove(t, e);
32
+ }
33
+ /** Keeps `child` drawn below `other`, anywhere below it: moved (directly below) only when it is above (`keepAbove`). */
34
+ keepBelow(t, e) {
35
+ return t.parent !== this || e.parent !== this || t === e ? this : this.getChildIndex(t) < this.getChildIndex(e) ? this : this.moveBelow(t, e);
36
+ }
25
37
  /** Puts `child` directly above `other` in the draw order; already there, it does nothing (see `moveBelow`). */
26
38
  moveAbove(t, e) {
27
39
  return t.parent !== this || e.parent !== this || t === e ? this : this.getChildIndex(t) === this.getChildIndex(e) + 1 ? this : (this.removeChild(t), this.addChildAt(t, this.getChildIndex(e) + 1), this);
@@ -1,13 +1,14 @@
1
1
  import { Container as s } from "pixi.js";
2
2
  import { Camera as n } from "./Camera.js";
3
3
  import { Clock as a } from "./Clock.js";
4
- import { ObjectFactory as o } from "./ObjectFactory.js";
5
- import { PixelGrid as d } from "./PixelGrid.js";
6
- import { Pointer as c } from "./Pointer.js";
7
- import { Tweener as m } from "./Tweener.js";
4
+ import { deferDepthSort as o, flushDepthSorts as d } from "./depthSort.js";
5
+ import { ObjectFactory as c } from "./ObjectFactory.js";
6
+ import { PixelGrid as m } from "./PixelGrid.js";
7
+ import { Pointer as p } from "./Pointer.js";
8
+ import { Tweener as u } from "./Tweener.js";
8
9
  class h {
9
10
  constructor(t, e) {
10
- this.app = t, this.textures = e, t.stage.addChild(this.world, this.screen), this.cameras = { main: new n(this.world, this.screen) }, this.input = { activePointer: new c(t.canvas) }, this.grid = new d(t, this.world), this.time.onError = (i) => this.caught("timers", i), this.syncSize();
11
+ this.app = t, this.textures = e, t.stage.addChild(this.world, this.screen), o(this.world), this.cameras = { main: new n(this.world, this.screen) }, this.input = { activePointer: new p(t.canvas) }, this.grid = new m(t, this.world), this.time.onError = (i) => this.caught("timers", i), this.syncSize();
11
12
  }
12
13
  app;
13
14
  textures;
@@ -15,8 +16,8 @@ class h {
15
16
  static onCaught = null;
16
17
  world = new s({ sortableChildren: !0 });
17
18
  screen = new s();
18
- add = new o(this);
19
- tweens = new m();
19
+ add = new c(this);
20
+ tweens = new u();
20
21
  time = new a();
21
22
  cameras;
22
23
  input;
@@ -61,7 +62,7 @@ class h {
61
62
  */
62
63
  frame(t) {
63
64
  const e = performance.now();
64
- this.guard("resize", () => this.syncSize()), this.guard("update", () => this.update(e, t)), this.guard("tweens", () => this.tweens.update(t)), this.guard("timers", () => this.time.update(e)), this.guard("camera", () => this.cameras.main.apply(e)), (this.pixelPerfect || this.gridLive) && (this.gridLive = this.pixelPerfect, this.guard("pixel grid", () => this.grid.render(this.cameras.main, this.pixelPerfect, this.pixelDensity)));
65
+ this.guard("resize", () => this.syncSize()), this.guard("update", () => this.update(e, t)), this.guard("tweens", () => this.tweens.update(t)), this.guard("timers", () => this.time.update(e)), this.guard("camera", () => this.cameras.main.apply(e)), this.guard("depth", d), (this.pixelPerfect || this.gridLive) && (this.gridLive = this.pixelPerfect, this.guard("pixel grid", () => this.grid.render(this.cameras.main, this.pixelPerfect, this.pixelDensity)));
65
66
  }
66
67
  /**
67
68
  * Keeps a piece of text made outside `add.text`/`add.label` (put on the world any way) at screen resolution while the
@@ -1,25 +1,26 @@
1
- import { CanvasSource as f, Texture as d, Rectangle as u } from "pixi.js";
2
- class v {
3
- constructor(t, s) {
4
- this.key = t, this.canvas = s, this.source = new f({ resource: s, scaleMode: "nearest" }), this.whole = new d({ source: this.source });
1
+ import { CanvasSource as m, Texture as c, Rectangle as u } from "pixi.js";
2
+ class f {
3
+ constructor(t, s, e) {
4
+ this.key = t, this.canvas = s, this.owned = !e, this.source = e?.source ?? new m({ resource: s, scaleMode: "nearest" }), this.whole = e ? new c({ source: this.source, frame: e.frame }) : new c({ source: this.source });
5
5
  }
6
6
  key;
7
7
  canvas;
8
8
  frames = /* @__PURE__ */ new Map();
9
9
  source;
10
10
  whole;
11
+ owned;
11
12
  get width() {
12
- return this.canvas.width;
13
+ return this.owned ? this.canvas.width : this.whole.frame.width;
13
14
  }
14
15
  get height() {
15
- return this.canvas.height;
16
+ return this.owned ? this.canvas.height : this.whole.frame.height;
16
17
  }
17
18
  get context() {
18
19
  return this.canvas.getContext("2d");
19
20
  }
20
21
  /** Adds a frame cut from the canvas (`_source` kept for the old call shape). */
21
- add(t, s, e, a, n, i) {
22
- this.frames.get(t)?.destroy(), this.frames.set(t, new d({ source: this.source, frame: new u(e, a, n, i) }));
22
+ add(t, s, e, a, i, h) {
23
+ this.frames.get(t)?.destroy(), this.frames.set(t, new c({ source: this.source, frame: new u(e, a, i, h) }));
23
24
  }
24
25
  /**
25
26
  * Adds a packed frame cut from `page` (this texture's canvas by default): trimmed frames keep their untrimmed size
@@ -27,7 +28,7 @@ class v {
27
28
  */
28
29
  addPacked(t, s = this) {
29
30
  this.frames.get(t.name)?.destroy();
30
- const e = new d({
31
+ const e = new c({
31
32
  source: s.source,
32
33
  frame: new u(t.x, t.y, t.w, t.h),
33
34
  orig: new u(0, 0, t.sourceW, t.sourceH),
@@ -43,17 +44,17 @@ class v {
43
44
  */
44
45
  adopt(t, s) {
45
46
  const e = s.frames.get(t);
46
- e && (this.frames.get(t)?.destroy(), this.frames.set(t, new d({ source: s.source, frame: e.frame.clone() })));
47
+ e && (this.frames.get(t)?.destroy(), this.frames.set(t, new c({ source: s.source, frame: e.frame.clone() })));
47
48
  }
48
49
  refresh() {
49
50
  this.source.update();
50
51
  }
51
52
  destroy() {
52
53
  for (const t of this.frames.values()) t.destroy();
53
- this.frames.clear(), this.whole.destroy(), this.source.destroy();
54
+ this.frames.clear(), this.whole.destroy(), this.owned && this.source.destroy();
54
55
  }
55
56
  }
56
- class m {
57
+ class v {
57
58
  textures = /* @__PURE__ */ new Map();
58
59
  /** Textures repainted or freed while in use (a rig body, its hand): a copy of one must snapshot it first. */
59
60
  live = /* @__PURE__ */ new Set();
@@ -67,42 +68,42 @@ class m {
67
68
  }
68
69
  /** A new texture holding frame `frame` of `key` as it is painted right now; returns its key (one frame, '0'). */
69
70
  snapshot(t, s) {
70
- const e = this.get(t, s), { x: a, y: n, width: i, height: r } = e.frame, h = document.createElement("canvas");
71
- h.width = i, h.height = r;
71
+ const e = this.get(t, s), { x: a, y: i, width: h, height: r } = e.frame, n = document.createElement("canvas");
72
+ n.width = h, n.height = r;
72
73
  const o = this.textures.get(t)?.canvas;
73
- o && h.getContext("2d").drawImage(o, a, n, i, r, 0, 0, i, r);
74
- const c = `${t}#still${++this.snapshots}`;
75
- return this.addCanvas(c, h).add("0", 0, 0, 0, i, r), c;
74
+ o && n.getContext("2d").drawImage(o, a, i, h, r, 0, 0, h, r);
75
+ const d = `${t}#still${++this.snapshots}`;
76
+ return this.addCanvas(d, n).add("0", 0, 0, 0, h, r), d;
76
77
  }
77
78
  /**
78
79
  * `snapshot` into a texture kept for reuse (`into`): its canvas is repainted in place and uploaded again, and only
79
80
  * made anew when the frame's size changes. Frame '0' is the copy.
80
81
  */
81
82
  snapshotInto(t, s, e) {
82
- const a = this.get(t, s), { x: n, y: i, width: r, height: h } = a.frame;
83
+ const a = this.get(t, s), { x: i, y: h, width: r, height: n } = a.frame;
83
84
  let o = this.textures.get(e);
84
- if (!o || o.width !== r || o.height !== h) {
85
+ if (!o || o.width !== r || o.height !== n) {
85
86
  const g = document.createElement("canvas");
86
- g.width = r, g.height = h, o = this.addCanvas(e, g), o.add("0", 0, 0, 0, r, h);
87
+ g.width = r, g.height = n, o = this.addCanvas(e, g), o.add("0", 0, 0, 0, r, n);
87
88
  }
88
- const c = o.context;
89
- c.clearRect(0, 0, r, h);
89
+ const d = o.context;
90
+ d.clearRect(0, 0, r, n);
90
91
  const w = this.textures.get(t)?.canvas;
91
- w && c.drawImage(w, n, i, r, h, 0, 0, r, h), o.refresh();
92
+ w && d.drawImage(w, i, h, r, n, 0, 0, r, n), o.refresh();
92
93
  }
93
94
  exists(t) {
94
95
  return this.textures.has(t);
95
96
  }
96
97
  addCanvas(t, s) {
97
98
  this.remove(t);
98
- const e = new v(t, s);
99
+ const e = new f(t, s);
99
100
  return this.textures.set(t, e), e;
100
101
  }
101
102
  /** A canvas cut into equal frames named 0, 1, 2... left to right, then row by row. */
102
103
  addSpriteSheet(t, s, e) {
103
- const a = this.addCanvas(t, s), n = Math.floor(s.width / e.frameWidth), i = Math.floor(s.height / e.frameHeight);
104
- for (let r = 0; r < n * i; r++)
105
- a.add(String(r), 0, r % n * e.frameWidth, Math.floor(r / n) * e.frameHeight, e.frameWidth, e.frameHeight);
104
+ const a = this.addCanvas(t, s), i = Math.floor(s.width / e.frameWidth), h = Math.floor(s.height / e.frameHeight);
105
+ for (let r = 0; r < i * h; r++)
106
+ a.add(String(r), 0, r % i * e.frameWidth, Math.floor(r / i) * e.frameHeight, e.frameWidth, e.frameHeight);
106
107
  return a;
107
108
  }
108
109
  /**
@@ -114,12 +115,23 @@ class m {
114
115
  for (let a = 1; this.textures.has(`${t}~${a}`); a++)
115
116
  this.remove(`${t}~${a}`);
116
117
  const e = this.addCanvas(t, s[0].canvas);
117
- return s.forEach((a, n) => {
118
- const i = n === 0 ? e : this.addCanvas(`${t}~${n}`, a.canvas);
118
+ return s.forEach((a, i) => {
119
+ const h = i === 0 ? e : this.addCanvas(`${t}~${i}`, a.canvas);
119
120
  for (const r of a.frames)
120
- i !== e && i.addPacked(r), e.addPacked(r, i);
121
+ h !== e && h.addPacked(r), e.addPacked(r, h);
121
122
  }), e;
122
123
  }
124
+ /**
125
+ * Registers `key` as the rect (x, y, w, h) of the texture `page`, on the page's source: shown by `setTexture(key)`
126
+ * like any texture, and batched with every other view of that page. Null when the page is not registered.
127
+ */
128
+ addView(t, s, e, a, i, h) {
129
+ const r = this.textures.get(s);
130
+ if (!r) return null;
131
+ this.remove(t);
132
+ const n = new f(t, r.canvas, { source: r.source, frame: new u(e, a, i, h) });
133
+ return this.textures.set(t, n), n;
134
+ }
123
135
  createCanvas(t, s, e) {
124
136
  const a = document.createElement("canvas");
125
137
  return a.width = s, a.height = e, this.addCanvas(t, a);
@@ -132,10 +144,10 @@ class m {
132
144
  return e ? s === void 0 || s === "" ? e.whole : e.frames.get(String(s)) ?? this.warn(`${t}/${s}`) : this.warn(t);
133
145
  }
134
146
  warn(t) {
135
- return this.missing.has(t) || (this.missing.add(t), console.warn(`[textures] missing ${t}`)), d.EMPTY;
147
+ return this.missing.has(t) || (this.missing.add(t), console.warn(`[textures] missing ${t}`)), c.EMPTY;
136
148
  }
137
149
  }
138
150
  export {
139
- v as CanvasTexture,
140
- m as TextureRegistry
151
+ f as CanvasTexture,
152
+ v as TextureRegistry
141
153
  };
@@ -0,0 +1,44 @@
1
+ import { Container as c } from "pixi.js";
2
+ const s = /* @__PURE__ */ new WeakSet(), d = /* @__PURE__ */ new Set();
3
+ let f = !1;
4
+ function p() {
5
+ if (f) return;
6
+ f = !0;
7
+ const e = c.prototype, r = e.depthOfChildModified;
8
+ e.depthOfChildModified = function() {
9
+ const t = this.parent;
10
+ if (t && s.has(t)) {
11
+ const n = t;
12
+ n.sortableChildren = !0, n.sortDirty = !0, d.add(t);
13
+ return;
14
+ }
15
+ r.call(this);
16
+ };
17
+ }
18
+ function h(e) {
19
+ p(), s.add(e);
20
+ }
21
+ function l() {
22
+ for (const e of d) {
23
+ if (e.destroyed) continue;
24
+ const r = e, o = e.children;
25
+ let t = !0;
26
+ for (let i = 1; i < o.length; i++)
27
+ if (o[i - 1].zIndex > o[i].zIndex) {
28
+ t = !1;
29
+ break;
30
+ }
31
+ if (t) {
32
+ r.sortDirty = !1;
33
+ continue;
34
+ }
35
+ r.sortChildren();
36
+ const n = r.renderGroup ?? r.parentRenderGroup;
37
+ n && (n.structureDidChange = !0);
38
+ }
39
+ d.clear();
40
+ }
41
+ export {
42
+ h as deferDepthSort,
43
+ l as flushDepthSorts
44
+ };
@@ -1,4 +1,4 @@
1
- const F = {
1
+ const M = {
2
2
  leaves: [
3
3
  ["#7ab04e", "#3d7a36"],
4
4
  ["#d8a040", "#9a5a24"]
@@ -22,62 +22,77 @@ const F = {
22
22
  firefly: ["#f0ff9a", "#a8c850"],
23
23
  smoke: ["#b8b0b4", "#9a9296", "#7c7478"]
24
24
  }, v = 6;
25
- function L(o, e) {
25
+ function O(o, b) {
26
26
  const l = Number.parseInt(o.replace("#", ""), 16);
27
- return `rgba(${l >> 16 & 255},${l >> 8 & 255},${l & 255},${e})`;
27
+ return `rgba(${l >> 16 & 255},${l >> 8 & 255},${l & 255},${b})`;
28
28
  }
29
- function M(o, e = F.smoke) {
30
- const l = [[2, 2], [3, 3], [4, 3], [5, 4], [6, 5], [7, 5]], [s, n] = l[Math.max(0, Math.min(v - 1, o))], [b, _, p] = e, h = [], y = (s - 1) / 2, u = (n - 1) / 2, S = o < 3 ? 0.9 : o < 5 ? 0.78 : 0.62;
31
- for (let a = 0; a < n; a++)
32
- for (let r = 0; r < s; r++) {
33
- const $ = (r - y) / (s / 2), m = (a - u) / (n / 2), g = (r * 7 + a * 13 + o * 5) % 5 / 10;
34
- if ($ * $ + m * m > 0.85 + g || o >= v - 2 && (r + a + o) % 2) continue;
35
- const w = $ + m, d = w < -0.35 ? b : w > 0.45 ? p : _;
36
- h.push([r, a, d.startsWith("#") ? L(d, S) : d]);
29
+ function P(o, b = M.smoke) {
30
+ const l = [[2, 2], [3, 3], [4, 3], [5, 4], [6, 5], [7, 5]], [n, c] = l[Math.max(0, Math.min(v - 1, o))], [h, t, _] = b, p = [], f = (n - 1) / 2, m = (c - 1) / 2, $ = o < 3 ? 0.9 : o < 5 ? 0.78 : 0.62;
31
+ for (let d = 0; d < c; d++)
32
+ for (let r = 0; r < n; r++) {
33
+ const e = (r - f) / (n / 2), y = (d - m) / (c / 2), k = (r * 7 + d * 13 + o * 5) % 5 / 10;
34
+ if (e * e + y * y > 0.85 + k || o >= v - 2 && (r + d + o) % 2) continue;
35
+ const g = e + y, u = g < -0.35 ? h : g > 0.45 ? _ : t;
36
+ p.push([r, d, u.startsWith("#") ? O(u, $) : u]);
37
37
  }
38
- return { w: s, h: n, px: h };
38
+ return { w: n, h: c, px: p };
39
39
  }
40
- function f(o, e, l, s, n) {
41
- if (o.exists(e)) return e;
42
- const b = document.createElement("canvas");
43
- b.width = l, b.height = s;
44
- const _ = b.getContext("2d");
45
- for (const [p, h, y] of n)
46
- _.fillStyle = y, _.fillRect(p, h, 1, 1);
47
- return o.addCanvas(e, b), e;
40
+ const A = 64;
41
+ function R(o, b = A) {
42
+ const l = [];
43
+ let n = 0, c = 0, h = 0;
44
+ for (const [t, _] of o)
45
+ n > 0 && n + t > b && (n = 0, c += h + 1, h = 0), l.push([n, c]), n += t + 1, h = Math.max(h, _);
46
+ return { at: l, height: c + h };
48
47
  }
49
- function R(o, e = {}, l = "life_") {
50
- const s = { ...F, ...e }, n = (c) => l + c, b = s.leaves.map(([c, t], i) => [
51
- f(o, n(`leaf_${i}_0`), 2, 1, [[0, 0, c], [1, 0, t]]),
52
- f(o, n(`leaf_${i}_1`), 2, 2, [[0, 0, c], [1, 1, t]]),
53
- f(o, n(`leaf_${i}_2`), 1, 2, [[0, 0, c], [0, 1, t]])
54
- ]), _ = [
55
- [f(o, n("seed_0"), 1, 1, [[0, 0, s.seed[0]]])],
56
- [f(o, n("seed_1"), 2, 1, [[0, 0, s.seed[0]], [1, 0, s.seed[1]]])]
57
- ], p = [s.ember.map((c, t) => f(o, n(`ember_${t}`), 1, 1, [[0, 0, c]]))], h = s.mote.map((c, t) => [f(o, n(`mote_${t}`), 1, 1, [[0, 0, c]])]), y = s.ash.map(
58
- ([c, t], i) => (
48
+ let B = 0;
49
+ function I(o, b, l) {
50
+ const n = l.filter((f) => !o.exists(f.key));
51
+ if (!n.length) return;
52
+ const { at: c, height: h } = R(n.map((f) => [f.w, f.h])), t = document.createElement("canvas");
53
+ t.width = A, t.height = Math.max(1, h);
54
+ const _ = t.getContext("2d");
55
+ n.forEach((f, m) => {
56
+ const [$, d] = c[m];
57
+ for (const [r, e, y] of f.pixels)
58
+ _.fillStyle = y, _.fillRect($ + r, d + e, 1, 1);
59
+ });
60
+ const p = `${b}page${++B}`;
61
+ o.addCanvas(p, t), n.forEach((f, m) => o.addView(f.key, p, c[m][0], c[m][1], f.w, f.h));
62
+ }
63
+ function W(o, b = {}, l = "life_") {
64
+ const n = { ...M, ...b }, c = (s) => l + s, h = [], t = (s, a, i, S, L) => (h.push({ key: a, w: i, h: S, pixels: L }), a), _ = n.leaves.map(([s, a], i) => [
65
+ t(o, c(`leaf_${i}_0`), 2, 1, [[0, 0, s], [1, 0, a]]),
66
+ t(o, c(`leaf_${i}_1`), 2, 2, [[0, 0, s], [1, 1, a]]),
67
+ t(o, c(`leaf_${i}_2`), 1, 2, [[0, 0, s], [0, 1, a]])
68
+ ]), p = [
69
+ [t(o, c("seed_0"), 1, 1, [[0, 0, n.seed[0]]])],
70
+ [t(o, c("seed_1"), 2, 1, [[0, 0, n.seed[0]], [1, 0, n.seed[1]]])]
71
+ ], f = [n.ember.map((s, a) => t(o, c(`ember_${a}`), 1, 1, [[0, 0, s]]))], m = n.mote.map((s, a) => [t(o, c(`mote_${a}`), 1, 1, [[0, 0, s]])]), $ = n.ash.map(
72
+ ([s, a], i) => (
59
73
  // the first flake flat, the next tumbling on its corner
60
- [f(o, n(`ash_${i}`), 2, i % 2 ? 2 : 1, i % 2 ? [[0, 0, c], [1, 1, t]] : [[0, 0, c], [1, 0, t]])]
74
+ [t(o, c(`ash_${i}`), 2, i % 2 ? 2 : 1, i % 2 ? [[0, 0, s], [1, 1, a]] : [[0, 0, s], [1, 0, a]])]
61
75
  )
62
- ), u = s.butterflyBody, S = s.butterflies.map(([c, t], i) => [
63
- f(o, n(`fly_${i}_o`), 3, 2, [[0, 0, c], [2, 0, c], [1, 0, u], [0, 1, t], [1, 1, u], [2, 1, t]]),
64
- f(o, n(`fly_${i}_c`), 3, 2, [[1, 0, c], [1, 1, t]])
65
- ]), a = s.bird, r = [
66
- f(o, n("bird_0"), 5, 2, [[0, 0, a], [4, 0, a], [1, 1, a], [2, 1, a], [3, 1, a]]),
67
- f(o, n("bird_1"), 5, 2, [[0, 1, a], [1, 0, a], [2, 0, a], [3, 0, a], [4, 1, a]])
68
- ], [$, m] = s.birdShadow, g = f(o, n("bird_shadow"), 3, 1, [[0, 0, m], [1, 0, $], [2, 0, m]]), [w, d] = s.firefly, A = [
69
- f(o, n("firefly_dim"), 3, 3, [[1, 1, d]]),
70
- f(o, n("firefly_lit"), 3, 3, [[1, 1, w], [0, 1, d], [2, 1, d], [1, 0, d], [1, 2, d]])
71
- ], C = [];
72
- for (let c = 0; c < v; c++) {
73
- const { w: t, h: i, px: E } = M(c, s.smoke);
74
- C.push(f(o, n(`puff_${c}`), t, i, E));
76
+ ), d = n.butterflyBody, r = n.butterflies.map(([s, a], i) => [
77
+ t(o, c(`fly_${i}_o`), 3, 2, [[0, 0, s], [2, 0, s], [1, 0, d], [0, 1, a], [1, 1, d], [2, 1, a]]),
78
+ t(o, c(`fly_${i}_c`), 3, 2, [[1, 0, s], [1, 1, a]])
79
+ ]), e = n.bird, y = [
80
+ t(o, c("bird_0"), 5, 2, [[0, 0, e], [4, 0, e], [1, 1, e], [2, 1, e], [3, 1, e]]),
81
+ t(o, c("bird_1"), 5, 2, [[0, 1, e], [1, 0, e], [2, 0, e], [3, 0, e], [4, 1, e]])
82
+ ], [k, g] = n.birdShadow, u = t(o, c("bird_shadow"), 3, 1, [[0, 0, g], [1, 0, k], [2, 0, g]]), [C, w] = n.firefly, F = [
83
+ t(o, c("firefly_dim"), 3, 3, [[1, 1, w]]),
84
+ t(o, c("firefly_lit"), 3, 3, [[1, 1, C], [0, 1, w], [2, 1, w], [1, 0, w], [1, 2, w]])
85
+ ], E = [];
86
+ for (let s = 0; s < v; s++) {
87
+ const { w: a, h: i, px: S } = P(s, n.smoke);
88
+ E.push(t(o, c(`puff_${s}`), a, i, S));
75
89
  }
76
- return { leaves: b, seeds: _, embers: p, motes: h, ash: y, butterflies: S, bird: r, birdShadow: g, firefly: A, puffs: C };
90
+ return I(o, l, h), { leaves: _, seeds: p, embers: f, motes: m, ash: $, butterflies: r, bird: y, birdShadow: u, firefly: F, puffs: E };
77
91
  }
78
92
  export {
79
- F as LIFE_COLORS,
93
+ M as LIFE_COLORS,
80
94
  v as PUFF_FRAMES,
81
- R as paintLifeArt,
82
- M as puffPixels
95
+ R as packShelves,
96
+ W as paintLifeArt,
97
+ P as puffPixels
83
98
  };
@@ -12,6 +12,14 @@ export declare class Group extends Group_base {
12
12
  * frame — a held weapon ordered against its body every frame did it every frame.
13
13
  */
14
14
  moveBelow(child: PixiContainer, other: PixiContainer): this;
15
+ /**
16
+ * Keeps `child` drawn above `other`, anywhere above it: moved (directly above) only when it is below. What a weapon
17
+ * held over its body asks for. `moveAbove` from two pieces each wanting to sit *directly* above the same body (two
18
+ * blades, a fist on a hilt, a load) pushed the other out every frame, and every push rebuilt Pixi's instructions.
19
+ */
20
+ keepAbove(child: PixiContainer, other: PixiContainer): this;
21
+ /** Keeps `child` drawn below `other`, anywhere below it: moved (directly below) only when it is above (`keepAbove`). */
22
+ keepBelow(child: PixiContainer, other: PixiContainer): this;
15
23
  /** Puts `child` directly above `other` in the draw order; already there, it does nothing (see `moveBelow`). */
16
24
  moveAbove(child: PixiContainer, other: PixiContainer): this;
17
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../src/core/Group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;;AAGrE,yFAAyF;AACzF,qBAAa,KAAM,SAAQ,UAAqB;IA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I,GAAG,MAAM,IAAI;IAQpC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAEjD;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAe1B;;;OAGG;IACH,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI;IAI/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAE9C;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI;IAInD,2EAA2E;IAC3E,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC;IAS/D,iIAAiI;IACjI,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI;IASlD,OAAO,IAAI,IAAI;IAUf,OAAO,CAAC,QAAQ;CAWjB"}
@@ -1,4 +1,4 @@
1
- import { CanvasSource, Texture } from 'pixi.js';
1
+ import { CanvasSource, Rectangle, Texture } from 'pixi.js';
2
2
  /** A frame packed on an atlas page (TexturePacker and the like), as `assets/textureAtlas.ts` parses it. */
3
3
  export interface PackedFrame {
4
4
  name: string;
@@ -25,14 +25,23 @@ export interface PackedFrame {
25
25
  y: number;
26
26
  };
27
27
  }
28
- /** A canvas-backed texture with named frames; repaint the canvas, then `refresh()` to upload it. */
28
+ /**
29
+ * A canvas-backed texture with named frames; repaint the canvas, then `refresh()` to upload it. Made with a `view`, it
30
+ * is one rect of another texture's canvas on that texture's own source (`TextureRegistry.addView`): small pieces
31
+ * swapped every few frames then batch together, where a source each made Pixi rebuild its draw instructions at every
32
+ * swap.
33
+ */
29
34
  export declare class CanvasTexture {
30
35
  readonly key: string;
31
36
  readonly canvas: HTMLCanvasElement;
32
37
  readonly frames: Map<string, Texture<import("pixi.js").TextureSource<any>>>;
33
38
  readonly source: CanvasSource;
34
39
  readonly whole: Texture;
35
- constructor(key: string, canvas: HTMLCanvasElement);
40
+ private readonly owned;
41
+ constructor(key: string, canvas: HTMLCanvasElement, view?: {
42
+ source: CanvasSource;
43
+ frame: Rectangle;
44
+ });
36
45
  get width(): number;
37
46
  get height(): number;
38
47
  get context(): CanvasRenderingContext2D;
@@ -82,6 +91,11 @@ export declare class TextureRegistry {
82
91
  canvas: HTMLCanvasElement;
83
92
  frames: readonly PackedFrame[];
84
93
  }[]): CanvasTexture;
94
+ /**
95
+ * Registers `key` as the rect (x, y, w, h) of the texture `page`, on the page's source: shown by `setTexture(key)`
96
+ * like any texture, and batched with every other view of that page. Null when the page is not registered.
97
+ */
98
+ addView(key: string, page: string, x: number, y: number, w: number, h: number): CanvasTexture | null;
85
99
  createCanvas(key: string, width: number, height: number): CanvasTexture;
86
100
  remove(key: string): void;
87
101
  get(key: string, frame?: string | number): Texture;
@@ -1 +1 @@
1
- {"version":3,"file":"TextureRegistry.d.ts","sourceRoot":"","sources":["../../../src/core/TextureRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAa,OAAO,EAAE,MAAM,SAAS,CAAC;AAE3D,2GAA2G;AAC3G,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,uGAAuG;IACvG,IAAI,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAA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AAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAA;KAAE,EAAE,GAAG,aAAa;IAiBrH;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;IASpG,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa;IAOvE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMzB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;IAOlD,OAAO,CAAC,IAAI;CAOb"}
@@ -0,0 +1,6 @@
1
+ import { Container } from 'pixi.js';
2
+ /** Checks `container`'s depth order once a frame (`flushDepthSorts`) instead of at every child's `zIndex` change. */
3
+ export declare function deferDepthSort(container: Container): void;
4
+ /** Sorts each container whose children changed depth, marking its render group changed only if the order did. */
5
+ export declare function flushDepthSorts(): void;
6
+ //# sourceMappingURL=depthSort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depthSort.d.ts","sourceRoot":"","sources":["../../../src/core/depthSort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAyCpC,qHAAqH;AACrH,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAGzD;AAED,iHAAiH;AACjH,wBAAgB,eAAe,IAAI,IAAI,CAqBtC"}
@@ -55,6 +55,14 @@ export declare function puffPixels(frame: number, colors?: readonly [string, str
55
55
  h: number;
56
56
  px: LifePixel[];
57
57
  };
58
+ /**
59
+ * Where each of `sizes` goes on one page `width` wide: left to right, a new row below the tallest of the last when the
60
+ * next does not fit, one clear pixel between pieces (so nothing bleeds into a neighbour). Also the page's height.
61
+ */
62
+ export declare function packShelves(sizes: readonly (readonly [w: number, h: number])[], width?: number): {
63
+ at: [number, number][];
64
+ height: number;
65
+ };
58
66
  /**
59
67
  * Paints the life's art under `prefix` (default `'life_'`) and returns its keys. A key already registered is kept, so
60
68
  * calling it again (every map) costs nothing — and painting other colours needs another prefix.
@@ -1 +1 @@
1
- {"version":3,"file":"lifeArt.d.ts","sourceRoot":"","sources":["../../../src/pixel/lifeArt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAS/D,kDAAkD;AAClD,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEvE,8FAA8F;AAC9F,MAAM,WAAW,UAAU;IACzB,mCAAmC;IACnC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;IAC/C,qEAAqE;IACrE,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,iCAAiC;IACjC,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,iBAAiB;IACjB,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,2CAA2C;IAC3C,GAAG,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;IAC5C,gDAAgD;IAChD,WAAW,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,UAAU,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC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AAO,CAAC,UAAU,CAAM,EAAE,MAAM,SAAU,GAAG,OAAO,CAkDnH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "1681-engine",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "A 2D game engine on PixiJS 8 for any art style: scenes and a fast ECS, a fixed-step loop, asset loading, Tiled maps, sprite animation, input actions, camera follow, audio and deterministic, server-replayable movement, plus Dither, an optional pixel-art module (pixel-perfect effects, dithered lighting).",
5
5
  "type": "module",
6
6
  "types": "./dist/types/index.d.ts",