agentcut 0.2.3 → 0.2.5

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 (35) hide show
  1. package/dist/studio/tools.js +17 -2
  2. package/dist/studio/tools.js.map +1 -1
  3. package/dist/studio/workspace.js +4 -0
  4. package/dist/studio/workspace.js.map +1 -1
  5. package/package.json +1 -1
  6. package/template/components/CATALOG.md +52 -0
  7. package/template/components/README.md +70 -61
  8. package/template/components/STYLES.md +2 -0
  9. package/template/components/catalog.json +477 -0
  10. package/template/components/catalog.ts +4 -0
  11. package/template/components/cinematic/Cinematic.tsx +1139 -0
  12. package/template/components/cinematic/Device3D.tsx +299 -0
  13. package/template/components/cinematic/devices3d/display-model.ts +184 -0
  14. package/template/components/cinematic/devices3d/iphone-model.ts +643 -0
  15. package/template/components/cinematic/devices3d/macbook-model.ts +553 -0
  16. package/template/components/cinematic/devices3d/models.ts +612 -0
  17. package/template/components/cinematic/devices3d/runtime.ts +258 -0
  18. package/template/components/cinematic/math.ts +100 -0
  19. package/template/components/dot-trace-title/DotTraceTitle.tsx +181 -0
  20. package/template/components/dot-trace-title/meta.json +51 -0
  21. package/template/components/generate/GenerateReveal.tsx +381 -0
  22. package/template/components/index.ts +36 -0
  23. package/template/components/lib.ts +18 -6
  24. package/template/components/loops/LoopCanvas.tsx +132 -0
  25. package/template/components/loops/engine.ts +184 -0
  26. package/template/components/loops/library.ts +667 -0
  27. package/template/components/loops/library2.ts +777 -0
  28. package/template/components/motion-loop/MotionLoop.tsx +37 -0
  29. package/template/components/motion-loop/meta.json +312 -0
  30. package/template/runtime/composition.tsx +927 -920
  31. package/template/skill/SKILL.md +20 -3
  32. package/template/skill/references/browser-export.md +61 -61
  33. package/template/skill/references/cinematic.md +171 -0
  34. package/template/skill/references/loops.md +151 -0
  35. package/template/skill/references/performance.md +81 -0
@@ -0,0 +1,777 @@
1
+ // More seamless loops: symmetry, shape morphing, little games, physics and generative pieces.
2
+ // Same contract as library.ts: a pure function of t, every period divides 12 s, colours from P.
3
+ import type { LoopDef, LoopDraw, LoopPalette } from "./engine";
4
+
5
+ const second = (P: LoopPalette) => (P.tone === "accent" ? P.paper : P.fg2);
6
+
7
+ // ─── Symmetry ────────────────────────────────────────────────────────────────────────────────────
8
+
9
+ /** Draw `paint` in one wedge, then rotate (and mirror) it n times around (cx, cy). */
10
+ function symmetric(ctx: CanvasRenderingContext2D, cx: number, cy: number, n: number, mirror: boolean, paint: () => void) {
11
+ for (let k = 0; k < n; k++) {
12
+ for (const flip of mirror ? [1, -1] : [1]) {
13
+ ctx.save();
14
+ ctx.translate(cx, cy);
15
+ ctx.rotate((k * Math.PI * 2) / n);
16
+ ctx.scale(1, flip);
17
+ paint();
18
+ ctx.restore();
19
+ }
20
+ }
21
+ }
22
+
23
+ const kaleidoscope: LoopDraw = (ctx, w, h, t, P, M, seed) => {
24
+ const u = h / 100;
25
+ const R = Math.hypot(w, h) / 2;
26
+ const cols = [P.fg, second(P), P.mid, M.mixColor(P.fg, P.paper, 0.4)];
27
+ symmetric(ctx, w / 2, h / 2, 8, true, () => {
28
+ for (let i = 0; i < 14; i++) {
29
+ // Each piece drifts out from the center and wraps: whole cycles per 12 s.
30
+ const life = M.phase(t, [3, 4, 6][i % 3], M.rand(i, seed + 1));
31
+ const r = life * R;
32
+ const a = M.rand(i, seed + 2) * (Math.PI / 8) + Math.sin(M.TAU * M.phase(t, 6) + i) * 0.04;
33
+ const size = u * (1.5 + 5 * M.rand(i, seed + 3)) * (0.4 + life);
34
+ ctx.fillStyle = M.rgba(cols[i % cols.length], Math.sin(Math.PI * life));
35
+ ctx.save();
36
+ ctx.translate(Math.cos(a) * r, Math.sin(a) * r);
37
+ ctx.rotate(M.TAU * M.phase(t, 4) + i);
38
+ if (i % 3 === 0) {
39
+ ctx.beginPath();
40
+ ctx.arc(0, 0, size, 0, M.TAU);
41
+ ctx.fill();
42
+ } else if (i % 3 === 1) ctx.fillRect(-size, -size * 0.4, size * 2, size * 0.8);
43
+ else {
44
+ ctx.beginPath();
45
+ ctx.moveTo(0, -size);
46
+ ctx.lineTo(size * 0.9, size * 0.6);
47
+ ctx.lineTo(-size * 0.9, size * 0.6);
48
+ ctx.closePath();
49
+ ctx.fill();
50
+ }
51
+ ctx.restore();
52
+ }
53
+ });
54
+ };
55
+
56
+ const mandalaBloom: LoopDraw = (ctx, w, h, t, P, M) => {
57
+ const s = Math.min(w, h) / 100;
58
+ const rings = [
59
+ { n: 6, r: 9, len: 9, dir: 1, c: P.fg },
60
+ { n: 12, r: 19, len: 8, dir: -1, c: second(P) },
61
+ { n: 18, r: 29, len: 7, dir: 1, c: P.mid },
62
+ { n: 24, r: 38, len: 5, dir: -1, c: P.fg },
63
+ ];
64
+ rings.forEach((ring, i) => {
65
+ const breathe = 1 + 0.12 * Math.sin(M.TAU * M.phase(t, 3, i * 0.15));
66
+ // One petal step per 3 s: the ring looks identical after each step.
67
+ const step = (M.TAU / ring.n) * ring.dir * (Math.floor(t / 3) + M.ease.inOutCubic(M.win(M.phase(t, 3), 0.2, 0.8)));
68
+ for (let k = 0; k < ring.n; k++) {
69
+ const a = step + (k * M.TAU) / ring.n;
70
+ ctx.save();
71
+ ctx.translate(w / 2 + Math.cos(a) * ring.r * s * breathe, h / 2 + Math.sin(a) * ring.r * s * breathe);
72
+ ctx.rotate(a);
73
+ ctx.fillStyle = ring.c;
74
+ ctx.beginPath();
75
+ ctx.ellipse(0, 0, ring.len * s * 0.55, ring.len * s * 0.22, 0, 0, M.TAU);
76
+ ctx.fill();
77
+ ctx.restore();
78
+ }
79
+ });
80
+ ctx.fillStyle = P.paper;
81
+ ctx.beginPath();
82
+ ctx.arc(w / 2, h / 2, s * (4 + Math.sin(M.TAU * M.phase(t, 1.5))), 0, M.TAU);
83
+ ctx.fill();
84
+ };
85
+
86
+ const spirograph: LoopDraw = (ctx, w, h, t, P, M) => {
87
+ const s = Math.min(w, h) / 100;
88
+ const R = 30;
89
+ const r = 11.25; // R / r = 8/3: the curve closes after 3 turns
90
+ const d = 16;
91
+ const point = (a: number) => ({
92
+ x: w / 2 + ((R - r) * Math.cos(a) + d * Math.cos(((R - r) / r) * a)) * s,
93
+ y: h / 2 + ((R - r) * Math.sin(a) - d * Math.sin(((R - r) / r) * a)) * s,
94
+ });
95
+ const total = M.TAU * 3;
96
+ const head = M.phase(t, 6) * total;
97
+ const tail = total * 0.55;
98
+ ctx.lineCap = "round";
99
+ ctx.lineJoin = "round";
100
+ // Faint full curve, then a bright trail that sweeps around it.
101
+ ctx.strokeStyle = M.rgba(P.mid, 0.5);
102
+ ctx.lineWidth = s * 0.3;
103
+ ctx.beginPath();
104
+ for (let i = 0; i <= 600; i++) {
105
+ const p = point((i / 600) * total);
106
+ if (i) ctx.lineTo(p.x, p.y);
107
+ else ctx.moveTo(p.x, p.y);
108
+ }
109
+ ctx.stroke();
110
+ const steps = 240;
111
+ for (let i = 0; i < steps; i++) {
112
+ const a0 = head - tail + (i / steps) * tail;
113
+ const a1 = head - tail + ((i + 1) / steps) * tail;
114
+ const p0 = point(a0);
115
+ const p1 = point(a1);
116
+ const k = i / steps;
117
+ ctx.strokeStyle = M.rgba(M.mixColor(second(P), P.fg, k), k);
118
+ ctx.lineWidth = s * (0.3 + 0.9 * k);
119
+ ctx.beginPath();
120
+ ctx.moveTo(p0.x, p0.y);
121
+ ctx.lineTo(p1.x, p1.y);
122
+ ctx.stroke();
123
+ }
124
+ const p = point(head);
125
+ ctx.fillStyle = P.fg;
126
+ ctx.beginPath();
127
+ ctx.arc(p.x, p.y, s * 1.6, 0, M.TAU);
128
+ ctx.fill();
129
+ };
130
+
131
+ const mirrorTiles: LoopDraw = (ctx, w, h, t, P, M) => {
132
+ const cols = 16;
133
+ const s = w / cols;
134
+ const rows = Math.ceil(h / s);
135
+ ctx.lineCap = "round";
136
+ for (let j = 0; j < rows; j++) {
137
+ for (let i = 0; i < cols; i++) {
138
+ // Mirror the tile orientation around the frame's center lines (four-way symmetry).
139
+ const mi = Math.min(i, cols - 1 - i);
140
+ const mj = Math.min(j, rows - 1 - j);
141
+ // Count turns on the tile's own (offset) clock, so 12 s is exactly two quarter turns everywhere.
142
+ const q = t / 6 - (mi + mj) * 0.04;
143
+ const turn = Math.floor(q) + M.ease.inOutCubic(M.win(M.fract(q), 0.1, 0.4));
144
+ const flipX = i >= cols / 2 ? -1 : 1;
145
+ const flipY = j >= rows / 2 ? -1 : 1;
146
+ ctx.save();
147
+ ctx.translate((i + 0.5) * s, (j + 0.5) * s);
148
+ ctx.scale(flipX, flipY);
149
+ ctx.rotate((turn * Math.PI) / 2);
150
+ ctx.strokeStyle = (mi + mj) % 3 === 0 ? second(P) : P.fg;
151
+ ctx.lineWidth = s * 0.14;
152
+ ctx.beginPath();
153
+ ctx.arc(-s / 2, -s / 2, s / 2, 0, Math.PI / 2);
154
+ ctx.stroke();
155
+ ctx.beginPath();
156
+ ctx.arc(s / 2, s / 2, s / 2, Math.PI, Math.PI * 1.5);
157
+ ctx.stroke();
158
+ ctx.restore();
159
+ }
160
+ }
161
+ };
162
+
163
+ const radialBurst: LoopDraw = (ctx, w, h, t, P, M) => {
164
+ const R = Math.hypot(w, h);
165
+ const n = 24;
166
+ // Two rays per 3 s: the alternating pattern lines up again each cycle.
167
+ const rot = ((M.TAU * 2) / n) * (t / 3);
168
+ for (let k = 0; k < n; k++) {
169
+ const a = rot + (k * M.TAU) / n;
170
+ ctx.fillStyle = k % 2 ? P.mid : M.rgba(P.fg, 0.9);
171
+ ctx.beginPath();
172
+ ctx.moveTo(w / 2, h / 2);
173
+ ctx.arc(w / 2, h / 2, R, a, a + M.TAU / n);
174
+ ctx.closePath();
175
+ ctx.fill();
176
+ }
177
+ const p = M.phase(t, 1.5);
178
+ const s = Math.min(w, h) / 100;
179
+ const pop = 1 + 0.18 * M.ease.outBack(M.win(p, 0, 0.3)) * (1 - M.win(p, 0.5, 1));
180
+ ctx.fillStyle = second(P);
181
+ ctx.beginPath();
182
+ ctx.arc(w / 2, h / 2, s * 13 * pop, 0, M.TAU);
183
+ ctx.fill();
184
+ ctx.fillStyle = P.bg;
185
+ ctx.beginPath();
186
+ ctx.arc(w / 2, h / 2, s * 8 * pop, 0, M.TAU);
187
+ ctx.fill();
188
+ };
189
+
190
+ // ─── Morphing ────────────────────────────────────────────────────────────────────────────────────
191
+
192
+ const N = 96;
193
+
194
+ /** A unit shape (radius 1) sampled at N angles, so any two shapes can be interpolated point by point. */
195
+ function polygon(sides: number, rot = -Math.PI / 2, inner = 1): [number, number][] {
196
+ const out: [number, number][] = [];
197
+ const corners: [number, number][] = [];
198
+ const count = inner < 1 ? sides * 2 : sides;
199
+ for (let k = 0; k < count; k++) {
200
+ const a = rot + (k * Math.PI * 2) / count;
201
+ const r = inner < 1 && k % 2 ? inner : 1;
202
+ corners.push([Math.cos(a) * r, Math.sin(a) * r]);
203
+ }
204
+ for (let i = 0; i < N; i++) {
205
+ const f = (i / N) * count;
206
+ const k = Math.floor(f);
207
+ const a = corners[k % count];
208
+ const b = corners[(k + 1) % count];
209
+ const e = f - k;
210
+ out.push([a[0] + (b[0] - a[0]) * e, a[1] + (b[1] - a[1]) * e]);
211
+ }
212
+ return out;
213
+ }
214
+
215
+ const circle = (): [number, number][] =>
216
+ Array.from({ length: N }, (_, i) => {
217
+ const a = -Math.PI / 2 + (i / N) * Math.PI * 2;
218
+ return [Math.cos(a), Math.sin(a)] as [number, number];
219
+ });
220
+
221
+ const SHAPES = [circle(), polygon(4, -Math.PI / 4), polygon(3), polygon(5, -Math.PI / 2, 0.45), polygon(6)];
222
+ // Squares and triangles look smaller than circles at the same radius: scale for equal visual weight.
223
+ const WEIGHT = [1, 1.12, 1.25, 1.18, 1.04];
224
+
225
+ function drawMorph(ctx: CanvasRenderingContext2D, x: number, y: number, r: number, a: number, b: number, k: number, rot: number) {
226
+ const A = SHAPES[a];
227
+ const B = SHAPES[b];
228
+ const wa = WEIGHT[a] + (WEIGHT[b] - WEIGHT[a]) * k;
229
+ ctx.beginPath();
230
+ for (let i = 0; i < N; i++) {
231
+ const px = (A[i][0] + (B[i][0] - A[i][0]) * k) * r * wa;
232
+ const py = (A[i][1] + (B[i][1] - A[i][1]) * k) * r * wa;
233
+ const c = Math.cos(rot);
234
+ const s = Math.sin(rot);
235
+ const X = x + px * c - py * s;
236
+ const Y = y + px * s + py * c;
237
+ if (i) ctx.lineTo(X, Y);
238
+ else ctx.moveTo(X, Y);
239
+ }
240
+ ctx.closePath();
241
+ }
242
+
243
+ const shapeMorph: LoopDraw = (ctx, w, h, t, P, M) => {
244
+ const s = Math.min(w, h) / 100;
245
+ // Five shapes, 2.4 s each would not divide 12: use 4 morphs of 3 s through a closed cycle of 4 shapes.
246
+ const order = [0, 1, 2, 3];
247
+ const step = Math.floor(t / 3) % order.length;
248
+ const p = M.phase(t, 3);
249
+ const k = M.ease.spring(M.win(p, 0.45, 0.85), 0.42, 2.2);
250
+ const a = order[step];
251
+ const b = order[(step + 1) % order.length];
252
+ const squash = 1 - 0.1 * Math.sin(Math.PI * M.win(p, 0.3, 0.5));
253
+ const rot = (Math.PI / 2) * (step + M.ease.inOutCubic(M.win(p, 0.45, 0.85)));
254
+ const colors = [P.fg, second(P), P.fg, M.mixColor(P.fg, second(P), 0.5)];
255
+ ctx.fillStyle = M.mixColor(colors[step], colors[(step + 1) % colors.length], M.clamp(k));
256
+ ctx.save();
257
+ ctx.translate(w / 2, h / 2);
258
+ ctx.scale(1 / squash, squash);
259
+ drawMorph(ctx, 0, 0, s * 22, a, b, k, rot);
260
+ ctx.restore();
261
+ ctx.fill();
262
+ ctx.fillStyle = M.rgba(P.tone === "light" ? P.ink : "#000000", 0.18);
263
+ ctx.beginPath();
264
+ ctx.ellipse(w / 2, h / 2 + s * 32, s * 18 * squash, s * 2.4, 0, 0, M.TAU);
265
+ ctx.fill();
266
+ };
267
+
268
+ const morphGrid: LoopDraw = (ctx, w, h, t, P, M) => {
269
+ const cols = 12;
270
+ const cell = w / cols;
271
+ const rows = Math.ceil(h / cell);
272
+ for (let j = 0; j < rows; j++) {
273
+ for (let i = 0; i < cols; i++) {
274
+ const p = M.phase(t, 4, -(i + j) * 0.05);
275
+ // Circle → square → diamond (rotated square) → circle within each 4 s cycle.
276
+ const stage = p * 3;
277
+ const st = Math.min(2, Math.floor(stage));
278
+ const k = M.ease.inOutCubic(stage - st);
279
+ const from = [0, 1, 1][st];
280
+ const to = [1, 1, 0][st];
281
+ const rot = st === 1 ? (k * Math.PI) / 4 : st === 2 ? Math.PI / 4 : 0;
282
+ ctx.fillStyle = (i + j) % 4 === 0 ? second(P) : M.mixColor(P.mid, P.fg, 0.5 + 0.5 * Math.sin(M.TAU * p));
283
+ drawMorph(ctx, (i + 0.5) * cell, (j + 0.5) * cell, cell * 0.32, from, to, st === 1 ? 1 : k, rot);
284
+ ctx.fill();
285
+ }
286
+ }
287
+ };
288
+
289
+ const shapeShuffle: LoopDraw = (ctx, w, h, t, P, M) => {
290
+ const s = Math.min(w, h) / 100;
291
+ const slots = [-28, 0, 28];
292
+ const colors = [P.fg, second(P), P.mid];
293
+ // Every 4 s the three shapes hop one slot right (the last wraps left) and become the next shape:
294
+ // three hops per 12 s bring every shape home.
295
+ const cycle = Math.floor(t / 4);
296
+ const p = M.phase(t, 4);
297
+ const k = M.ease.inOutCubic(M.win(p, 0.35, 0.75));
298
+ for (let i = 0; i < 3; i++) {
299
+ const from = (i + cycle) % 3;
300
+ const to = (i + cycle + 1) % 3;
301
+ const wrap = from === 2;
302
+ const x = wrap ? slots[2] + (slots[0] - slots[2]) * k : slots[from] + (slots[to] - slots[from]) * k;
303
+ const hop = Math.sin(Math.PI * k) * (wrap ? -16 : 10);
304
+ ctx.fillStyle = colors[i];
305
+ drawMorph(ctx, w / 2 + x * s, h / 2 - hop * s, s * 9, [0, 1, 2][from], [0, 1, 2][to], k, 0);
306
+ ctx.fill();
307
+ }
308
+ };
309
+
310
+ let scratch: HTMLCanvasElement | undefined;
311
+
312
+ const metaballs: LoopDraw = (ctx, w, h, t, P, M, seed) => {
313
+ // A coarse field, thresholded with a soft edge, then scaled up smoothly.
314
+ const gw = 192;
315
+ const gh = Math.max(1, Math.round((gw * h) / w));
316
+ const field = new ImageData(gw, gh);
317
+ const balls = Array.from({ length: 6 }, (_, i) => ({
318
+ x: gw * (0.5 + 0.32 * Math.sin(M.TAU * (t / 12) * (1 + (i % 2)) + M.rand(i, seed + 1) * M.TAU)),
319
+ y: gh * (0.5 + 0.3 * Math.cos(M.TAU * (t / 6) + M.rand(i, seed + 2) * M.TAU)),
320
+ r: gh * (0.1 + 0.06 * M.rand(i, seed + 3)),
321
+ }));
322
+ const parse = (c: string) => {
323
+ const m = /(\d+),(\d+),(\d+)/.exec(M.mixColor(c, c, 0));
324
+ return m ? [+m[1], +m[2], +m[3]] : [255, 255, 255];
325
+ };
326
+ const fg = parse(P.fg);
327
+ const fg2 = parse(second(P));
328
+ for (let y = 0; y < gh; y++) {
329
+ for (let x = 0; x < gw; x++) {
330
+ let v = 0;
331
+ let wx = 0;
332
+ for (let b = 0; b < balls.length; b++) {
333
+ const dx = x - balls[b].x;
334
+ const dy = y - balls[b].y;
335
+ const f = (balls[b].r * balls[b].r) / (dx * dx + dy * dy + 1);
336
+ v += f;
337
+ wx += (b % 2) * f;
338
+ }
339
+ const a = M.smoothstep(0.9, 1.1, v);
340
+ const k = v > 0 ? wx / v : 0;
341
+ const i = (y * gw + x) * 4;
342
+ field.data[i] = fg[0] + (fg2[0] - fg[0]) * k;
343
+ field.data[i + 1] = fg[1] + (fg2[1] - fg[1]) * k;
344
+ field.data[i + 2] = fg[2] + (fg2[2] - fg[2]) * k;
345
+ field.data[i + 3] = a * 255;
346
+ }
347
+ }
348
+ scratch ??= document.createElement("canvas");
349
+ scratch.width = gw;
350
+ scratch.height = gh;
351
+ scratch.getContext("2d")?.putImageData(field, 0, 0);
352
+ const small = scratch;
353
+ ctx.imageSmoothingEnabled = true;
354
+ ctx.imageSmoothingQuality = "high";
355
+ ctx.drawImage(small, 0, 0, w, h);
356
+ };
357
+
358
+ // ─── Games ───────────────────────────────────────────────────────────────────────────────────────
359
+
360
+ /** A closed path over a cols × rows board (a serpentine plus the return lane): the snake's track. */
361
+ function snakeTrack(cols: number, rows: number) {
362
+ const path: [number, number][] = [];
363
+ for (let x = 0; x < cols; x++) path.push([x, 0]);
364
+ for (let col = cols - 1; col >= 1; col--) {
365
+ const down = (cols - 1 - col) % 2 === 0;
366
+ for (let y = 1; y < rows; y++) path.push([col, down ? y : rows - y]);
367
+ }
368
+ // Up the first column back to the start.
369
+ for (let y = rows - 1; y >= 1; y--) path.push([0, y]);
370
+ return path;
371
+ }
372
+
373
+ const snakeGame: LoopDraw = (ctx, w, h, t, P, M) => {
374
+ const rows = 9;
375
+ const cell = Math.min(h / (rows + 2), w / 18);
376
+ const cols = Math.max(4, Math.floor((w / cell - 2) / 2) * 2);
377
+ const track = snakeTrack(cols, rows);
378
+ const L = track.length;
379
+ const ox = (w - cols * cell) / 2;
380
+ const oy = (h - rows * cell) / 2;
381
+ const at = (i: number) => track[M.mod(Math.floor(i), L)];
382
+ // The head runs the whole track once per 12 s: L cells.
383
+ const head = (t / 12) * L;
384
+ const len = Math.max(6, Math.round(L * 0.09));
385
+ const gap = cell * 0.12;
386
+ // Board.
387
+ ctx.fillStyle = P.mid;
388
+ for (let y = 0; y < rows; y++)
389
+ for (let x = 0; x < cols; x++) {
390
+ ctx.globalAlpha = 0.25;
391
+ ctx.fillRect(ox + x * cell + gap, oy + y * cell + gap, cell - 2 * gap, cell - 2 * gap);
392
+ }
393
+ ctx.globalAlpha = 1;
394
+ // Food on the track ahead of the head; eaten with a pop when the head reaches it.
395
+ const foods = [0.13, 0.38, 0.61, 0.86].map((f) => Math.round(f * L));
396
+ foods.forEach((f) => {
397
+ const ahead = M.mod(f - head, L);
398
+ const [fx, fy] = at(f);
399
+ const cx = ox + (fx + 0.5) * cell;
400
+ const cy = oy + (fy + 0.5) * cell;
401
+ if (ahead < L * 0.6) {
402
+ const blink = 0.85 + 0.15 * Math.sin(M.TAU * M.phase(t, 1));
403
+ ctx.fillStyle = second(P);
404
+ ctx.fillRect(cx - cell * 0.3 * blink, cy - cell * 0.3 * blink, cell * 0.6 * blink, cell * 0.6 * blink);
405
+ }
406
+ const since = M.mod(head - f, L);
407
+ if (since < 3) {
408
+ const q = since / 3;
409
+ ctx.strokeStyle = M.rgba(second(P), 1 - q);
410
+ ctx.lineWidth = cell * 0.12;
411
+ ctx.strokeRect(cx - cell * (0.4 + q), cy - cell * (0.4 + q), cell * (0.8 + 2 * q), cell * (0.8 + 2 * q));
412
+ }
413
+ });
414
+ // Snake body, tail to head, with a sub-cell slide on the head and tail.
415
+ const frac = head - Math.floor(head);
416
+ for (let k = len; k >= 0; k--) {
417
+ const [x, y] = at(head - k);
418
+ const [nx, ny] = at(head - k + 1);
419
+ const slide = k === 0 ? frac : 0;
420
+ const px = ox + (x + (nx - x) * slide) * cell;
421
+ const py = oy + (y + (ny - y) * slide) * cell;
422
+ ctx.fillStyle = k === 0 ? P.fg : M.mixColor(P.fg, P.mid, (k / len) * 0.6);
423
+ ctx.fillRect(px + gap * 0.5, py + gap * 0.5, cell - gap, cell - gap);
424
+ if (k === 0) {
425
+ ctx.fillStyle = P.bg;
426
+ const ex = (nx - x) || 0;
427
+ const ey = (ny - y) || 0;
428
+ const e = cell * 0.12;
429
+ ctx.fillRect(px + cell / 2 + ex * cell * 0.15 - ey * cell * 0.18 - e / 2, py + cell / 2 + ey * cell * 0.15 - ex * cell * 0.18 - e / 2, e, e);
430
+ ctx.fillRect(px + cell / 2 + ex * cell * 0.15 + ey * cell * 0.18 - e / 2, py + cell / 2 + ey * cell * 0.15 + ex * cell * 0.18 - e / 2, e, e);
431
+ }
432
+ }
433
+ };
434
+
435
+ const fallingBlocks: LoopDraw = (ctx, w, h, t, P, M, seed) => {
436
+ const cols = 10;
437
+ const rows = 16;
438
+ const cell = Math.min((h * 0.9) / rows, (w * 0.9) / cols);
439
+ const ox = (w - cols * cell) / 2;
440
+ const oy = (h - rows * cell) / 2;
441
+ const colors = [P.fg, second(P), M.mixColor(P.fg, P.paper, 0.35), P.mid];
442
+ ctx.strokeStyle = M.rgba(P.mid, 0.6);
443
+ ctx.lineWidth = cell * 0.06;
444
+ ctx.strokeRect(ox, oy, cols * cell, rows * cell);
445
+ // Pieces enter from above the well: clip so a waiting piece never shows.
446
+ ctx.save();
447
+ ctx.beginPath();
448
+ ctx.rect(ox, oy, cols * cell, rows * cell);
449
+ ctx.clip();
450
+ // Twenty pieces (2×1 and 1×2 bars and squares) drop one after another and fill the bottom 4 rows,
451
+ // which flash and clear at the end of the 12 s cycle.
452
+ const layout: { x: number; y: number; w: number; h: number }[] = [];
453
+ for (let r = 0; r < 4; r++) for (let c = 0; c < cols; c += 2) layout.push({ x: c, y: rows - 1 - r, w: 2, h: 1 });
454
+ const order = layout.map((_, i) => i).sort((a, b) => Math.floor(a / 5) - Math.floor(b / 5) || M.rand(a, seed) - M.rand(b, seed));
455
+ const per = 10.5 / order.length;
456
+ const clear = M.win(t, 11.2, 11.9);
457
+ order.forEach((idx, n) => {
458
+ const piece = layout[idx];
459
+ const start = n * per;
460
+ const land = M.ease.inCubic(M.win(t, start, start + per * 1.4));
461
+ if (t < start) return;
462
+ const y = -2 + (piece.y + 2) * land;
463
+ ctx.fillStyle = clear > 0 ? M.mixColor(colors[idx % colors.length], P.paper, Math.sin(Math.PI * clear * 3) ** 2) : colors[idx % colors.length];
464
+ ctx.globalAlpha = 1 - M.smoothstep(0.6, 1, clear);
465
+ ctx.fillRect(ox + piece.x * cell + cell * 0.06, oy + y * cell + cell * 0.06, piece.w * cell - cell * 0.12, piece.h * cell - cell * 0.12);
466
+ });
467
+ ctx.globalAlpha = 1;
468
+ ctx.restore();
469
+ };
470
+
471
+ const pong: LoopDraw = (ctx, w, h, t, P, M) => {
472
+ const s = Math.min(w, h) / 100;
473
+ const tri = (x: number) => 1 - Math.abs(1 - 2 * M.fract(x));
474
+ // x bounces paddle to paddle every 1.5 s, y wall to wall every 2 s: both close at 12 s.
475
+ const bx = 0.12 + 0.76 * tri(t / 3);
476
+ const by = 0.1 + 0.8 * tri(t / 4 + 0.15);
477
+ const pad = (side: number) => {
478
+ // Each paddle follows the ball loosely, snapping to it as it arrives.
479
+ const near = side ? bx : 1 - bx;
480
+ return 0.5 + (by - 0.5) * (0.4 + 0.6 * near ** 2);
481
+ };
482
+ ctx.fillStyle = M.rgba(P.mid, 0.8);
483
+ for (let y = 0; y < h; y += s * 6) ctx.fillRect(w / 2 - s * 0.5, y, s, s * 3);
484
+ ctx.fillStyle = P.fg;
485
+ const ph = s * 18;
486
+ ctx.fillRect(w * 0.1 - s * 1.5, pad(0) * h - ph / 2, s * 3, ph);
487
+ ctx.fillRect(w * 0.9 - s * 1.5, pad(1) * h - ph / 2, s * 3, ph);
488
+ for (let k = 4; k >= 0; k--) {
489
+ const tk = t - k * 0.03;
490
+ const x = 0.12 + 0.76 * tri(tk / 3);
491
+ const y = 0.1 + 0.8 * tri(tk / 4 + 0.15);
492
+ ctx.fillStyle = M.rgba(second(P), 1 - k * 0.2);
493
+ ctx.fillRect(x * w - s * 1.6, y * h - s * 1.6, s * 3.2, s * 3.2);
494
+ }
495
+ };
496
+
497
+ const GLIDER = [
498
+ [[1, 0], [2, 1], [0, 2], [1, 2], [2, 2]],
499
+ [[0, 1], [2, 1], [1, 2], [2, 2], [1, 3]],
500
+ [[2, 1], [0, 2], [2, 2], [1, 3], [2, 3]],
501
+ [[1, 1], [2, 2], [3, 2], [1, 3], [2, 3]],
502
+ ];
503
+
504
+ const lifeGliders: LoopDraw = (ctx, w, h, t, P, M) => {
505
+ // Gliders on a torus: each moves one cell diagonally every 4 generations, so a 12 × 12 board brings
506
+ // them home after 48 generations (4 per second).
507
+ const size = 12;
508
+ const cell = Math.min(w, h) / (size + 2);
509
+ const ox = (w - size * cell) / 2;
510
+ const oy = (h - size * cell) / 2;
511
+ const gen = Math.floor((t / 12) * 48);
512
+ const shift = Math.floor(gen / 4);
513
+ const pattern = GLIDER[gen % 4];
514
+ const starts = [[0, 0], [6, 1], [3, 6], [9, 7]];
515
+ ctx.fillStyle = M.rgba(P.mid, 0.35);
516
+ for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) ctx.fillRect(ox + x * cell + cell * 0.1, oy + y * cell + cell * 0.1, cell * 0.8, cell * 0.8);
517
+ starts.forEach(([sx, sy], g) => {
518
+ ctx.fillStyle = g % 2 ? second(P) : P.fg;
519
+ for (const [px, py] of pattern) {
520
+ const x = M.mod(sx + px + shift, size);
521
+ const y = M.mod(sy + py + shift, size);
522
+ ctx.fillRect(ox + x * cell + cell * 0.06, oy + y * cell + cell * 0.06, cell * 0.88, cell * 0.88);
523
+ }
524
+ });
525
+ };
526
+
527
+ // ─── Physics ─────────────────────────────────────────────────────────────────────────────────────
528
+
529
+ const newtonsCradle: LoopDraw = (ctx, w, h, t, P, M) => {
530
+ const s = Math.min(w, h) / 100;
531
+ const n = 5;
532
+ const r = s * 5;
533
+ const len = s * 34;
534
+ const top = h / 2 - s * 26;
535
+ const swing = Math.sin(M.TAU * M.phase(t, 1.5)) * 0.55;
536
+ ctx.strokeStyle = P.mid;
537
+ ctx.lineWidth = s * 0.8;
538
+ ctx.beginPath();
539
+ ctx.moveTo(w / 2 - s * 22, top);
540
+ ctx.lineTo(w / 2 + s * 22, top);
541
+ ctx.stroke();
542
+ for (let i = 0; i < n; i++) {
543
+ const px = w / 2 + (i - (n - 1) / 2) * r * 2;
544
+ let a = 0;
545
+ if (i === 0 && swing < 0) a = swing;
546
+ if (i === n - 1 && swing > 0) a = swing;
547
+ const bx = px + Math.sin(a) * len;
548
+ const by = top + Math.cos(a) * len;
549
+ ctx.strokeStyle = M.rgba(P.mid, 0.9);
550
+ ctx.lineWidth = s * 0.3;
551
+ ctx.beginPath();
552
+ ctx.moveTo(px, top);
553
+ ctx.lineTo(bx, by);
554
+ ctx.stroke();
555
+ const g = ctx.createRadialGradient(bx - r * 0.35, by - r * 0.4, r * 0.1, bx, by, r);
556
+ g.addColorStop(0, M.mixColor(P.fg, P.paper, 0.6));
557
+ g.addColorStop(1, i % 2 ? M.mixColor(P.fg, second(P), 0.4) : P.fg);
558
+ ctx.fillStyle = g;
559
+ ctx.beginPath();
560
+ ctx.arc(bx, by, r, 0, M.TAU);
561
+ ctx.fill();
562
+ }
563
+ };
564
+
565
+ function gear(ctx: CanvasRenderingContext2D, x: number, y: number, r: number, teeth: number, a: number, color: string, hole: string) {
566
+ ctx.save();
567
+ ctx.translate(x, y);
568
+ ctx.rotate(a);
569
+ ctx.fillStyle = color;
570
+ ctx.beginPath();
571
+ for (let k = 0; k < teeth * 2; k++) {
572
+ const rr = k % 2 ? r : r * 1.16;
573
+ const a0 = (k / (teeth * 2)) * Math.PI * 2;
574
+ const a1 = ((k + 1) / (teeth * 2)) * Math.PI * 2;
575
+ ctx.lineTo(Math.cos(a0) * rr, Math.sin(a0) * rr);
576
+ ctx.lineTo(Math.cos(a1) * rr, Math.sin(a1) * rr);
577
+ }
578
+ ctx.closePath();
579
+ ctx.fill();
580
+ ctx.fillStyle = hole;
581
+ ctx.beginPath();
582
+ ctx.arc(0, 0, r * 0.3, 0, Math.PI * 2);
583
+ ctx.fill();
584
+ ctx.restore();
585
+ }
586
+
587
+ const clockGears: LoopDraw = (ctx, w, h, t, P, M) => {
588
+ const s = Math.min(w, h) / 100;
589
+ // Tooth counts 24 / 12 / 8: one turn of the big gear per 12 s, two of the middle, three of the small.
590
+ const big = (M.TAU * t) / 12;
591
+ gear(ctx, w / 2 - s * 10, h / 2, s * 24, 24, big, P.fg, P.bg);
592
+ gear(ctx, w / 2 + s * 26.5, h / 2 - s * 6, s * 12, 12, -2 * big + Math.PI / 12, second(P), P.bg);
593
+ gear(ctx, w / 2 - s * 10 + s * 30 * Math.cos(2.3), h / 2 + s * 30 * Math.sin(2.3), s * 8, 8, -3 * big + 0.2, P.mid, P.bg);
594
+ };
595
+
596
+ const liquidFill: LoopDraw = (ctx, w, h, t, P, M, seed) => {
597
+ const s = Math.min(w, h) / 100;
598
+ const R = s * 28;
599
+ const cx = w / 2;
600
+ const cy = h / 2;
601
+ // Fills over 8 s, drains over 4 s.
602
+ const level = t < 8 ? M.ease.inOutSine(t / 8) : 1 - M.ease.inOutSine((t - 8) / 4);
603
+ const surface = cy + R - level * 2 * R;
604
+ ctx.save();
605
+ ctx.beginPath();
606
+ ctx.arc(cx, cy, R, 0, M.TAU);
607
+ ctx.clip();
608
+ ctx.fillStyle = M.rgba(P.mid, 0.4);
609
+ ctx.fillRect(cx - R, cy - R, R * 2, R * 2);
610
+ for (const [k, col] of [[0, second(P)], [1, P.fg]] as const) {
611
+ ctx.fillStyle = col;
612
+ ctx.beginPath();
613
+ ctx.moveTo(cx - R, cy + R);
614
+ for (let x = -R; x <= R; x += R / 40) {
615
+ const y = surface + Math.sin((x / R) * 3 + M.TAU * M.phase(t, 2) + k * 1.5) * s * 2 * (0.4 + Math.sin(Math.PI * level)) + k * s * 2;
616
+ ctx.lineTo(cx + x, y);
617
+ }
618
+ ctx.lineTo(cx + R, cy + R);
619
+ ctx.closePath();
620
+ ctx.fill();
621
+ }
622
+ for (let i = 0; i < 8; i++) {
623
+ const life = M.phase(t, 3, M.rand(i, seed + 1));
624
+ const bx = cx + (M.rand(i, seed + 2) - 0.5) * R * 1.4;
625
+ const by = cy + R - life * (cy + R - surface);
626
+ if (by > surface + s) {
627
+ ctx.strokeStyle = M.rgba(P.paper, 0.6);
628
+ ctx.lineWidth = s * 0.4;
629
+ ctx.beginPath();
630
+ ctx.arc(bx, by, s * (0.8 + M.rand(i, seed + 3)), 0, M.TAU);
631
+ ctx.stroke();
632
+ }
633
+ }
634
+ ctx.restore();
635
+ ctx.strokeStyle = P.fg;
636
+ ctx.lineWidth = s * 1.4;
637
+ ctx.beginPath();
638
+ ctx.arc(cx, cy, R, 0, M.TAU);
639
+ ctx.stroke();
640
+ };
641
+
642
+ const dominoWave: LoopDraw = (ctx, w, h, t, P, M) => {
643
+ const u = h / 100;
644
+ const rows = 5;
645
+ const cols = 22;
646
+ const gapX = w / cols;
647
+ for (let r = 0; r < rows; r++) {
648
+ const y = h * (0.22 + r * 0.15);
649
+ for (let c = 0; c < cols; c++) {
650
+ // A wave knocks each domino down in turn, then it stands back up: one wave per 6 s.
651
+ const p = M.phase(t, 6, -c * 0.025 - r * 0.08);
652
+ const fall = M.ease.inCubic(M.win(p, 0, 0.12));
653
+ const rise = M.ease.outBack(M.win(p, 0.55, 0.75));
654
+ const a = (fall - rise) * 1.25;
655
+ ctx.save();
656
+ ctx.translate((c + 0.5) * gapX, y + u * 5);
657
+ ctx.rotate(a);
658
+ ctx.fillStyle = (c + r) % 6 === 0 ? second(P) : P.fg;
659
+ ctx.beginPath();
660
+ ctx.roundRect(-u * 1.2, -u * 10, u * 2.4, u * 10, u * 0.6);
661
+ ctx.fill();
662
+ ctx.restore();
663
+ }
664
+ }
665
+ };
666
+
667
+ // ─── Generative ──────────────────────────────────────────────────────────────────────────────────
668
+
669
+ const vortex: LoopDraw = (ctx, w, h, t, P, M, seed) => {
670
+ const s = Math.min(w, h) / 100;
671
+ const R = Math.hypot(w, h) * 0.55;
672
+ for (let i = 0; i < 420; i++) {
673
+ const life = M.phase(t, 6, M.rand(i, seed + 1));
674
+ const arm = i % 3;
675
+ const r = R * (1 - M.ease.inCubic(life));
676
+ // Spin faster near the center; whole turns per cycle keep the seam closed.
677
+ const a = (arm * M.TAU) / 3 + M.rand(i, seed + 2) * 0.5 + M.TAU * (2 * life) + (M.TAU * t) / 12;
678
+ const x = w / 2 + Math.cos(a) * r;
679
+ const y = h / 2 + Math.sin(a) * r * 0.62;
680
+ ctx.fillStyle = M.rgba(arm === 1 ? second(P) : P.fg, Math.sin(Math.PI * life));
681
+ ctx.beginPath();
682
+ ctx.arc(x, y, s * (0.25 + 0.9 * (1 - life)), 0, M.TAU);
683
+ ctx.fill();
684
+ }
685
+ const g = ctx.createRadialGradient(w / 2, h / 2, 0, w / 2, h / 2, s * 14);
686
+ g.addColorStop(0, M.rgba(P.paper, 0.85));
687
+ g.addColorStop(1, M.rgba(P.fg, 0));
688
+ ctx.fillStyle = g;
689
+ ctx.fillRect(0, 0, w, h);
690
+ };
691
+
692
+ const lissajousTrail: LoopDraw = (ctx, w, h, t, P, M) => {
693
+ const s = Math.min(w, h) / 100;
694
+ // 3:2 Lissajous: x every 4 s, y every 6 s, the whole figure every 12 s.
695
+ const at = (tt: number) => ({
696
+ x: w / 2 + Math.sin((M.TAU * tt) / 4) * s * 40,
697
+ y: h / 2 + Math.sin((M.TAU * tt) / 6 + Math.PI / 4) * s * 30,
698
+ });
699
+ ctx.lineCap = "round";
700
+ const steps = 160;
701
+ for (let i = 0; i < steps; i++) {
702
+ const a = at(t - 3 + (i / steps) * 3);
703
+ const b = at(t - 3 + ((i + 1) / steps) * 3);
704
+ const k = i / steps;
705
+ ctx.strokeStyle = M.rgba(M.mixColor(second(P), P.fg, k), k);
706
+ ctx.lineWidth = s * (0.2 + 2.2 * k);
707
+ ctx.beginPath();
708
+ ctx.moveTo(a.x, a.y);
709
+ ctx.lineTo(b.x, b.y);
710
+ ctx.stroke();
711
+ }
712
+ const p = at(t);
713
+ const g = ctx.createRadialGradient(p.x, p.y, 0, p.x, p.y, s * 8);
714
+ g.addColorStop(0, M.rgba(P.paper, 0.9));
715
+ g.addColorStop(1, M.rgba(P.fg, 0));
716
+ ctx.fillStyle = g;
717
+ ctx.fillRect(p.x - s * 8, p.y - s * 8, s * 16, s * 16);
718
+ };
719
+
720
+ const bubblePop: LoopDraw = (ctx, w, h, t, P, M, seed) => {
721
+ const u = h / 100;
722
+ for (let i = 0; i < 26; i++) {
723
+ const life = M.phase(t, [3, 4, 6][i % 3], M.rand(i, seed + 1));
724
+ const popAt = 0.55 + 0.35 * M.rand(i, seed + 2);
725
+ const x = M.rand(i, seed + 3) * w + Math.sin(M.TAU * life * 2 + i) * u * 2;
726
+ const r = u * (2 + 4 * M.rand(i, seed + 4));
727
+ const y = h + r - life * (h + 2 * r);
728
+ const col = i % 4 === 0 ? second(P) : P.fg;
729
+ if (life < popAt) {
730
+ ctx.strokeStyle = M.rgba(col, 0.9);
731
+ ctx.lineWidth = u * 0.35;
732
+ ctx.beginPath();
733
+ ctx.arc(x, y, r * (0.6 + 0.4 * M.smoothstep(0, 0.1, life)), 0, M.TAU);
734
+ ctx.stroke();
735
+ ctx.fillStyle = M.rgba(P.paper, 0.5);
736
+ ctx.beginPath();
737
+ ctx.arc(x - r * 0.35, y - r * 0.35, r * 0.18, 0, M.TAU);
738
+ ctx.fill();
739
+ } else {
740
+ // Pop: a ring of sparks flying out and fading.
741
+ const q = M.clamp((life - popAt) / 0.12);
742
+ if (q < 1) {
743
+ const py = h + r - popAt * (h + 2 * r);
744
+ for (let k = 0; k < 8; k++) {
745
+ const a = (k * M.TAU) / 8;
746
+ ctx.fillStyle = M.rgba(col, 1 - q);
747
+ ctx.beginPath();
748
+ ctx.arc(x + Math.cos(a) * r * (1 + q * 1.5), py + Math.sin(a) * r * (1 + q * 1.5), u * 0.5 * (1 - q), 0, M.TAU);
749
+ ctx.fill();
750
+ }
751
+ }
752
+ }
753
+ }
754
+ };
755
+
756
+ export const LOOPS_MORE: LoopDef[] = [
757
+ { id: "kaleidoscope", name: "Kaleidoscope", kind: "background", category: "Symmetry", draw: kaleidoscope, tags: ["kaleidoscope", "symmetry", "mirror", "psychedelic"], description: "Shapes drifting out of the center through an eight-way mirror. Music, festivals, creative tools, hypnotic openers." },
758
+ { id: "mandala-bloom", name: "Mandala Bloom", kind: "shape", category: "Symmetry", draw: mandalaBloom, tags: ["mandala", "symmetry", "petals", "wellness"], description: "Four rings of petals turning in alternate directions and breathing. Wellness, meditation, craft, elegant openers." },
759
+ { id: "spirograph", name: "Spirograph", kind: "shape", category: "Symmetry", draw: spirograph, tags: ["spirograph", "curve", "line", "symmetry"], description: "A glowing pen tracing a spirograph curve around its own faint outline. Precision, engineering, design, math." },
760
+ { id: "mirror-tiles", name: "Mirror Tiles", kind: "background", category: "Symmetry", draw: mirrorTiles, tags: ["truchet", "tiles", "symmetry", "arcs"], description: "Arc tiles mirrored four ways, turning in waves from the edges: a pattern that keeps redrawing itself. Design, architecture, playful tech." },
761
+ { id: "radial-burst", name: "Radial Burst", kind: "background", category: "Symmetry", draw: radialBurst, tags: ["sunburst", "rays", "pop", "retro"], description: "Retro sunburst rays turning behind a pulsing ring. Announcements, sales, 'new!', game shows, comic pop." },
762
+ { id: "shape-morph", name: "Shape Morph", kind: "shape", category: "Morphing", draw: shapeMorph, tags: ["morph", "shapes", "circle", "square", "triangle", "star"], description: "A shape that springs from circle to square to triangle to star and back, squashing before each change. Transformation, 'one tool, many uses', playful brands." },
763
+ { id: "morph-grid", name: "Morph Grid", kind: "background", category: "Morphing", draw: morphGrid, tags: ["morph", "grid", "shapes", "wave"], description: "A grid of circles that become squares, turn into diamonds and round off again in a diagonal wave. Systems, design tools, modular products." },
764
+ { id: "shape-shuffle", name: "Shape Shuffle", kind: "shape", category: "Morphing", draw: shapeShuffle, tags: ["shuffle", "morph", "shapes", "playful"], description: "Three shapes hopping one slot over and turning into the next shape. Options, choices, 'mix and match', onboarding." },
765
+ { id: "metaballs", name: "Metaballs", kind: "background", category: "Morphing", draw: metaballs, tags: ["liquid", "blobs", "metaballs", "lava"], description: "Liquid blobs that merge and split like lava. Fluid, organic, AI, creative tools, music." },
766
+ { id: "snake-game", name: "Snake", kind: "background", category: "Games", draw: snakeGame, tags: ["snake", "game", "retro", "pixel", "arcade"], description: "The classic snake game: the snake winds across a pixel board eating food with a pop. Gaming, retro, nostalgia, 'level up'." },
767
+ { id: "falling-blocks", name: "Falling Blocks", kind: "shape", category: "Games", draw: fallingBlocks, tags: ["blocks", "tetris", "stack", "game", "retro"], description: "Blocks drop into a well, stack up and clear in a flash. Building, organizing, productivity, games." },
768
+ { id: "pong", name: "Pong", kind: "background", category: "Games", draw: pong, tags: ["pong", "game", "retro", "arcade", "back and forth"], description: "Two paddles rallying a ball with a motion trail. Retro, back-and-forth, collaboration, versus." },
769
+ { id: "life-gliders", name: "Life Gliders", kind: "shape", category: "Games", draw: lifeGliders, tags: ["game of life", "pixel", "cellular", "generative"], description: "Conway's Game of Life gliders sailing across a wrapped board. Code, dev tools, emergence, nerdy brands." },
770
+ { id: "newtons-cradle", name: "Newton's Cradle", kind: "shape", category: "Physics", draw: newtonsCradle, tags: ["newton", "cradle", "physics", "momentum"], description: "A Newton's cradle clicking back and forth. Momentum, cause and effect, focus, steady progress." },
771
+ { id: "clock-gears", name: "Clock Gears", kind: "shape", category: "Physics", draw: clockGears, tags: ["gears", "machine", "process", "automation"], description: "Three meshing gears turning at true ratios. Automation, workflows, engineering, 'how it works'." },
772
+ { id: "liquid-fill", name: "Liquid Fill", kind: "shape", category: "Physics", draw: liquidFill, tags: ["liquid", "fill", "progress", "water"], description: "A round vessel filling with wavy liquid and bubbles, then draining. Progress, loading, drinks, growth." },
773
+ { id: "domino-wave", name: "Domino Wave", kind: "background", category: "Physics", draw: dominoWave, tags: ["domino", "chain reaction", "wave"], description: "Rows of dominoes toppling in a wave and springing back up. Chain reactions, automation, 'one action, many results'." },
774
+ { id: "vortex", name: "Vortex", kind: "background", category: "Generative", draw: vortex, tags: ["vortex", "galaxy", "particles", "spiral"], description: "Three arms of particles spiralling into a glowing core. AI, space, gravity, 'everything flows to one place'." },
775
+ { id: "lissajous-trail", name: "Lissajous Trail", kind: "shape", category: "Generative", draw: lissajousTrail, tags: ["lissajous", "trail", "light", "curve"], description: "A comet of light drawing a Lissajous figure with a fading trail. Signals, elegance, music, tech intros." },
776
+ { id: "bubble-pop", name: "Bubble Pop", kind: "background", category: "Generative", draw: bubblePop, tags: ["bubbles", "pop", "playful", "fizzy"], description: "Bubbles wobbling upward and popping into sparks. Playful, drinks, kids, social, notifications." },
777
+ ];