@johnoscott/isometric-engine 0.15.0 → 0.17.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.
Files changed (78) hide show
  1. package/README.md +3 -1
  2. package/iso-editor.js +230 -193
  3. package/iso-remotion.js +353 -0
  4. package/iso-render.js +184 -147
  5. package/iso-systems.js +183 -146
  6. package/isometric-diagram.js +389 -0
  7. package/js/iso-core/arimo.js +5 -0
  8. package/js/iso-core/arimo.json +1 -0
  9. package/js/iso-core/index.js +8 -2
  10. package/js/iso-core/kernel.js +13 -2
  11. package/js/iso-core/mono.js +242 -0
  12. package/js/iso-editor/ui/canvas.js +23 -1
  13. package/js/iso-objects/ants.js +1 -1
  14. package/js/iso-objects/index.js +10 -2
  15. package/js/iso-objects/mono-paint.js +96 -0
  16. package/js/iso-objects/motion-doc.js +0 -79
  17. package/js/iso-objects/motion-entry.js +4 -2
  18. package/js/iso-objects/motion-schema.js +83 -0
  19. package/js/iso-objects/motion.js +9 -4
  20. package/js/iso-objects/timeline.js +60 -16
  21. package/js/iso-systems/compile.js +34 -3
  22. package/js/iso-systems/render.js +1 -1
  23. package/js/iso-systems/schema.json +1 -0
  24. package/js/iso-viewer/index.js +6 -0
  25. package/js/iso-viewer/page.js +40 -17
  26. package/js/iso-viewer/play.js +340 -0
  27. package/js/iso-viewer/player.js +147 -162
  28. package/js/iso-viewer/transport.js +289 -0
  29. package/package.json +61 -2
  30. package/src/iso-core/arimo.json +1 -0
  31. package/src/iso-core/arimo.ts +6 -0
  32. package/src/iso-core/index.ts +2 -1
  33. package/src/iso-core/kernel.ts +11 -1
  34. package/src/iso-core/mono.ts +306 -0
  35. package/src/iso-core/theme.ts +2 -1
  36. package/src/iso-editor/ui/canvas.ts +14 -1
  37. package/src/iso-objects/ants.ts +2 -2
  38. package/src/iso-objects/index.ts +5 -3
  39. package/src/iso-objects/mono-paint.ts +97 -0
  40. package/src/iso-objects/motion-doc.ts +0 -52
  41. package/src/iso-objects/motion-entry.ts +4 -3
  42. package/src/iso-objects/motion-schema.ts +55 -0
  43. package/src/iso-objects/motion.ts +6 -5
  44. package/src/iso-objects/scene.ts +3 -0
  45. package/src/iso-objects/timeline.ts +71 -15
  46. package/src/iso-objects/types.ts +2 -0
  47. package/src/iso-systems/compile.ts +37 -4
  48. package/src/iso-systems/render.ts +5 -1
  49. package/src/iso-systems/schema.json +1 -0
  50. package/src/iso-viewer/index.ts +4 -0
  51. package/src/iso-viewer/page.ts +28 -12
  52. package/src/iso-viewer/play.ts +280 -0
  53. package/src/iso-viewer/player.ts +133 -134
  54. package/src/iso-viewer/transport.ts +272 -0
  55. package/types/iso-core/arimo.d.ts +2 -0
  56. package/types/iso-core/index.d.ts +2 -1
  57. package/types/iso-core/kernel.d.ts +9 -0
  58. package/types/iso-core/mono.d.ts +61 -0
  59. package/types/iso-core/theme.d.ts +2 -0
  60. package/types/iso-objects/ants.d.ts +1 -0
  61. package/types/iso-objects/index.d.ts +5 -3
  62. package/types/iso-objects/mono-paint.d.ts +20 -0
  63. package/types/iso-objects/motion-doc.d.ts +0 -594
  64. package/types/iso-objects/motion-entry.d.ts +4 -3
  65. package/types/iso-objects/motion-schema.d.ts +594 -0
  66. package/types/iso-objects/motion.d.ts +4 -2
  67. package/types/iso-objects/scene.d.ts +3 -0
  68. package/types/iso-objects/timeline.d.ts +26 -3
  69. package/types/iso-objects/types.d.ts +2 -0
  70. package/types/iso-systems/compile.d.ts +8 -0
  71. package/types/iso-systems/render.d.ts +4 -0
  72. package/types/iso-viewer/index.d.ts +4 -0
  73. package/types/iso-viewer/play.d.ts +37 -0
  74. package/types/iso-viewer/transport.d.ts +73 -0
  75. package/types/player/isometric-diagram.d.ts +24 -0
  76. package/types/remotion/entry.d.ts +2 -0
  77. package/types/remotion/frames.d.ts +70 -0
  78. package/types/remotion/index.d.ts +39 -0
@@ -1,22 +1,16 @@
1
- import { focusView } from "../iso-objects/focus.js";
2
1
  import { paint, planOf } from "../iso-objects/motion.js";
3
- const NS = "http://www.w3.org/2000/svg";
4
- const TRAVEL = 1150;
5
- function svgEl(tag, attrs, parent) {
6
- const e = document.createElementNS(NS, tag);
7
- for (const k in attrs) e.setAttribute(k, String(attrs[k]));
8
- parent.appendChild(e);
9
- return e;
10
- }
2
+ import { bindMotion } from "../iso-objects/timeline.js";
3
+ import { transport } from "./transport.js";
11
4
  const ease = (f) => f < 0.5 ? 2 * f * f : 1 - Math.pow(-2 * f + 2, 2) / 2;
5
+ const none = { ok: true, diags: [], duration: 0, beats: [], markers: {}, ambient: "on", loops: false, at: () => ({}), cues: () => void 0, beatAt: () => void 0, startOf: () => void 0 };
12
6
  function init() {
13
7
  const dataEl = document.getElementById("diagram-steps");
14
8
  if (!dataEl) return;
15
9
  const data = JSON.parse(dataEl.textContent || "{}");
16
10
  const hash = location.hash;
17
11
  const still = /still/.test(hash);
18
- const reduceMedia = matchMedia("(prefers-reduced-motion: reduce)").matches && !/motion/.test(hash);
19
- const reduce = still || reduceMedia;
12
+ const asked = matchMedia("(prefers-reduced-motion: reduce)").matches && !still && !/motion/.test(hash);
13
+ let reduce = still;
20
14
  const frozenT = Math.max(0, Math.min(1, Number((/[#&]t=([\d.]+)/.exec(hash) || [])[1] ?? 0.6)));
21
15
  const wantScene = (/[#&]scene=([\w-]+)/.exec(hash) || [])[1];
22
16
  const wantStep = Number((/[#&]step=?(\d+)/.exec(hash) || [])[1] || 0);
@@ -26,6 +20,7 @@ function init() {
26
20
  if (still) document.documentElement.classList.add("still");
27
21
  if (wantScene && !still) document.getElementById("scene-" + wantScene)?.scrollIntoView({ block: "start" });
28
22
  const runners = [];
23
+ const offBtns = [];
29
24
  for (const sd of data.scenes) {
30
25
  const sec = document.getElementById("scene-" + sd.id);
31
26
  if (sec) runners.push(makeRunner(sec, sd));
@@ -33,7 +28,6 @@ function init() {
33
28
  function makeRunner(sec, sd) {
34
29
  const STEPS = sd.steps, N = STEPS.length;
35
30
  const svg = sec.querySelector("svg"), fig = sec.querySelector(".figure");
36
- const anim = svg.querySelector(".g-anim");
37
31
  const q = (s) => sec.querySelector(s);
38
32
  const num = q(".cap-h .num"), hEl = q(".cap-h .h"), cnt = q(".cap-h .cnt");
39
33
  const capT = q(".cap-t"), capC = q(".cap-c"), prog = q(".prog i"), dots = q(".dots");
@@ -56,11 +50,12 @@ function init() {
56
50
  visEls.set(id, l);
57
51
  }
58
52
  }
59
- const flowPath = (id) => svg.querySelector(`[data-hl="${CSS.escape(id)}"] path.flow`);
60
53
  if (sd.dim === "all") svg.classList.add("dim-all");
61
- let cur = 0, playing = false, userPaused = false, active = false, timer = 0, raf = 0, groups = 0, t0 = 0;
62
- let assembling = false, assembled = false, introTimer = 0, introDone;
63
- let tokens = [];
54
+ const bound = sd.doc ? bindMotion(sd.source, sd.doc) : none, tl = bound.ok ? bound : none;
55
+ const tr = transport(tl, { loop: sd.loop });
56
+ tr.active = false;
57
+ let cur = 0, userPaused = false, active = false, stepping = false;
58
+ let assembling = false, assembled = false;
64
59
  const setGrid = (on) => {
65
60
  svg.classList.toggle("show-grid", on);
66
61
  gridBtn?.setAttribute("aria-pressed", String(on));
@@ -75,72 +70,58 @@ function init() {
75
70
  b.addEventListener("click", () => {
76
71
  userPause();
77
72
  finishAssemble();
78
- show(i);
73
+ show(i, true);
79
74
  });
80
75
  dots?.appendChild(b);
81
76
  });
82
- function clearAnim() {
83
- anim.textContent = "";
84
- tokens = [];
85
- if (raf) cancelAnimationFrame(raf);
86
- raf = 0;
87
- }
88
- function tick(now) {
89
- const per = TRAVEL * groups + 700, tt = (now - t0) % per;
90
- for (const tk of tokens) {
91
- const f = reduce ? frozenT : Math.max(0, Math.min(1, (tt - tk.gi * TRAVEL) / TRAVEL));
92
- let e = ease(f);
93
- if (tk.stop) e = f < 0.7 ? f / 0.7 : 1 - (f - 0.7) / 0.3 * 0.25;
94
- const p = tk.path.getPointAtLength(Math.max(0, Math.min(1, e)) * tk.len);
95
- tk.c.setAttribute("cx", String(p.x));
96
- tk.c.setAttribute("cy", String(p.y));
97
- tk.c.style.opacity = reduce ? "1" : f <= 0 || f >= 1 ? "0" : "1";
98
- }
99
- if (!reduce && active) raf = requestAnimationFrame(tick);
77
+ const inkOf = new Map(STEPS.flatMap((s) => s.phases.flat().map((t) => [t.kind, t.color])));
78
+ function drawn() {
79
+ const S = reduce ? frozen() : tr.state(), s = STEPS[cur];
80
+ if (sd.own || !s) return S;
81
+ const out = {};
82
+ if (S.camera && !svg.classList.contains("all")) out.camera = S.camera;
83
+ if (S.tokens) out.tokens = S.tokens.map((k) => ({ ...k, color: k.color ?? (k.kind === void 0 ? void 0 : inkOf.get(k.kind)) }));
84
+ if (reduce) {
85
+ if (s.pulses.length) out.pulses = s.pulses.map(([x, y, rx, ry]) => ({ x, y, rx, ry, opacity: 0.85, color: s.color }));
86
+ } else if (S.pulses) out.pulses = s.pulses.flatMap(([x, y, rx, ry], k) => {
87
+ const p = S.pulses[k];
88
+ if (!p) return [];
89
+ const f = 1 - Math.pow(p.opacity ?? 1, 2), z = 0.35 + 1.15 * f;
90
+ return [{ x, y, rx: rx * z, ry: ry * z, opacity: 0.95 * (1 - f), color: s.color }];
91
+ });
92
+ return out;
100
93
  }
101
- const FULL = svg.getAttribute("viewBox").split(/\s+/).map(Number);
102
- let view = FULL.slice(), zoomTimer = 0;
103
- const viewFor = (s) => focusView(FULL, s.focus);
104
- function zoomTo(target) {
105
- clearTimeout(zoomTimer);
106
- if (target.every((v, k) => Math.abs(v - view[k]) < 0.5)) return;
107
- const from = view.slice(), t0z = performance.now(), D = reduce ? 0 : 900;
108
- const step = () => {
109
- const f = D ? Math.min(1, (performance.now() - t0z) / D) : 1, e = ease(f);
110
- view = from.map((v, k) => v + (target[k] - v) * e);
111
- svg.setAttribute("viewBox", view.map((v) => v.toFixed(1)).join(" "));
112
- if (f < 1) zoomTimer = window.setTimeout(step, 16);
113
- };
114
- step();
94
+ function frozen() {
95
+ const s = STEPS[cur], b = tl.beats[cur];
96
+ if (!s || !b) return {};
97
+ const S = tl.at(Math.max(b.start, b.end - 1), { ambient: "off" });
98
+ if (sd.own) return S;
99
+ const at = (kind) => kind === "blocked" ? frozenT < 0.7 ? frozenT / 0.7 : 1 - (frozenT - 0.7) / 0.3 * 0.25 : ease(frozenT);
100
+ return { ...S.camera ? { camera: S.camera } : {}, tokens: s.phases.flat().map((t) => ({ route: t.route, at: at(t.kind), kind: t.kind })) };
115
101
  }
116
- function show(i) {
117
- if (!N) return;
118
- clearAnim();
119
- cur = i;
102
+ const draw = () => {
103
+ if (assembling) return;
104
+ paint(svg, drawn());
105
+ if (prog && N) prog.style.width = (going() ? (tl.cues(tr.time)?.progress ?? 0) * 100 : (cur + 1) / N * 100) + "%";
106
+ };
107
+ const going = () => tr.playing && !stepping;
108
+ function look(i) {
120
109
  const s = STEPS[i], n = s.n;
121
- zoomTo(svg.classList.contains("all") ? FULL : viewFor(s));
110
+ cur = i;
122
111
  const lit = new Set(s.lit);
123
- svg.classList.add("focus");
124
- for (const e of hlEls) e.classList.toggle("hl", e.dataset.hl.split(" ").some((x) => lit.has(x)));
125
- if (sd.dim === "all") {
126
- for (const e of idEls) if (e.hasAttribute("data-dim")) e.classList.toggle("hl", lit.has(e.dataset.id));
112
+ if (!sd.own) {
113
+ svg.classList.add("focus");
114
+ for (const e of hlEls) e.classList.toggle("hl", e.dataset.hl.split(" ").some((x) => lit.has(x)));
115
+ if (sd.dim === "all") {
116
+ for (const e of idEls) if (e.hasAttribute("data-dim")) e.classList.toggle("hl", lit.has(e.dataset.id));
117
+ }
118
+ for (const [id, els] of visEls) {
119
+ const v = sd.vis[id][i];
120
+ for (const e of els) e.classList.toggle("pre", !v);
121
+ }
127
122
  }
128
123
  for (const e of stepEls) e.classList.toggle("on", e.dataset.step === String(n));
129
124
  svg.querySelectorAll("[data-badge]").forEach((b) => b.classList.toggle("on", b.dataset.badge === String(n)));
130
- for (const [id, els] of visEls) {
131
- const v = sd.vis[id][i];
132
- for (const e of els) e.classList.toggle("pre", !v);
133
- }
134
- for (const [x, y, rx, ry] of s.pulses) svgEl("ellipse", { cx: x, cy: y, rx, ry, class: "pulse", style: `stroke:${s.color}` }, anim);
135
- groups = s.phases.length;
136
- s.phases.forEach((ph, gi) => ph.forEach((tk) => {
137
- const path = flowPath(tk.route);
138
- if (!path) return;
139
- tokens.push({ path, len: path.getTotalLength(), gi, stop: tk.kind === "blocked", c: svgEl("circle", { r: 7, class: "tok", style: `fill:${tk.color}` }, anim) });
140
- }));
141
- t0 = performance.now();
142
- tick(t0);
143
- if (!reduce && active && !raf) raf = requestAnimationFrame(tick);
144
125
  num.textContent = String(s.num);
145
126
  num.style.background = s.color;
146
127
  hEl.textContent = s.heading;
@@ -152,89 +133,84 @@ function init() {
152
133
  d.classList.toggle("on", j === i);
153
134
  d.classList.toggle("done", j < i);
154
135
  });
155
- restartProg();
156
136
  }
157
- function restartProg() {
158
- if (!prog) return;
159
- prog.style.transition = "none";
160
- prog.style.width = playing ? "0%" : (cur + 1) / N * 100 + "%";
161
- if (playing) {
162
- void prog.offsetWidth;
163
- prog.style.transition = `width ${STEPS[cur].duration}ms linear`;
164
- prog.style.width = "100%";
137
+ function show(i, through = false) {
138
+ const b = tl.beats[i];
139
+ if (!N || !b) return;
140
+ tr.pause();
141
+ look(i);
142
+ tr.seek(b.start, { join: true });
143
+ if (through && !reduce && active) {
144
+ stepping = true;
145
+ tr.play({ until: Math.max(b.start + 1, b.end - 1) });
146
+ setBtn();
165
147
  }
166
- }
167
- function schedule() {
168
- clearTimeout(timer);
169
- if (!playing) return;
170
- timer = window.setTimeout(() => {
171
- if (cur === N - 1 && !sd.loop) {
172
- stop();
173
- return;
174
- }
175
- show((cur + 1) % N);
176
- schedule();
177
- }, STEPS[cur].duration);
148
+ draw();
178
149
  }
179
150
  function setBtn() {
180
151
  if (!playBtn) return;
181
- playBtn.textContent = playing ? "\u275A\u275A Pause" : "\u25B6 Play";
182
- playBtn.setAttribute("aria-label", playing ? "Pause" : "Play");
183
- capBox?.setAttribute("aria-live", playing ? "off" : "polite");
152
+ playBtn.disabled = reduce;
153
+ if (reduce) {
154
+ playBtn.textContent = "Motion off";
155
+ return;
156
+ }
157
+ const on = going();
158
+ playBtn.textContent = on ? "\u275A\u275A Pause" : "\u25B6 Play";
159
+ playBtn.setAttribute("aria-label", on ? "Pause" : "Play");
160
+ capBox?.setAttribute("aria-live", on ? "off" : "polite");
184
161
  }
185
162
  function play() {
186
163
  if (reduce || !N || assembling) return;
187
- playing = true;
164
+ if (stepping) tr.pause();
165
+ stepping = false;
166
+ tr.play();
188
167
  setBtn();
189
- restartProg();
190
- schedule();
168
+ draw();
191
169
  }
192
170
  function stop() {
193
- playing = false;
194
- clearTimeout(timer);
195
- setBtn();
196
- restartProg();
171
+ tr.pause();
197
172
  }
198
173
  function userPause() {
199
174
  userPaused = true;
200
175
  stop();
201
176
  }
202
- const plan = planOf(sd.motion, "assemble");
177
+ tr.on("time", draw);
178
+ tr.on("beat", (b) => {
179
+ if (b.index !== cur) look(b.index);
180
+ });
181
+ tr.on("pause", () => {
182
+ stepping = false;
183
+ setBtn();
184
+ draw();
185
+ });
186
+ const plan = planOf(sd.source.model, "assemble");
187
+ let intro;
203
188
  function finishAssemble() {
204
- if (assembling) introDone?.();
189
+ if (!assembling || !intro) return;
190
+ intro.dispose();
191
+ intro = void 0;
192
+ assembling = false;
193
+ assembled = true;
194
+ paint(svg, {});
195
+ if (N) show(cur);
196
+ if (active && !userPaused) play();
205
197
  }
206
198
  function assemble(freezeAt) {
207
- clearTimeout(introTimer);
208
- introDone = void 0;
199
+ intro?.dispose();
200
+ intro = void 0;
209
201
  stop();
210
202
  if (N) show(cur);
211
- clearAnim();
212
203
  svg.classList.remove("focus", "pre-assemble", "all");
213
204
  assembling = true;
214
205
  if (freezeAt !== void 0) {
215
206
  paint(svg, plan.at(freezeAt));
216
207
  return;
217
208
  }
218
- const start = performance.now();
219
- introDone = () => {
220
- clearTimeout(introTimer);
221
- introDone = void 0;
222
- paint(svg, {});
223
- assembling = false;
224
- assembled = true;
225
- if (N) show(cur);
226
- if (active && !userPaused) play();
227
- };
228
- const step = () => {
229
- const t = performance.now() - start;
230
- if (t >= plan.duration) {
231
- introDone?.();
232
- return;
233
- }
234
- paint(svg, plan.at(t));
235
- introTimer = window.setTimeout(step, 16);
236
- };
237
- step();
209
+ const run = intro = transport({ ...none, duration: plan.duration, at: (t) => plan.at(t) });
210
+ run.on("time", (t) => paint(svg, plan.at(t)));
211
+ run.on("end", finishAssemble);
212
+ paint(svg, plan.at(0));
213
+ run.play();
238
214
  }
239
215
  asmBtn?.addEventListener("click", () => {
240
216
  userPaused = false;
@@ -243,36 +219,29 @@ function init() {
243
219
  function setActive(on) {
244
220
  if (on === active) return;
245
221
  active = on;
222
+ tr.active = on && !reduce;
246
223
  if (on) {
247
- if (!reduce) {
248
- t0 = performance.now();
249
- raf = requestAnimationFrame(tick);
250
- }
251
224
  if (!userPaused) play();
252
- } else {
253
- stop();
254
- if (raf) cancelAnimationFrame(raf);
255
- raf = 0;
256
- }
225
+ } else stop();
257
226
  }
258
227
  playBtn?.addEventListener("click", () => {
259
- if (playing) userPause();
228
+ if (going()) userPause();
260
229
  else {
261
230
  userPaused = false;
262
231
  finishAssemble();
263
- if (cur === N - 1) show(0);
232
+ if (cur === N - 1 && !going()) show(0);
264
233
  play();
265
234
  }
266
235
  });
267
236
  q("[data-a=next]")?.addEventListener("click", () => {
268
237
  userPause();
269
238
  finishAssemble();
270
- show(Math.min(N - 1, cur + 1));
239
+ show(Math.min(N - 1, cur + 1), true);
271
240
  });
272
241
  q("[data-a=prev]")?.addEventListener("click", () => {
273
242
  userPause();
274
243
  finishAssemble();
275
- show(Math.max(0, cur - 1));
244
+ show(Math.max(0, cur - 1), true);
276
245
  });
277
246
  fig.addEventListener("keydown", (e) => {
278
247
  const k = e.key;
@@ -281,20 +250,20 @@ function init() {
281
250
  e.preventDefault();
282
251
  userPause();
283
252
  finishAssemble();
284
- show(Math.min(N - 1, cur + 1));
253
+ show(Math.min(N - 1, cur + 1), true);
285
254
  }
286
255
  if (k === "ArrowLeft") {
287
256
  e.preventDefault();
288
257
  userPause();
289
258
  finishAssemble();
290
- show(Math.max(0, cur - 1));
259
+ show(Math.max(0, cur - 1), true);
291
260
  }
292
261
  });
293
262
  svg.querySelectorAll(".badge").forEach((b) => {
294
263
  const go = () => {
295
264
  userPause();
296
265
  finishAssemble();
297
- show(Number(b.dataset.go) - 1);
266
+ show(Number(b.dataset.go) - 1, true);
298
267
  };
299
268
  b.addEventListener("click", go);
300
269
  b.addEventListener("keydown", (e) => {
@@ -307,23 +276,39 @@ function init() {
307
276
  });
308
277
  const forced = wantStep && (!wantScene || wantScene === sd.id) ? Math.min(N, wantStep) - 1 : -1;
309
278
  const frozenAssemble = wantAssemble && assembleAt !== void 0 && (!wantScene || wantScene === sd.id);
310
- if (reduce && forced < 0 && !still && !frozenAssemble) {
311
- if (N) {
312
- svg.classList.add("all");
313
- show(N - 1);
314
- }
315
- if (playBtn) {
316
- playBtn.disabled = true;
317
- playBtn.textContent = "Motion off";
318
- }
319
- if (asmBtn) asmBtn.disabled = true;
320
- sec.querySelector("details.steps")?.setAttribute("open", "");
321
- } else {
322
- if (N) show(forced >= 0 ? forced : 0);
323
- if (reduce && playBtn) {
324
- playBtn.disabled = true;
325
- playBtn.textContent = "Motion off";
279
+ if (N) show(forced >= 0 ? forced : 0);
280
+ setBtn();
281
+ function setMotion() {
282
+ svg.classList.remove("pre-assemble");
283
+ if (reduce) {
284
+ assembled = true;
285
+ finishAssemble();
286
+ stop();
326
287
  }
288
+ svg.classList.toggle("all", reduce && N > 0);
289
+ tr.active = active && !reduce;
290
+ if (asmBtn) asmBtn.disabled = reduce;
291
+ if (reduce) sec.querySelector("details.steps")?.setAttribute("open", "");
292
+ if (N) show(reduce ? N - 1 : 0);
293
+ setBtn();
294
+ if (!reduce && active && !userPaused) play();
295
+ }
296
+ const tools = q(".tools");
297
+ if (asked && tools) {
298
+ const b = document.createElement("button");
299
+ b.type = "button";
300
+ b.className = "pbtn small";
301
+ b.dataset.a = "motion";
302
+ b.textContent = "Motion off";
303
+ b.title = "Draw everything in place, with nothing moving";
304
+ b.setAttribute("aria-pressed", "false");
305
+ b.addEventListener("click", () => {
306
+ reduce = !reduce;
307
+ for (const x of offBtns) x.setAttribute("aria-pressed", String(reduce));
308
+ for (const r of runners) r.setMotion();
309
+ });
310
+ offBtns.push(b);
311
+ tools.appendChild(b);
327
312
  }
328
313
  if (frozenAssemble) assemble(Number(assembleAt));
329
314
  else if ((sd.assemble || wantAssemble) && !reduce && !window.__diagramNoIntro) {
@@ -353,9 +338,9 @@ function init() {
353
338
  addEventListener("scroll", check, { passive: true });
354
339
  setTimeout(check, 60);
355
340
  }
356
- return { fig, setActive };
341
+ return { fig, setActive, setMotion };
357
342
  }
358
- if (!reduce) {
343
+ if (!still) {
359
344
  const ratio = /* @__PURE__ */ new Map();
360
345
  const pick = () => {
361
346
  let best, br = 0;