Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.
TypeScript agent-skillsanimationcanvasclaude-codeclaude-pluginclaude-skillscodex-plugincreative-codecreative-codingcreative-toolsdeterministicgenerative-arthand-drawnillustrationlaunch-videomotion-designmotion-graphicspluginprocedural-generationskill
0.5.2: the installed plugin ships only what users need (anidoodle's own launch films, their reference image and the gallery tool stay in the repo); docs link the gallery sheet online
Alex Greenshpunb0a35ce63aeb
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonindex 000b409..c73c240 100644--- a/.claude-plugin/marketplace.json+++ b/.claude-plugin/marketplace.json@@ -13,7 +13,7 @@"name": "anidoodle","source": "./","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.",- "version": "0.5.1",+ "version": "0.5.2","author": {"name": "Alex Greenshpun","url": "https://linkedin.com/in/alexgreensh"diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex 1f7b41e..92e08ba 100644--- a/.claude-plugin/plugin.json+++ b/.claude-plugin/plugin.json@@ -2,7 +2,7 @@"name": "anidoodle","displayName": "anidoodle","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.",- "version": "0.5.1",+ "version": "0.5.2","icon": "./assets/icon.png","author": {"name": "Alex Greenshpun",diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.jsonindex 6204eda..8350a93 100644--- a/.codex-plugin/plugin.json+++ b/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "anidoodle",- "version": "0.5.1",+ "version": "0.5.2","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.","skills": "./skills/","interface": {diff --git a/.grok-plugin/marketplace.json b/.grok-plugin/marketplace.jsonindex 16795cf..15197d7 100644--- a/.grok-plugin/marketplace.json+++ b/.grok-plugin/marketplace.json@@ -10,7 +10,7 @@"name": "anidoodle","source": "./plugins/anidoodle","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.",- "version": "0.5.1",+ "version": "0.5.2","author": {"name": "Alex Greenshpun","url": "https://linkedin.com/in/alexgreensh"diff --git a/plugins/anidoodle/.claude-plugin/plugin.json b/plugins/anidoodle/.claude-plugin/plugin.jsonindex 1f7b41e..92e08ba 100644--- a/plugins/anidoodle/.claude-plugin/plugin.json+++ b/plugins/anidoodle/.claude-plugin/plugin.json@@ -2,7 +2,7 @@"name": "anidoodle","displayName": "anidoodle","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.",- "version": "0.5.1",+ "version": "0.5.2","icon": "./assets/icon.png","author": {"name": "Alex Greenshpun",diff --git a/plugins/anidoodle/.codex-plugin/plugin.json b/plugins/anidoodle/.codex-plugin/plugin.jsonindex 6204eda..8350a93 100644--- a/plugins/anidoodle/.codex-plugin/plugin.json+++ b/plugins/anidoodle/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "anidoodle",- "version": "0.5.1",+ "version": "0.5.2","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.","skills": "./skills/","interface": {diff --git a/plugins/anidoodle/skills/anidoodle/SKILL.md b/plugins/anidoodle/skills/anidoodle/SKILL.mdindex 9dbb02f..3d6a0e4 100644--- a/plugins/anidoodle/skills/anidoodle/SKILL.md+++ b/plugins/anidoodle/skills/anidoodle/SKILL.md@@ -21,7 +21,7 @@ that prevents each of those.Read `references/workflows/start-here.md` and run its intake: one question at a time, onlywhat the request leaves open, your recommendation first. **What** are they making, in **which-style** (show `assets/styles.jpg`; the list is `references/styles/INDEX.md`), what+style** (show the gallery sheet, https://github.com/alexgreensh/anidoodle/blob/main/skills/anidoodle/assets/styles.jpg; the list is `references/styles/INDEX.md`), what**shape** (1x1, 9x16, 16x9, 4x5 or any W x H), how **long** (any length; never cap it), what**sound** (silent or a music style and mood), which **characters**. "You pick" means pick andsay why in one line. Write the answers into a short brief before drawing.diff --git a/plugins/anidoodle/skills/anidoodle/assets/styles.jpg b/plugins/anidoodle/skills/anidoodle/assets/styles.jpgdeleted file mode 100644index d22375c..0000000Binary files a/plugins/anidoodle/skills/anidoodle/assets/styles.jpg and /dev/null differdiff --git a/plugins/anidoodle/skills/anidoodle/engine/assets/refs/PROVENANCE.json b/plugins/anidoodle/skills/anidoodle/engine/assets/refs/PROVENANCE.jsondeleted file mode 100644index 90f5a4d..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/assets/refs/PROVENANCE.json+++ /dev/null@@ -1,12 +0,0 @@-{- "vangogh-almond-blossom.jpg": {- "work": "Vincent van Gogh, Almond Blossom (1890), Van Gogh Museum, Amsterdam",- "title": "File:Vincent van Gogh - Almond blossom - Google Art Project.jpg",- "page": "https://commons.wikimedia.org/wiki/File:Vincent_van_Gogh_-_Almond_blossom_-_Google_Art_Project.jpg",- "license": "Public domain (author died 1890; faithful reproduction of a 2D public-domain work)",- "sha256": "6f640dcd79def4223bf16569fd29ca5e37ee9d6cde2670958636e259e2a1c9d0",- "bytes": 1046465,- "usedBy": "the launch films (launch.ts, launch2.ts, launch3.ts) and typeOptions.ts show it only as the picture the user attaches in the chat; adaptAlmond.ts borrows its hand, never its pixels",- "note": "the one image in the repo that is not drawn by code; kept byte-identical to the download so renders stay reproducible"- }-}diff --git a/plugins/anidoodle/skills/anidoodle/engine/assets/refs/vangogh-almond-blossom.jpg b/plugins/anidoodle/skills/anidoodle/engine/assets/refs/vangogh-almond-blossom.jpgdeleted file mode 100644index bfb1848..0000000Binary files a/plugins/anidoodle/skills/anidoodle/engine/assets/refs/vangogh-almond-blossom.jpg and /dev/null differdiff --git a/plugins/anidoodle/skills/anidoodle/engine/package-lock.json b/plugins/anidoodle/skills/anidoodle/engine/package-lock.jsonindex 79123db..058f838 100644--- a/plugins/anidoodle/skills/anidoodle/engine/package-lock.json+++ b/plugins/anidoodle/skills/anidoodle/engine/package-lock.json@@ -1,12 +1,12 @@{"name": "anidoodle-engine",- "version": "0.5.1",+ "version": "0.5.2","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "anidoodle-engine",- "version": "0.5.1",+ "version": "0.5.2","dependencies": {"esbuild": "^0.25.0"},diff --git a/plugins/anidoodle/skills/anidoodle/engine/package.json b/plugins/anidoodle/skills/anidoodle/engine/package.jsonindex 084cba4..4b7d893 100644--- a/plugins/anidoodle/skills/anidoodle/engine/package.json+++ b/plugins/anidoodle/skills/anidoodle/engine/package.json@@ -1,6 +1,6 @@{"name": "anidoodle-engine",- "version": "0.5.1",+ "version": "0.5.2","private": true,"type": "module","description": "Portable art core + backend adapters for illustrations, animations and films drawn entirely in code.",diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/bake.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/bake.tsindex f956cef..a485823 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/bake.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/bake.ts@@ -2,7 +2,7 @@// blurred and toothed). A web page has 6. So an interactive piece does the drawing ONCE, at mount,// into sprites, and each frame is a composite of sprites plus a handful of live marks.//-// A sprite is a pure function of its key (and env.scale, which the key includes): contract rule 5.+// A sprite is a pure function of its id (and env.scale, which the id includes): contract rule 5.// It is cropped to exactly the device box the drawing touched, at integer device pixels, so an// untransformed blit puts back the very pixels the plate drew. Moving parts are blitted with a// rotation or a DOWN-scale about a pivot, never an up-scale (contract rule 6).@@ -13,15 +13,15 @@ export const stats = { baked: 0, bytes: 0, ms: 0 }; // for the host's report onlconst resettable = (c: unknown) => !!c && typeof (c as { reset?: unknown }).reset === "function";const scratch = (env: Env): Layer => {- const DW = Math.round(env.W * env.scale), DH = Math.round(env.H * env.scale), key = `bake:scratch:${DW}x${DH}`;- let L = env.cache.get(key) as Layer | undefined;- if (L && resettable(L.ctx)) (L.ctx as unknown as { reset(): void }).reset(); else { L = env.canvas(DW, DH); env.cache.set(key, L); } /* see bake(): pristine, or new */+ const DW = Math.round(env.W * env.scale), DH = Math.round(env.H * env.scale), id = `bake:scratch:${DW}x${DH}`;+ let L = env.cache.get(id) as Layer | undefined;+ if (L && resettable(L.ctx)) (L.ctx as unknown as { reset(): void }).reset(); else { L = env.canvas(DW, DH); env.cache.set(id, L); } /* see bake(): pristine, or new */return L;};// Draw `fn` with a fresh Gfx on a clean full-size scratch, crop what it composited, cache it.-export const bake = (env: Env, key: string, fn: (g: Gfx) => void, o: { medium?: Medium; frame?: number; full?: boolean; raw?: boolean } = {}): Sprite => {- const k = `sprite:${key}@${env.scale}`, hit = env.cache.get(k) as Sprite | undefined; if (hit) return hit;+export const bake = (env: Env, id: string, fn: (g: Gfx) => void, o: { medium?: Medium; frame?: number; full?: boolean; raw?: boolean } = {}): Sprite => {+ const k = `sprite:${id}@${env.scale}`, hit = env.cache.get(k) as Sprite | undefined; if (hit) return hit;const S = scratch(env), DW = Math.round(env.W * env.scale), DH = Math.round(env.H * env.scale), c = S.ctx;c.setTransform(1, 0, 0, 1, 0, 0); c.globalAlpha = 1; c.globalCompositeOperation = "source-over"; c.clearRect(0, 0, DW, DH);// Every bake starts from pristine surfaces. Measured in Chromium: a 2D canvas that has EVER filled@@ -94,5 +94,5 @@ export class Only extends Gfx {inkGroup(fn: () => void, o: Parameters<Gfx["inkGroup"]>[1] = {}) { const i = this.n++; this.census.push("inkGroup"); if (this.keep(i)) super.inkGroup(fn, o); }}// bake() for a part of a plate: `draw(g)` receives an Only that keeps groups in `keep`.-export const bakePart = (env: Env, key: string, keep: (i: number) => boolean, draw: (g: Gfx) => void, o: { medium?: Medium; frame?: number } = {}): Sprite =>- bake(env, key, (g0) => { const g = new Only(g0.main, env, o.frame ?? 0, o.medium ?? PENCIL, keep); draw(g); g0.drawn = g.drawn; }, o);+export const bakePart = (env: Env, id: string, keep: (i: number) => boolean, draw: (g: Gfx) => void, o: { medium?: Medium; frame?: number } = {}): Sprite =>+ bake(env, id, (g0) => { const g = new Only(g0.main, env, o.frame ?? 0, o.medium ?? PENCIL, keep); draw(g); g0.drawn = g.drawn; }, o);diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launch.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launch.tsdeleted file mode 100644index 16f6dfd..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launch.ts+++ /dev/null@@ -1,440 +0,0 @@-// LAUNCH. The anidoodle launch film, 1920x1080, 30 fps, 104 s on the 90 bpm grid of its own score-// (a beat is 20 frames, a bar 80: every scene starts on a bar the music changes on).-//-// THE STORY is one sentence, told from the user's chair: you can make images, illustrations,-// loops, animations and films, in pure code. A person types into a chat and presses Generate; the-// Generate button becomes a drop of ink that blooms into the answer. Each request opens a chapter,-// and the chapter's word writes itself onto a rail at the left as it is delivered:-// Illustrations the koi draws itself, stroke by stroke-// Animations "now make it swim": the card breaks out to the full frame and the koi swims-// through a pond bigger than the screen, the camera following-// Images the camera dives into a lily pad and the plates bloom out of shared circles-// (watch face, full moon, crayon balloon); then a painter's hand, borrowed-// Animations the crayon balloon rebuilds itself in toy bricks and flies over a brick world-// Loops an embroidery that stitches itself, on a seamless loop-// Animations a live page: Bit watches the real pointer-// Films the butterfly film with its own score-// then the words gather in the order of the sentence and "All in pure code." lands on the-// score's home chord, the film pulls back into the editor that draws it, and the name writes itself.-//-// Every plate on screen is that plate's own code drawing live (launchKit.plateLayer): no recordings.-// The one image is a public-domain painting the user "brings" (Van Gogh, Almond Blossom, 1890),-// pinned in assets and shown only as the attachment; the answer is adaptAlmond. The sound is code-// too: the score (music/pieces/launch.ts) plus the UI's clicks, thocks, plips and whooshes below.-import { rng, type Ctx, type Env, type P } from "./core";-import type { Film } from "./film";-import {- C, CHAT, GEN, HOME, INPUT, MONO, REPLY, SANS, TEXT, artCard, blot, camLerp, caretAt, clamp, drawChatFrame, expo, inOut, lerp, lerpP,- out3, pathOf, plateLayer, pointer, press, ramp, rr, selfLayer, softShadow, spring, useCam, type Cam, type ChatState,-} from "./launchKit";-import { koiDraw } from "./koiDraw";-import { koi } from "./koi";-import { koiWorld, padsOnScreen } from "./koiWorld";-import { pocketWatch } from "./pocketWatch";-import { moonPhases } from "./moonPhases";-import { balloon } from "./balloon";-import { brickBalloon } from "./brickBalloon";-import { adaptAlmond } from "./adaptAlmond";-import { embroideryAlive } from "./embroideryAlive";-import { mascotHero } from "./mascotHero";-import { stateAt, type InputLog } from "./input";-import { mechanicalLepidoptera } from "./mechanicalLepidoptera";-import { banner as bannerFilm } from "./banner";-import { launchLofi } from "./music/pieces/launch";-import { renderPiece } from "./music/render";--const W = 1920, H = 1080, FPS = 30, BEAT = 20;--// THE TIMELINE, in frames. Every boundary is on a bar of the score (80 frames).-export const T = {- type: [0, 160], gen: [160, 240], draw: [240, 560], swim: [560, 880],- run: [880, 1120], brick: [1120, 1520], ref: [1520, 1840], emb: [1840, 2080],- web: [2080, 2400], film: [2400, 2720], reveal: [2720, 2960], end: [2960, 3120],-} as const;-const N = T.end[1];--// ---------------------------------------------------------------- typing-// when each character lands: a typist's rhythm, seeded, never mechanical. Later requests type-// faster: the viewer has learned the move, the film should not make them wait for it.-const charTimes = (text: string, t0: number, rate: number, seed: number) => {- const out: number[] = []; let t = t0;- for (let i = 0; i < text.length; i++) { const h = Math.sin((i + 1) * 12.9898 + seed * 78.233) * 43758.5453, j = h - Math.floor(h); t += rate * (0.55 + j * 0.9) + (text[i] === " " ? 0.8 * rate : 0); out.push(t); }- return out;-};-const typedAt = (text: string, f: number, t0: number, rate: number, seed: number) => text.slice(0, charTimes(text, t0, rate, seed).filter((t) => f >= t).length);--// ---------------------------------------------------------------- cameras-const CARD_C: P = [REPLY.x + REPLY.s / 2, REPLY.y + REPLY.s / 2];-const CARD_CAM: Cam = { c: CARD_C, z: 1000 / REPLY.s }; // the reply card at 1000 px, centred-const GEN_C: P = [GEN.x + GEN.w / 2, GEN.y + GEN.h / 2];--// ---------------------------------------------------------------- 1 + 2: the first request, Generate, ink-const KOI_PROMPT = "a koi turning under lily pads, marker comic";-const KOI_TYPE = { t0: 14, rate: 2.0, seed: 7 };-const PRESS = { down: T.gen[0], up: T.gen[0] + 6 };-const DROP = { t0: PRESS.up + 6, land: PRESS.up + 22, full: PRESS.up + 60 };-const KOI_SPEED = 1.5, KOI_DONE = DROP.land + (koiDraw.meta.durationFrames - 30) / KOI_SPEED;-const koiLayer = (env: Env, f: number) => (f < KOI_DONE ? plateLayer(env, "koiDraw", koiDraw, (f - DROP.land) * KOI_SPEED, 1080) : plateLayer(env, "koi", koi, 0, 1080));--const typeCam = (ctx: Ctx, f: number): Cam => {- const typed = typedAt(KOI_PROMPT, f, KOI_TYPE.t0, KOI_TYPE.rate, KOI_TYPE.seed), [cx] = caretAt(ctx, typed);- const macro: Cam = { c: [Math.max(TEXT.x + 330, cx - 110), 934], z: 2.7 };- return f < 112 ? macro : camLerp(macro, HOME, expo(ramp(f, 112, 150)));-};-const leanCam = (f: number): Cam => { const lean = expo(ramp(f, DROP.land - 4, DROP.full + 20)) * 0.09; return { c: lerpP(HOME.c, CARD_C, lean * 1.6), z: 1 + lean }; };--// the ink: the button's ink wells up, lets go, arcs into the reply with a drawn smear, and blooms-const drawInk = (ctx: Ctx, env: Env, f: number, D: typeof DROP, art: CanvasImageSource, card = REPLY) => {- if (f < PRESS.up && D === DROP) return;- const land: P = [card.x + card.s / 2, card.y + card.s / 2], R0 = 30;- if (f < D.t0) { const w = out3(ramp(f, D.t0 - 6, D.t0)); ctx.fillStyle = C.ink; ctx.beginPath(); ctx.arc(GEN_C[0], GEN.y + 6 - w * 22, R0 * (0.3 + 0.7 * w), 0, Math.PI * 2); ctx.fill(); return; }- if (f < D.land) {- const at = (g: number): P => { const u = ramp(g, D.t0, D.land), e = inOut(u); return [lerp(GEN_C[0], land[0], e), lerp(GEN.y - 16, land[1], e) - Math.sin(Math.PI * u) * 170]; };- for (let k = 30; k >= 0; k--) { const p = at(f - k * 0.1), r = R0 * (1 - k * 0.022) * (1 - 0.25 * Math.sin(Math.PI * ramp(f, D.t0, D.land))); ctx.fillStyle = C.ink; ctx.globalAlpha = k === 0 ? 1 : 0.22 * (1 - k / 31); ctx.beginPath(); ctx.arc(p[0], p[1], r, 0, Math.PI * 2); ctx.fill(); }- ctx.globalAlpha = 1; return;- }- const u = ramp(f, D.land, D.full), R = lerp(18, card.s * 0.8, out3(u)), rim = lerp(40, 0, ramp(u, 0.55, 1));- ctx.save(); rr(ctx, card.x, card.y, card.s, card.s, 22); ctx.clip();- pathOf(ctx, blot(land, R + rim, 311)); ctx.fillStyle = C.ink; ctx.fill();- pathOf(ctx, blot(land, Math.max(0, R - 6), 311)); ctx.clip();- ctx.fillStyle = C.paper; ctx.fillRect(card.x, card.y, card.s, card.s); ctx.drawImage(art, card.x, card.y, card.s, card.s);- ctx.restore();- for (let i = 0; i < 9; i++) { const a = i * 2.39 + 0.4, d = 30 + (i % 3) * 22 + 160 * out3(ramp(u, 0, 0.3)), s = (1 - ramp(u, 0.12, 0.34)) * (4 + (i % 4) * 2.5); if (s <= 0.2) continue; ctx.fillStyle = C.ink; ctx.beginPath(); ctx.arc(land[0] + Math.cos(a) * d, land[1] + Math.sin(a) * d, s, 0, Math.PI * 2); ctx.fill(); }-};--const sceneOpen = (ctx: Ctx, env: Env, f: number) => {- useCam(ctx, env, f < T.gen[0] ? typeCam(ctx, f) : leanCam(f));- const typed = typedAt(KOI_PROMPT, f, KOI_TYPE.t0, KOI_TYPE.rate, KOI_TYPE.seed);- const s: ChatState = {- typed: f < PRESS.up ? typed : "", caret: f < PRESS.up && (Math.floor(f / 8) % 2 === 0 || typed.length < KOI_PROMPT.length),- placeholder: "Describe what you want drawn…",- sent: f >= PRESS.up ? KOI_PROMPT : undefined, sentAlpha: ramp(f, PRESS.up, PRESS.up + 10),- genPress: press(f, PRESS.down, PRESS.up), genHot: ramp(f, 150, 158),- label: f >= DROP.land ? "marker comic" : undefined, labelAlpha: ramp(f, DROP.land, DROP.land + 10),- };- drawChatFrame(ctx, s);- if (f >= DROP.land) softShadow(ctx, REPLY.x, REPLY.y, REPLY.s, REPLY.s, 22, ramp(f, DROP.land, DROP.full));- drawInk(ctx, env, f, DROP, koiLayer(env, f).canvas);- if (f >= 112) pointer(ctx, lerpP([1760, 1130], [GEN_C[0] + 18, GEN_C[1] + 6], out3(ramp(f, 116, 158))), press(f, PRESS.down, PRESS.up) * 0.8);-};-const sceneDraw = (ctx: Ctx, env: Env, f: number) => {- useCam(ctx, env, camLerp(leanCam(f), CARD_CAM, expo(ramp(f, T.draw[0] + 8, T.draw[0] + 80))));- drawChatFrame(ctx, { typed: "", caret: false, placeholder: "Describe what you want drawn…", sent: KOI_PROMPT, label: "marker comic" });- artCard(ctx, REPLY.x, REPLY.y, REPLY.s, koiLayer(env, f));-};--// ---------------------------------------------------------------- a request (the rest of the chat)-// The previous answer rides back into the thread and away, the user types, presses Generate, the-// button's ink flies into the reply and the answer blooms and plays. `push` leans into the card.-type Art = { L: CanvasImageSource; w: number; h: number; crop?: [number, number, number, number] };-type Turn = { prompt: string; label: string; t0: number; attach?: string; rate?: number; seed: number };-const turnState = (tn: Turn) => {- const times = charTimes(tn.prompt, tn.t0 + 10, tn.rate ?? 0.9, tn.seed), end = times[times.length - 1], down = Math.ceil(end + 6), up = down + 5;- return { times, typeFrom: tn.t0 + 10, end, down, up, drop: { t0: up + 6, land: up + 22, full: up + 60 }, landAt: up + 22, fullAt: up + 60 };-};-const fitCard = (a: Art) => { const hMax = INPUT.y - 40 - REPLY.y, k = Math.min(1, hMax / ((REPLY.s * a.h) / a.w)), s = Math.round(REPLY.s * k); return { s, h: Math.round((s * a.h) / a.w) }; };-const drawArt = (ctx: Ctx, a: Art, x: number, y: number, w: number, h: number) => { if (a.crop) ctx.drawImage(a.L, ...a.crop, x, y, w, h); else ctx.drawImage(a.L, x, y, w, h); };-const sceneTurn = (ctx: Ctx, env: Env, f: number, tn: Turn, art: (f: number) => Art | null, o: { prev?: Art | null; push?: boolean } = {}) => {- const k = turnState(tn), pushU = o.push ? expo(ramp(f, k.fullAt + 10, k.fullAt + 50)) : 0;- useCam(ctx, env, camLerp(HOME, CARD_CAM, pushU));- const typed = typedAt(tn.prompt, f, k.typeFrom, tn.rate ?? 0.9, tn.seed), img = tn.attach ? env.image?.(tn.attach) : undefined;- drawChatFrame(ctx, {- typed: f < k.up ? typed : "", caret: f < k.up, placeholder: "Describe what you want drawn…",- sent: f >= k.up ? tn.prompt : undefined, sentAlpha: ramp(f, k.up, k.up + 10),- attach: f >= k.up && img ? { img, label: "" } : null,- genPress: press(f, k.down, k.up), genHot: ramp(f, k.down - 8, k.down),- label: f >= k.landAt ? tn.label : undefined, labelAlpha: ramp(f, k.landAt, k.landAt + 10),- });- // the previous answer rides up out of the thread as the new request starts- if (o.prev && f < k.landAt) { const u = inOut(ramp(f, tn.t0, tn.t0 + 16)), c = fitCard(o.prev); ctx.globalAlpha = 1 - u; ctx.save(); ctx.translate(0, -120 * u); artCard(ctx, REPLY.x, REPLY.y, c.s, null); rr(ctx, REPLY.x, REPLY.y, c.s, c.h, 22); ctx.clip(); drawArt(ctx, o.prev, REPLY.x, REPLY.y, c.s, c.h); ctx.restore(); ctx.globalAlpha = 1; }- if (img && f < k.up) { const u = out3(ramp(f, tn.t0, tn.t0 + 12)); ctx.globalAlpha = u; ctx.save(); rr(ctx, INPUT.x + INPUT.w - 420, INPUT.y + 16, 104, 72, 12); ctx.clip(); ctx.drawImage(img, INPUT.x + INPUT.w - 420, INPUT.y + 16, 104, 72); ctx.restore(); ctx.globalAlpha = 1; }- const a = f >= k.drop.t0 - 6 ? art(f) : null;- if (a && f < k.landAt) drawInk(ctx, env, f, k.drop, a.L); // the drop in flight (the bloom below takes over at landing)- if (a && f >= k.landAt) {- const { s, h } = fitCard(a), grow = out3(ramp(f, k.landAt, k.fullAt)), R = lerp(18, Math.hypot(s, h), grow), c: P = [REPLY.x + s / 2, REPLY.y + h / 2];- softShadow(ctx, REPLY.x, REPLY.y, s, h, 22, grow);- ctx.save(); rr(ctx, REPLY.x, REPLY.y, s, h, 22); ctx.clip();- if (grow < 1) { pathOf(ctx, blot(c, R + 30 * (1 - grow), 77)); ctx.fillStyle = C.ink; ctx.fill(); pathOf(ctx, blot(c, Math.max(0, R - 5), 77)); ctx.clip(); }- ctx.fillStyle = C.paper; ctx.fillRect(REPLY.x, REPLY.y, s, h); drawArt(ctx, a, REPLY.x, REPLY.y, s, h); ctx.restore();- }- pointer(ctx, lerpP([GEN_C[0] + 240, GEN_C[1] + 160], [GEN_C[0] + 18, GEN_C[1] + 6], out3(ramp(f, k.end - 14, k.down))), press(f, k.down, k.up) * 0.8);- return k;-};-// the previous answer, still: the chat pulls back from it before the next request-const pullBack = (ctx: Ctx, env: Env, f: number, from: number, to: number, prev: Art) => {- useCam(ctx, env, camLerp(CARD_CAM, HOME, expo(ramp(f, from, to))));- drawChatFrame(ctx, { typed: "", caret: false, placeholder: "Describe what you want drawn…" });- const c = fitCard(prev); softShadow(ctx, REPLY.x, REPLY.y, c.s, c.h, 22, 1.4);- ctx.save(); rr(ctx, REPLY.x, REPLY.y, c.s, c.h, 22); ctx.clip(); ctx.fillStyle = C.paper; ctx.fillRect(REPLY.x, REPLY.y, c.s, c.h); drawArt(ctx, prev, REPLY.x, REPLY.y, c.s, c.h); ctx.restore();-};--// ---------------------------------------------------------------- 3: "now make it swim"-const SWIM: Turn = { prompt: "now make it swim", label: "animation · swimming through the pond", t0: T.swim[0] + 30, seed: 11 };-const SW = turnState(SWIM), SWIM_OPEN = SW.fullAt, SWIM_FULL = SW.fullAt + 30; // the card breaks out to the full frame-const swimFrame = (f: number) => Math.max(0, f - SWIM_OPEN);-const worldLayer = (env: Env, f: number, px = 1920) => plateLayer(env, `world${px}`, koiWorld, swimFrame(f), px);-const SQUARE: [number, number, number, number] = [420, 0, 1080, 1080]; // at t = 0 the world is framed like the plate: this square IS the koi plate-const sceneSwim = (ctx: Ctx, env: Env, f: number) => {- const koiArt: Art = { L: plateLayer(env, "koi", koi, 0, 1080).canvas, w: 1080, h: 1080 };- if (f < SWIM.t0) return pullBack(ctx, env, f, T.swim[0], SWIM.t0, koiArt);- if (f < SWIM_OPEN) { sceneTurn(ctx, env, f, SWIM, () => ({ L: worldLayer(env, f).canvas, w: 1080, h: 1080, crop: SQUARE }), { prev: koiArt }); return; }- // the break-out: the card's frame opens to the whole screen while the fish starts to move- const u = expo(ramp(f, SWIM_OPEN, SWIM_FULL)), L = worldLayer(env, f).canvas;- useCam(ctx, env, HOME);- if (u < 1) { ctx.globalAlpha = 1 - u; drawChatFrame(ctx, { typed: "", caret: false, placeholder: "Describe what you want drawn…", sent: SWIM.prompt, label: SWIM.label }); ctx.globalAlpha = 1; }- const x = lerp(REPLY.x, 0, u), y = lerp(REPLY.y, 0, u), w = lerp(REPLY.s, W, u), h = lerp(REPLY.s, H, u), sx = lerp(SQUARE[0], 0, u), sw = lerp(1080, 1920, u);- ctx.save(); rr(ctx, x, y, w, h, 22 * (1 - u)); ctx.clip(); ctx.drawImage(L, sx, 0, sw, 1080, x, y, w, h); ctx.restore();-};--// ---------------------------------------------------------------- 4: the circle run (Images)-// The camera dives into a lily pad in the swim, and the plates bloom out of shared circles:-// lily pad -> watch face -> full moon -> balloon. Each handover: zoom into circle A, bloom B out of-// it in ink with B's own circle exactly where A's was, zoom out on B.-type Link = { film: Film; key: string; c: P; r: number };-const RUN: Link[] = [- { film: pocketWatch, key: "watch", c: [468, 590], r: 256 },- { film: moonPhases, key: "moon", c: [539, 390], r: 70 },- { film: balloon, key: "balloon", c: [540, 352], r: 236 },-];-const RUN_T0 = T.run[0], STEP = 3 * BEAT, XF = 2 * BEAT;-const O: P = [460, 40], SB = 1000 / 1080;-// the pad the camera dives into: the lily pad nearest the right third of the frame as the run begins-const DIVE = (() => { const t = swimFrame(RUN_T0) / FPS, pads = padsOnScreen(t, W, H).filter((p) => p.x > 200 && p.x < W - 200 && p.y > 150 && p.y < H - 150); const pick = [...pads].sort((a, b) => Number(b.lily) - Number(a.lily) || Math.hypot(a.x - 1300, a.y - 540) - Math.hypot(b.x - 1300, b.y - 540))[0]; return pick.i; })();-const diveCircle = (f: number) => { const p = padsOnScreen(swimFrame(f) / FPS, W, H)[DIVE]; return { c: [p.x, p.y] as P, r: p.r * 0.9 }; };-const bigR = (ra: number, rb: number) => Math.min(560, ra * 3.2, rb * 3.2 * 1.6);-const mapOf = (L: Link, z01: number, R1: number) => {- const kb = R1 / L.r, fit = (c: number, span: number, side: number) => (kb * span < side ? side / 2 - kb * (span / 2 - c) : clamp(side / 2, side - kb * (span - c), kb * c));- const base = { at: [O[0] + SB * L.c[0], O[1] + SB * L.c[1]] as P, k: SB }, big = { at: [fit(L.c[0], 1080, W), fit(L.c[1], 1080, H)] as P, k: kb };- return { k: Math.exp(lerp(Math.log(base.k), Math.log(big.k), z01)), at: lerpP(base.at, big.at, z01) };-};-const drawPlateMapped = (ctx: Ctx, env: Env, L: Link, m: { k: number; at: P }) => {- const px = m.k > 1.4 ? 2160 : 1080, lay = plateLayer(env, L.key, L.film, 0, px), s = env.scale, x = m.at[0] - m.k * L.c[0], y = m.at[1] - m.k * L.c[1], size = 1080 * m.k;- ctx.setTransform(s, 0, 0, s, 0, 0);- softShadow(ctx, x, y, size, size, (22 * m.k) / SB, 1.3);- ctx.save(); rr(ctx, x, y, size, size, (22 * m.k) / SB); ctx.clip(); ctx.drawImage(lay.canvas, x, y, size, size); ctx.restore();-};-const shiftTo = (m: { k: number; at: P }, from: P, to: P, z01: number) => ({ k: m.k, at: [m.at[0] + (from[0] - to[0]) * z01, m.at[1] + (from[1] - to[1]) * z01] as P });-const in3ish = (t: number) => { const c = clamp(t); return c * c * (2.2 - 1.2 * c); };-const bloomInto = (ctx: Ctx, env: Env, at: P, grow: number, seed: number, drawB: () => void) => {- const R = lerp(0, 1500, in3ish(grow));- ctx.save(); ctx.setTransform(env.scale, 0, 0, env.scale, 0, 0);- pathOf(ctx, blot(at, R + 26 * (1 - grow), seed)); ctx.fillStyle = C.ink; ctx.fill();- pathOf(ctx, blot(at, Math.max(0, R - 4), seed)); ctx.clip();- ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, H); drawB(); ctx.restore();-};-const sceneRun = (ctx: Ctx, env: Env, f: number) => {- ctx.setTransform(env.scale, 0, 0, env.scale, 0, 0); ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, H);- const i = Math.min(RUN.length - 1, Math.floor((f - RUN_T0) / STEP)), u = (f - (RUN_T0 + i * STEP)) / XF;- const zin = expo(ramp(u, 0, 0.42)), zout = 1 - expo(ramp(u, 0.6, 1)), grow = ramp(u, 0.34, 0.66);- if (u >= 1) return drawPlateMapped(ctx, env, RUN[i], mapOf(RUN[i], 0, 1));- if (i === 0) { // A is the swim: zoom the full frame about the pad- const d = diveCircle(f), R1 = bigR(d.r, RUN[0].r), k = Math.exp(lerp(0, Math.log(R1 / d.r), zin)), at = lerpP(d.c, [W / 2, H / 2], zin);- const L = worldLayer(env, f, k > 1.8 ? 3840 : 1920).canvas;- ctx.drawImage(L, at[0] - k * d.c[0], at[1] - k * d.c[1], W * k, H * k);- if (grow > 0) { const mB0 = mapOf(RUN[0], 1, R1), mB = u < 0.6 ? { k: mB0.k, at } : shiftTo(mapOf(RUN[0], zout, R1), at, mB0.at, zout); bloomInto(ctx, env, mB.at, grow, 900, () => drawPlateMapped(ctx, env, RUN[0], mB)); }- return;- }- const A = RUN[i - 1], B = RUN[i], R1 = bigR(A.r, B.r);- drawPlateMapped(ctx, env, A, mapOf(A, zin, R1));- if (grow > 0) { const mA = mapOf(A, 1, R1), mB0 = mapOf(B, 1, R1), mB = u < 0.6 ? { k: mB0.k, at: mA.at } : shiftTo(mapOf(B, zout, R1), mA.at, mB0.at, zout); bloomInto(ctx, env, mB.at, grow, 900 + i, () => drawPlateMapped(ctx, env, B, mB)); }-};--// ---------------------------------------------------------------- 5: "now in toy bricks, and let it fly"-const BRICK: Turn = { prompt: "now build it in toy bricks, and let it fly", label: "animation · toy bricks", t0: T.brick[0] + 30, seed: 13 };-const BK = turnState(BRICK), BRICK_SPEED = (brickBalloon.meta.durationFrames - 1) / (T.brick[1] - 12 - BK.landAt);-const brickArt = (env: Env, f: number): Art => ({ L: plateLayer(env, "brick", brickBalloon, (f - BK.landAt) * BRICK_SPEED, 1080).canvas, w: 1080, h: 1080 });-const sceneBrick = (ctx: Ctx, env: Env, f: number) => {- const prev: Art = { L: plateLayer(env, "balloon", balloon, 0, 1080).canvas, w: 1080, h: 1080 };- if (f < BRICK.t0) return pullBack(ctx, env, f, T.brick[0], BRICK.t0, prev);- sceneTurn(ctx, env, f, BRICK, (g) => brickArt(env, Math.max(g, BK.landAt)), { prev, push: true });-};--// ---------------------------------------------------------------- 6: a painter's hand, borrowed-const REF: Turn = { prompt: "my koi again, painted in this hand", label: "adapted · the almond-blossom hand", t0: T.ref[0] + 30, attach: "almond", seed: 17 };-const RF = turnState(REF), ALMOND_SPEED = (adaptAlmond.meta.durationFrames - 40) / (T.ref[1] - 16 - RF.landAt);-const sceneRef = (ctx: Ctx, env: Env, f: number) => {- const prev = brickArt(env, T.brick[1] - 1);- if (f < REF.t0) return pullBack(ctx, env, f, T.ref[0], REF.t0, prev);- sceneTurn(ctx, env, f, REF, (g) => ({ L: plateLayer(env, "almond", adaptAlmond, 8 + Math.max(0, g - RF.landAt) * ALMOND_SPEED, 1080).canvas, w: 1080, h: 1080 }), { prev });-};--// ---------------------------------------------------------------- 7: a loop (embroidery)-const EMB: Turn = { prompt: "and one in embroidery, on a loop", label: "loop · seamless", t0: T.emb[0] + 20, seed: 19 };-const EM = turnState(EMB), embArt = (env: Env, f: number): Art => ({ L: plateLayer(env, "emb", embroideryAlive, Math.max(0, f - EM.landAt) % embroideryAlive.meta.durationFrames, 1080).canvas, w: 1080, h: 1080 });-const sceneEmb = (ctx: Ctx, env: Env, f: number) => {- const prev: Art = { L: plateLayer(env, "almond", adaptAlmond, adaptAlmond.meta.durationFrames - 1, 1080).canvas, w: 1080, h: 1080 };- sceneTurn(ctx, env, f, EMB, (g) => embArt(env, g), { prev, push: true });-};--// ---------------------------------------------------------------- 8: a live page (Bit)-const WEB: Turn = { prompt: "a robot for my landing page who watches the visitor", label: "interactive · watches the pointer", t0: T.web[0] + 20, rate: 0.8, seed: 23 };-const WB = turnState(WEB);-const BROWSER = { x: 330, y: 70, w: 1460, h: 940 }, HERO = { x: 1090, y: 230, s: 620 }, START = { x: 450, y: 610, w: 250, h: 72 };-const webPointer = (g: number): P => { const pts: P[] = [[1580, 900], [1380, 420], [840, 330], [START.x + 140, START.y + 40]], u = clamp(g / 60) * (pts.length - 1), i = Math.min(pts.length - 2, Math.floor(u)); return lerpP(pts[i], pts[i + 1], inOut(u - i)); };-let LOG: InputLog | null = null;-const webLog = (): InputLog => {- const toPiece = (x: number, y: number): P => [((x - HERO.x) * 560) / HERO.s, ((y - HERO.y) * 560) / HERO.s];- const [sx, sy] = toPiece(START.x, START.y), log: InputLog = [{ tick: 0, type: "rect", target: "start", x: sx, y: sy, w: (START.w * 560) / HERO.s, h: (START.h * 560) / HERO.s }];- for (let t = 0; t <= 240; t += 2) { const [x, y] = webPointer(t / 2), [px, py] = toPiece(x, y); log.push({ tick: t, type: "move", x: px, y: py, value: "mouse" }); }- log.push({ tick: 118, type: "enter", target: "start" }, { tick: 170, type: "down", target: "start" }, { tick: 178, type: "up", target: "start" });- return log.sort((a, b) => a.tick - b.tick);-};-const subEnvOf = (env: Env, key: string, size: number, scale: number): Env => { const k = `sub:${key}:${scale}`; let e = env.cache.get(k) as Env | undefined; if (!e) { e = { W: size, H: size, scale, cache: new Map(), canvas: env.canvas, image: env.image }; env.cache.set(k, e); } return e; };-const webPage = (ctx: Ctx, env: Env, open: number, tick: number) => {- useCam(ctx, env, HOME); ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, H);- const e = expo(open), bx = lerp(CHAT.x, BROWSER.x, e), by = lerp(CHAT.y, BROWSER.y, e), bw = lerp(CHAT.w, BROWSER.w, e), bh = lerp(CHAT.h, BROWSER.h, e);- softShadow(ctx, bx, by, bw, bh, 26, 1.4); ctx.fillStyle = "#fff"; rr(ctx, bx, by, bw, bh, 26); ctx.fill();- ctx.save(); rr(ctx, bx, by, bw, bh, 26); ctx.clip();- ctx.fillStyle = "#f4f1ea"; ctx.fillRect(bx, by, bw, 64); ["#e8715a", "#e9b949", "#7cbf6b"].forEach((c, i) => { ctx.fillStyle = c; ctx.beginPath(); ctx.arc(bx + 34 + i * 26, by + 32, 8, 0, Math.PI * 2); ctx.fill(); });- ctx.fillStyle = "#fff"; rr(ctx, bx + 150, by + 14, Math.min(560, bw - 300), 36, 18); ctx.fill(); ctx.fillStyle = C.soft; ctx.font = SANS(500, 19); ctx.textBaseline = "middle"; ctx.fillText("your-site.com", bx + 176, by + 33);- ctx.globalAlpha = ramp(open, 0.5, 1);- ctx.fillStyle = C.ink; ctx.font = SANS(700, 76); ctx.textBaseline = "alphabetic"; ctx.fillText("Meet Bit.", START.x, 420);- ctx.font = SANS(500, 30); ctx.fillStyle = C.soft; ctx.fillText("He reads along with you.", START.x, 480); ctx.fillText("Try the button.", START.x, 522);- ctx.fillStyle = tick >= 118 ? C.accentDeep : C.ink; rr(ctx, START.x, START.y, START.w, START.h, 36); ctx.fill(); ctx.fillStyle = "#fff"; ctx.font = SANS(600, 28); ctx.textAlign = "center"; ctx.textBaseline = "middle"; ctx.fillText("Get started", START.x + START.w / 2, START.y + START.h / 2 + 1); ctx.textAlign = "left";- LOG ??= webLog();- const st = stateAt(tick, LOG, mascotHero.input), px = Math.round(HERO.s * env.scale), L = selfLayer(env, "bit", px, px), sub = subEnvOf(env, "bit", 560, px / 560);- mascotHero.draw(L.ctx, tick, sub, st);- ctx.save(); rr(ctx, HERO.x, HERO.y, HERO.s, HERO.s, 28); ctx.clip(); ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(L.canvas, HERO.x * env.scale, HERO.y * env.scale); ctx.restore(); useCam(ctx, env, HOME);- ctx.globalAlpha = 1; ctx.restore();- pointer(ctx, webPointer(tick / 2), tick >= 170 && tick < 178 ? 1 : 0);-};-const webTick = (f: number) => Math.max(0, (f - WB.landAt - 10) * 2);-const sceneWeb = (ctx: Ctx, env: Env, f: number) => {- if (f < WB.landAt) { sceneTurn(ctx, env, f, WEB, () => null, { prev: embArt(env, T.emb[1] - 1) }); return; }- webPage(ctx, env, ramp(f, WB.landAt, WB.landAt + 24), webTick(f));-};--// ---------------------------------------------------------------- 9: a film, with its own score-const FILMT: Turn = { prompt: "now a short film, with its own music", label: "film · with its own score", t0: T.film[0] + 26, seed: 29 };-const FM = turnState(FILMT);-const sceneFilm = (ctx: Ctx, env: Env, f: number) => {- if (f < FILMT.t0) { webPage(ctx, env, 1 - ramp(f, T.film[0], FILMT.t0), webTick(T.web[1] - 1)); return; } // the page folds back into the chat- sceneTurn(ctx, env, f, FILMT, (g) => ({ L: plateLayer(env, "lep", mechanicalLepidoptera, 1040 + Math.max(0, g - FM.landAt) * 1.5, 1080).canvas, w: 1080, h: 1080 }));- if (f >= FM.fullAt) {- const wave = waveform(env), x0 = REPLY.x + REPLY.s + 60, x1 = CHAT.x + CHAT.w - 70, y = REPLY.y + REPLY.s / 2, head = (f - FM.landAt) * 1.5 + 1040;- ctx.globalAlpha = ramp(f, FM.fullAt, FM.fullAt + 12);- for (let i = 0; i < 90; i++) { const a = wave[Math.max(0, Math.min(wave.length - 1, Math.floor(head - 45 + i)))] ?? 0, x = lerp(x0, x1, i / 89), h = 8 + a * 260; ctx.fillStyle = i < 45 ? C.accent : C.line; rr(ctx, x - 2.5, y - h / 2, 5, h, 2.5); ctx.fill(); }- ctx.fillStyle = C.soft; ctx.font = SANS(500, 18); ctx.textBaseline = "alphabetic"; ctx.fillText("its score: a music box, drawn in code too", x0, y + 180);- ctx.globalAlpha = 1;- }-};-const waveform = (env: Env): number[] => {- let w = env.cache.get("wave") as number[] | undefined; if (w) return w;- const sr = 6000, [L] = mechanicalLepidoptera.audio!(sr), per = sr / FPS; w = []; let peak = 1e-6;- for (let i = 0; i < L.length / per; i++) { let s = 0; for (let j = 0; j < per; j++) { const v = L[Math.floor(i * per + j)] ?? 0; s += v * v; } const r = Math.sqrt(s / per); w.push(r); peak = Math.max(peak, r); }- w = w.map((v) => Math.pow(v / peak, 0.6)); env.cache.set("wave", w); return w;-};--// ---------------------------------------------------------------- the chapter rail-// The story's words, written onto the left edge as each is delivered; the live one in ink with an-// accent dot, the delivered ones quiet. At the reveal they gather in the sentence's own order.-const CH = [- { word: "Illustrations", at: [300] },- { word: "Animations", at: [SWIM_OPEN, BK.landAt, WB.landAt] },- { word: "Images", at: [T.run[0] + 20, RF.landAt] },- { word: "Loops", at: [EM.landAt] },- { word: "Films", at: [FM.landAt] },-];-const SENTENCE = ["Images", "Illustrations", "Loops", "Animations", "Films"];-const railPos = (i: number): P => [56, 540 - (CH.length * 64) / 2 + i * 64 + 40];-const drawRail = (ctx: Ctx, env: Env, f: number) => {- ctx.setTransform(env.scale, 0, 0, env.scale, 0, 0); ctx.textBaseline = "alphabetic";- const live = CH.map((c, i) => ({ i, t: Math.max(...c.at.filter((a) => a <= f), -1) })).sort((a, b) => b.t - a.t)[0];- CH.forEach((c, i) => {- const a = spring(f, c.at[0], 0.3, 0.72); if (a <= 0) return;- const [x, y] = railPos(i), on = live.t >= 0 && live.i === i, pulse = on ? 1 - clamp((f - live.t) / 20) : 0;- ctx.globalAlpha = clamp(a); ctx.font = SANS(700, 34 + 4 * pulse);- ctx.fillStyle = "rgba(255,253,248,0.55)"; ctx.fillText(c.word, x + 1.5 - 24 * (1 - a), y + 2); // a soft lift off whatever is behind- ctx.fillStyle = on ? C.ink : C.mute; ctx.fillText(c.word, x - 24 * (1 - a), y);- if (on) { ctx.fillStyle = C.accent; ctx.beginPath(); ctx.arc(x - 22, y - 12, 6 + 3 * pulse, 0, Math.PI * 2); ctx.fill(); }- });- ctx.globalAlpha = 1;-};--// ---------------------------------------------------------------- 10: all in pure code-const kw = /\b(export|const|type|as)\b/g;-const CODE = ["// THE TIMELINE, in frames. Every boundary is on a bar of the score.", "export const T = {", ...Object.entries(T).map(([k, v]) => ` ${k}: [${v[0]}, ${v[1]}],`), "} as const;"];-const sceneReveal = (ctx: Ctx, env: Env, f: number) => {- const r0 = T.reveal[0], u = expo(ramp(f, r0, r0 + 40)), lines = ramp(f, r0 + 16, r0 + 90);- ctx.setTransform(env.scale, 0, 0, env.scale, 0, 0); ctx.fillStyle = "#1b1916"; ctx.fillRect(0, 0, W, H);- const ed = { x: 60, y: 70, w: 900, h: 940 };- ctx.globalAlpha = u; ctx.fillStyle = "#23201c"; rr(ctx, ed.x, ed.y, ed.w, ed.h, 20); ctx.fill();- ctx.fillStyle = "#8f8676"; ctx.font = MONO(18); ctx.textBaseline = "middle"; ctx.fillText("launch.ts", ed.x + 28, ed.y + 34);- let left = Math.floor(lines * CODE.join("").length);- CODE.forEach((ln, i) => {- const n = Math.max(0, Math.min(ln.length, left)); left -= ln.length; if (n <= 0) return;- const y = ed.y + 90 + i * 44, text = ln.slice(0, n);- ctx.fillStyle = "#5d564b"; ctx.font = MONO(18); ctx.fillText(String(i + 1).padStart(2, " "), ed.x + 24, y);- ctx.font = MONO(22); ctx.fillStyle = text.trim().startsWith("//") ? "#7e9a6c" : "#e9e1d3"; ctx.fillText(text, ed.x + 74, y);- if (!text.trim().startsWith("//")) { ctx.fillStyle = C.accent; for (const m of text.matchAll(kw)) ctx.fillText(m[0], ed.x + 74 + ctx.measureText(text.slice(0, m.index)).width, y); }- });- ctx.globalAlpha = 1;- // the film, shrunk into its canvas pane, still playing its last scene- const pane = { x: lerp(0, 1010, u), y: lerp(0, 150, u), w: lerp(W, 850, u), h: lerp(H, 478, u) };- const L = selfLayer(env, "inner", Math.round(W * env.scale * 0.5), Math.round(H * env.scale * 0.5)), sub: Env = { ...env, scale: env.scale * 0.5 };- sceneFilm(L.ctx, sub, T.film[1] - 40 + (f - r0) * 0.25);- ctx.setTransform(env.scale, 0, 0, env.scale, 0, 0);- ctx.save(); rr(ctx, pane.x, pane.y, pane.w, pane.h, 18 * u); ctx.clip(); ctx.drawImage(L.canvas, pane.x, pane.y, pane.w, pane.h); ctx.restore();- ctx.globalAlpha = u; ctx.fillStyle = "#8f8676"; ctx.font = MONO(18); ctx.textBaseline = "middle"; ctx.fillText("canvas · 1920×1080 · 30 fps · every frame and every sound computed", 1010, 122); ctx.globalAlpha = 1;- // the chapter words fly from the rail to the sentence, one a beat, then the line lands on the downbeat- // the slots are laid out by measured width, as a line of type: two lines under the pane- const g0 = r0 + 40, gap = 16, maxX = 1860; ctx.font = SANS(700, 44); ctx.textBaseline = "alphabetic";- const slots: P[] = []; let sx = 1010, sy = 720;- SENTENCE.forEach((w, j) => { const wd = ctx.measureText(w + (j < 4 ? "," : "")).width; if (sx + wd > maxX) { sx = 1010; sy += 70; } slots.push([sx, sy]); sx += wd + gap; });- SENTENCE.forEach((word, j) => {- const ci = CH.findIndex((c) => c.word === word), from = railPos(ci), q = inOut(ramp(f, g0 + j * 10, g0 + j * 10 + 30)), p = lerpP(from, slots[j], q);- ctx.font = SANS(700, lerp(34, 44, q)); ctx.fillStyle = mixTo("#8a8173", "#f4efe6", q); ctx.fillText(word + (j < 4 ? "," : ""), p[0], p[1]);- });- const hit = spring(f, 2880, 0.32, 0.62); // bar 36 of the score: the home chord- if (hit > 0) { ctx.globalAlpha = clamp(hit); ctx.font = SANS(800, 84); ctx.fillStyle = C.accent; ctx.fillText("All in pure code.", 1010, 920 + (1 - hit) * 26); ctx.globalAlpha = 1; }-};-const mixTo = (a: string, b: string, t: number) => { const h = (s: string) => [1, 3, 5].map((i) => parseInt(s.slice(i, i + 2), 16)); const x = h(a), y = h(b); return `rgb(${x.map((v, i) => Math.round(lerp(v, y[i], clamp(t)))).join(",")})`; };--const sceneEnd = (ctx: Ctx, env: Env, f: number) => {- ctx.setTransform(env.scale, 0, 0, env.scale, 0, 0); ctx.fillStyle = "#f4efe6"; ctx.fillRect(0, 0, W, H);- const L = plateLayer(env, "banner", bannerFilm, Math.min(200, 12 + (f - T.end[0]) * 1.6), 2000);- ctx.drawImage(L.canvas, 0, 230, 1920, (1920 * 620) / 2000);- ctx.fillStyle = C.ink; ctx.font = MONO(30); ctx.textAlign = "center"; ctx.textBaseline = "middle";- ctx.globalAlpha = ramp(f, T.end[0] + 40, T.end[0] + 56); ctx.fillText("/plugin install anidoodle@alexgreensh-anidoodle", 960, 910);- ctx.fillStyle = C.soft; ctx.font = SANS(500, 26); ctx.fillText("Images · Illustrations · Loops · Animations · Films · Claude Code and Codex · github.com/alexgreensh/anidoodle", 960, 972); ctx.textAlign = "left"; ctx.globalAlpha = 1;-};--// ---------------------------------------------------------------- the sound-// The score, cut to the film's length, plus the interface: a key click per character, the Generate-// thock, the ink's plip as it lands, a whoosh for every dive and break-out. All synthesized.-const launchAudio = (sr: number): [Float32Array, Float32Array] => {- const n = Math.round((N / FPS) * sr), L = new Float32Array(n), R = new Float32Array(n);- const m = renderPiece(launchLofi(), sr); for (let i = 0; i < n && i < m.L.length; i++) { L[i] = m.L[i]; R[i] = m.R[i]; }- const fade = Math.round(1.5 * sr); for (let i = 0; i < fade; i++) { const g = i / fade; L[n - 1 - i] *= g; R[n - 1 - i] *= g; }- const r = rng(4242), add = (t: number, len: number, fn: (s: number) => number, gain: number, pan = 0) => { const i0 = Math.round(t * sr); for (let i = 0; i < len * sr && i0 + i < n; i++) { if (i0 + i < 0) continue; const v = fn(i / sr) * gain; L[i0 + i] += v * (1 - Math.max(0, pan)); R[i0 + i] += v * (1 + Math.min(0, pan)); } };- const click = (fr: number) => { const f0 = 2600 + r() * 1400, ph = r() * 6; add(fr / FPS, 0.03, (s) => Math.sin(2 * Math.PI * f0 * s + ph) * Math.exp(-s / 0.004) + (r() - 0.5) * Math.exp(-s / 0.002) * 0.6, 0.05, (r() - 0.5) * 0.4); };- const thock = (fr: number) => add(fr / FPS, 0.14, (s) => Math.sin(2 * Math.PI * (70 + 90 * Math.exp(-s / 0.02)) * s) * Math.exp(-s / 0.05), 0.2);- const plip = (fr: number) => add(fr / FPS, 0.16, (s) => Math.sin(2 * Math.PI * (320 + 700 * Math.exp(-s / 0.03)) * s) * Math.exp(-s / 0.06), 0.12);- const whoosh = (fr: number, len = 0.7) => { let z = 0; add(fr / FPS, len, (s) => { z += 0.12 * ((r() - 0.5) - z); return z * Math.sin((Math.PI * s) / len) ** 2; }, 0.55); };- charTimes(KOI_PROMPT, KOI_TYPE.t0, KOI_TYPE.rate, KOI_TYPE.seed).forEach(click); thock(PRESS.down); plip(DROP.land);- [SWIM, BRICK, REF, EMB, WEB, FILMT].forEach((tn) => { const k = turnState(tn); k.times.forEach(click); thock(k.down); plip(k.landAt); });- whoosh(SWIM_OPEN, 0.9); [0, 1, 2].forEach((i) => whoosh(RUN_T0 + i * STEP, 0.9)); whoosh(T.reveal[0], 1.2);- return [L, R];-};--// ---------------------------------------------------------------- the film-const withRail = (draw: (ctx: Ctx, env: Env, f: number) => void) => (ctx: Ctx, env: Env, f: number) => { draw(ctx, env, f); drawRail(ctx, env, f); };-const shot = (id: keyof typeof T, draw: (ctx: Ctx, env: Env, f: number) => void) => ({ id, start: T[id][0], end: T[id][1], draw: (ctx: Ctx, local: number, env: Env) => draw(ctx, env, T[id][0] + local) });-export const launch: Film = {- meta: { title: "anidoodle · launch", W, H, fps: FPS, bpm: 90, durationFrames: N, raster: "cpu", kind: "launch" },- assets: { images: { almond: "assets/refs/vangogh-almond-blossom.jpg" } }, // public domain; provenance in engine/assets/refs/PROVENANCE.json- shots: [- shot("type", withRail(sceneOpen)), shot("gen", withRail(sceneOpen)), shot("draw", withRail(sceneDraw)), shot("swim", withRail(sceneSwim)),- shot("run", withRail(sceneRun)), shot("brick", withRail(sceneBrick)), shot("ref", withRail(sceneRef)), shot("emb", withRail(sceneEmb)),- shot("web", withRail(sceneWeb)), shot("film", withRail(sceneFilm)), shot("reveal", sceneReveal), shot("end", sceneEnd),- ],- audio: launchAudio,-};--// THE MOTION TEST: the Generate press, the drop and the bloom, on their own.-export const launchClip: Film = {- meta: { ...launch.meta, title: "anidoodle · launch, the ink test", durationFrames: 120 },- assets: launch.assets,- shots: [{ id: "ink", start: 0, end: 120, draw: (ctx, local, env) => { const f = 140 + local, sh = launch.shots.find((x) => f >= x.start && f < x.end)!; sh.draw(ctx, f - sh.start, env); } }],-};-export const KEYS = () => ({ SWIM: SW, BRICK: BK, REF: RF, EMB: EM, WEB: WB, FILM: FM, KOI_DONE, SWIM_OPEN, DIVE });diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launch2.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launch2.tsdeleted file mode 100644index ede7a6e..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launch2.ts+++ /dev/null@@ -1,334 +0,0 @@-// LAUNCH, CUT 2. 69 s on the 26-bar score (music/pieces/launch.ts, launchLofi2): 90 bpm, a bar is-// 80 frames. Alex's notes on cut 1 are the brief: it read as a slide deck; nobody could tell it-// was code; the drawings were slow; the waits were long; the styles came one at a time; the site-// was barely shown; the type was set, not drawn; the logo appeared once; the end card was cut out.-// So: the logo writes itself first; the koi draws beside its own code streaming ("no image model,-// just code"); a real chat thread that keeps every answer and scrolls; every drawing 3-6x faster;-// every change of scene a move (break-outs, whip pans, punch-ins, card flips), never a cut; the 31-// styles as a rolling wall the camera punches into; the full website tour; the words drawn in their-// media; the corner logo throughout; an end card composed for the frame, with both install lines.-import type { Ctx, Env, P } from "./core";-import type { Film } from "./film";-import {- C, GEN, HOME, INPUT, MONO, REPLY, SANS, TEXT, blot, camLerp, caretAt, charTimes, clamp, drawChatFrame, expo, inkDrop, inOut, lerp, lerpP,- out3, pathOf, plateLayer, pointer, press, ramp, rr, selfLayer, softShadow, typedAt, useCam, type Cam,-} from "./launchKit";-import { koiDraw } from "./koiDraw";-import { koi } from "./koi";-import { koiWorld } from "./koiWorld";-import { brickBalloon } from "./brickBalloon";-import { adaptAlmond } from "./adaptAlmond";-import { embroideryAlive } from "./embroideryAlive";-import { webTour } from "./webTour";-import { mechanicalLepidoptera } from "./mechanicalLepidoptera";-import { drawWall, wallCam, cardOf, PUNCH, PUNCH_IN, type Punch } from "./launchGallery";-import { caption, logo, logoBox, logoBug, logoCentred, sentence, writeOn, measure } from "./kinetic";-import { KOI_CODE } from "./launchCode";-import { launchLofi2 } from "./music/pieces/launch";-import { renderPiece } from "./music/render";-import { rng } from "./core";--const W = 1920, H = 1080, FPS = 30, BEAT = 20;-export const T2 = {- open: [0, 80], ask: [80, 200], code: [200, 360], swim: [360, 560], wall: [560, 800], brick: [800, 1040],- hand: [1040, 1200], loop: [1200, 1360], web: [1360, 1760], film: [1760, 1840], words: [1840, 2040], end: [2040, 2160],-} as const;-const N = T2.end[1];--// ---------------------------------------------------------------- small helpers-const screen = (ctx: Ctx, env: Env) => ctx.setTransform(env.scale, 0, 0, env.scale, 0, 0);-const GEN_C: P = [GEN.x + GEN.w / 2, GEN.y + GEN.h / 2];-// a whip: the outgoing frame smeared along the move (drawn several times, fading), the incoming following it in-const smear = (ctx: Ctx, env: Env, L: CanvasImageSource, dx: number, dy: number, blur: number) => { screen(ctx, env); for (let k = 5; k >= 0; k--) { ctx.globalAlpha = k === 0 ? 1 : 0.16; ctx.drawImage(L, dx - blur * k * Math.sign(dx || 1) * (dx ? 1 : 0), dy - blur * k * Math.sign(dy || 1) * (dy ? 1 : 0), W, H); } ctx.globalAlpha = 1; };--// ---------------------------------------------------------------- the conversation-// One thread for the whole film. Every answer stays in it; the thread scrolls as it grows, eased.-type Art = { src: (env: Env, f: number) => CanvasImageSource; crop?: [number, number, number, number] };-type Item = { kind: "user"; at: number; text: string; attach?: string } | { kind: "card"; at: number; art: Art; label: string; s: number; land: { t0: number; land: number; full: number } };-const KOI_PROMPT = "a koi turning under lily pads, marker comic";-const ASK = { times: charTimes(KOI_PROMPT, 84, 1.0, 7), down: 160, up: 166 };-const DROP0 = { t0: 172, land: 188, full: 222 };-const KOI_SPEED = 3.6, KOI_DONE = DROP0.land + (koiDraw.meta.durationFrames - 30) / KOI_SPEED;-const SWIM_PROMPT = "now make it swim";-const SW = (() => { const times = charTimes(SWIM_PROMPT, 378, 0.55, 11), down = Math.ceil(times[times.length - 1] + 4), up = down + 5; return { times, down, up, drop: { t0: up + 5, land: up + 19, full: up + 40 } }; })();-const SWIM_START = SW.up + 6, SWIM_OUT = SWIM_START + 22, SWIM_FULL = SWIM_OUT + 34; // the koi in the thread starts to swim in its card, then the card opens to the full frame-const swimArt: Art = { src: (env, f) => plateLayer(env, "world1920", koiWorld, Math.max(0, f - SWIM_START), 1920).canvas, crop: [420, 0, 1080, 1080] };-// the koi's card: it draws itself, holds, and when asked to swim, swims right there in the thread (the pond world framed exactly like the plate)-const koiArt: Art = { src: (env, f) => {- if (f < KOI_DONE) return plateLayer(env, "koiDraw", koiDraw, (f - DROP0.land) * KOI_SPEED, 1080).canvas;- if (f < SWIM_START) return plateLayer(env, "koi", koi, 0, 1080).canvas;- const Lw = plateLayer(env, "world1920", koiWorld, f - SWIM_START, 1920).canvas, sq = selfLayer(env, "koiswim", 1080, 1080); sq.ctx.drawImage(Lw, 420, 0, 1080, 1080, 0, 0, 1080, 1080); return sq.canvas;-} };-const HAND_PROMPT = "my koi, painted in this hand";-const HD = (() => { const times = charTimes(HAND_PROMPT, 1068, 0.5, 17), down = Math.ceil(times[times.length - 1] + 4), up = down + 5; return { times, down, up, drop: { t0: up + 5, land: up + 19, full: up + 40 } }; })();-const ALMOND_SPEED = (adaptAlmond.meta.durationFrames - 40) / (T2.hand[1] - 8 - HD.drop.land);-const FLIP = T2.loop[0] + 2; // the Van Gogh card turns over and the embroidery is on its back-const almondArt: Art = { src: (env, f) => (f < FLIP + 6 ? plateLayer(env, "almond", adaptAlmond, 8 + Math.max(0, f - HD.drop.land) * ALMOND_SPEED, 1080) : plateLayer(env, "emb", embroideryAlive, (f - FLIP) % embroideryAlive.meta.durationFrames, 1080)).canvas };-const THREAD: Item[] = [- { kind: "user", at: ASK.up, text: KOI_PROMPT },- { kind: "card", at: DROP0.land, art: koiArt, label: "marker comic", s: 560, land: DROP0 },- { kind: "user", at: SW.up, text: SWIM_PROMPT },- { kind: "user", at: HD.up, text: HAND_PROMPT, attach: "almond" },- { kind: "card", at: HD.drop.land, art: almondArt, label: "adapted · the almond-blossom hand", s: 460, land: HD.drop },-];-const TOP = 170, VIEW_BOTTOM = INPUT.y - 26, BUBBLE = 58, ATTACH = 150;-const layout = () => { let y = TOP; return THREAD.map((it) => { const h = it.kind === "user" ? BUBBLE + (it.attach ? ATTACH + 10 : 0) : it.s + 34; const r = { it, y, h }; y += h + 26; return r; }); };-const LAYOUT = layout();-// the scroll: each new item eases the thread up so the newest thing sits just above the composer-const scrollAt = (f: number) => { let s = 0; LAYOUT.forEach((L) => { const want = Math.max(0, L.y + L.h - VIEW_BOTTOM); const prev = s; if (want > prev) s += (want - prev) * expo(ramp(f, L.it.at - 2, L.it.at + 16)); }); return s; };-export const cardRect = (i: number, f: number) => { const L = LAYOUT[i], it = L.it as Extract<Item, { kind: "card" }>; return { x: REPLY.x, y: L.y + 34 - scrollAt(f), s: it.s }; };--const drawUser = (ctx: Ctx, env: Env, it: Extract<Item, { kind: "user" }>, y: number, a: number) => {- ctx.globalAlpha = a; ctx.font = SANS(500, 26);- const tw = ctx.measureText(it.text).width, bw = tw + 52, bx = 1560 - bw; let yy = y;- const img = it.attach ? env.image?.(it.attach) : undefined;- if (img) { ctx.save(); rr(ctx, 1560 - 240, yy, 240, ATTACH, 16); ctx.clip(); ctx.drawImage(img, 1560 - 240, yy, 240, ATTACH); ctx.restore(); yy += ATTACH + 10; }- ctx.fillStyle = C.chip; rr(ctx, bx, yy, bw, BUBBLE - 2, 22); ctx.fill(); ctx.fillStyle = C.ink; ctx.textBaseline = "middle"; ctx.fillText(it.text, bx + 26, yy + 29); ctx.globalAlpha = 1;-};-const drawCard = (ctx: Ctx, env: Env, it: Extract<Item, { kind: "card" }>, x: number, y: number, f: number, flip = 1) => {- ctx.fillStyle = C.ink; ctx.globalAlpha = ramp(f, it.land.land, it.land.land + 10); ctx.beginPath(); ctx.arc(x + 9, y - 16, 7, 0, Math.PI * 2); ctx.fill();- ctx.font = SANS(600, 20); ctx.textBaseline = "middle"; ctx.fillText(f >= FLIP + 6 && it.art === almondArt ? "loop · embroidery, seamless" : it.label, x + 26, y - 15); ctx.globalAlpha = 1;- const s = it.s, grow = out3(ramp(f, it.land.land, it.land.full)), c: P = [x + s / 2, y + s / 2], L = it.art.src(env, f);- ctx.save(); ctx.translate(c[0], c[1]); ctx.scale(flip, 1); ctx.translate(-c[0], -c[1]);- softShadow(ctx, x, y, s, s, 20, grow * 1.3);- ctx.save(); rr(ctx, x, y, s, s, 20); ctx.clip();- if (grow < 1) { pathOf(ctx, blot(c, lerp(16, s * 0.8, grow) + 28 * (1 - grow), 77)); ctx.fillStyle = C.ink; ctx.fill(); pathOf(ctx, blot(c, Math.max(0, lerp(16, s * 0.8, grow) - 5), 77)); ctx.clip(); }- ctx.fillStyle = C.paper; ctx.fillRect(x, y, s, s);- if (it.art.crop) ctx.drawImage(L, ...it.art.crop, x, y, s, s); else ctx.drawImage(L, x, y, s, s);- ctx.restore(); ctx.restore();-};-// the drop in flight from Generate to where the new card will land-const drawDrop = (ctx: Ctx, f: number, d: { t0: number; land: number }, to: P) => inkDrop(ctx, f, d, to);-type ChatO = { typed: string; caret: boolean; press: number; hot: number; flip?: number; hideCard?: number };-const drawChat = (ctx: Ctx, env: Env, f: number, o: ChatO) => {- drawChatFrame(ctx, { typed: o.typed, caret: o.caret, placeholder: "Describe what you want drawn…", genPress: o.press, genHot: o.hot });- const sc = scrollAt(f);- ctx.save(); ctx.beginPath(); ctx.rect(300, 158, 1320, VIEW_BOTTOM - 158); ctx.clip();- LAYOUT.forEach((L, i) => {- if (f < L.it.at) return;- const y = L.y - sc; if (y > VIEW_BOTTOM || y + L.h < 100) return;- if (L.it.kind === "user") drawUser(ctx, env, L.it, y, ramp(f, L.it.at, L.it.at + 8));- else if (o.hideCard !== i) drawCard(ctx, env, L.it, REPLY.x, y + 34, f, i === 4 ? (o.flip ?? 1) : 1);- });- ctx.restore();- // drops in flight land on the card's place in the thread- LAYOUT.forEach((L, i) => { if (L.it.kind !== "card") return; const r = cardRect(i, f); drawDrop(ctx, f, L.it.land, [r.x + r.s / 2, r.y + r.s / 2]); });-};--// ---------------------------------------------------------------- the corner logo-const BUG: P = [1700, 1040];-const bug = (ctx: Ctx, env: Env, f: number) => logoBug(ctx, env, f, BUG[0], BUG[1], 0.9, { t0: 70, fps: FPS });--// ---------------------------------------------------------------- 0: the logo writes itself-const sceneOpen = (ctx: Ctx, env: Env, f: number) => {- const u = expo(ramp(f, 58, 80));- useCam(ctx, env, HOME);- drawChatFrame(ctx, { typed: "", caret: false, placeholder: "Describe what you want drawn…" });- screen(ctx, env); ctx.globalAlpha = 1 - u; ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, H); ctx.globalAlpha = 1;- // the wordmark, big, then it shrinks away toward its corner as the chat comes up under it- const em = lerp(150, 26, u), cx = lerp(W / 2, BUG[0], u), cy = lerp(H / 2 - 10, BUG[1] - 20, u);- ctx.globalAlpha = 1 - ramp(f, 72, 80); logoCentred(ctx, env, cx, cy, em, ramp(f, 2, 50), { pen: f < 56 }); ctx.globalAlpha = 1;- if (f < 58) caption(ctx, env, "hand-drawn art, written as code", W / 2, H / 2 + 210, 28, ramp(f, 30, 52), "plain", { align: "center" });-};--// ---------------------------------------------------------------- 1: the ask-const askCam = (ctx: Ctx, f: number): Cam => {- const typed = typedAt(KOI_PROMPT, f, ASK.times), [cx] = caretAt(ctx, typed), macro: Cam = { c: [Math.max(TEXT.x + 330, cx - 110), 934], z: 2.4 };- return f < 136 ? macro : camLerp(macro, HOME, expo(ramp(f, 136, 158)));-};-// the code composition: the koi card at left of centre, its code streaming on the right-const CODE_CAM = (): Cam => { const r = cardRect(1, 230), z = 1.25; return { c: [r.x + r.s / 2 + (W / 2 - 520) / z, r.y + r.s / 2 - (620 - H / 2) / z], z }; }; // the card lands at (520, 620), the words above it, the code at right-const sceneAsk = (ctx: Ctx, env: Env, f: number) => {- const cam = f < T2.ask[1] ? (f < 160 ? askCam(ctx, f) : camLerp(HOME, CODE_CAM(), expo(ramp(f, 186, 226)))) : HOME;- useCam(ctx, env, cam);- const typed = typedAt(KOI_PROMPT, f, ASK.times);- drawChat(ctx, env, f, { typed: f < ASK.up ? typed : "", caret: f < ASK.up, press: press(f, ASK.down, ASK.up), hot: ramp(f, 150, 158) });- if (f >= 136) pointer(ctx, lerpP([1760, 1130], [GEN_C[0] + 18, GEN_C[1] + 6], out3(ramp(f, 138, 158))), press(f, ASK.down, ASK.up) * 0.8);- bug(ctx, env, f);-};--// ---------------------------------------------------------------- 2: it's code-const sceneCode = (ctx: Ctx, env: Env, f: number) => {- const back = expo(ramp(f, 328, 359));- useCam(ctx, env, camLerp(CODE_CAM(), HOME, back));- drawChat(ctx, env, f, { typed: "", caret: false, press: 0, hot: 0 });- // the editor slides in from the right, the lines stream in time with the drawing- screen(ctx, env);- const inU = expo(ramp(f, 200, 222)) * (1 - back), ex = lerp(W + 40, 1010, inU), ey = 110, ew = 830, eh = 860;- if (inU > 0.001) {- softShadow(ctx, ex, ey, ew, eh, 22, 1.6); ctx.fillStyle = "#1f1c18"; rr(ctx, ex, ey, ew, eh, 22); ctx.fill();- ctx.fillStyle = "#8f8676"; ctx.font = MONO(16); ctx.textBaseline = "middle"; ctx.fillText("koi.ts · drawFish() · running", ex + 26, ey + 30);- const prog = clamp((f - DROP0.land) / (KOI_DONE - DROP0.land)), shown = Math.floor(prog * KOI_CODE.length), first = Math.max(0, shown - 24);- ctx.save(); ctx.beginPath(); ctx.rect(ex, ey + 56, ew, eh - 70); ctx.clip();- for (let i = first; i < Math.min(KOI_CODE.length, shown + 1); i++) {- const y = ey + 80 + (i - first) * 32, ln = KOI_CODE[i], partial = i === shown ? ln.slice(0, Math.floor(((prog * KOI_CODE.length) % 1) * ln.length)) : ln;- ctx.fillStyle = "#5d564b"; ctx.font = MONO(13); ctx.fillText(String(i + 1).padStart(3, " "), ex + 16, y);- ctx.font = MONO(15); ctx.fillStyle = partial.trim().startsWith("//") ? "#8faa7c" : "#ece4d6"; ctx.fillText(partial, ex + 56, y);- }- ctx.restore();- }- // the point, drawn: no image model- bug(ctx, env, f);-};--// ---------------------------------------------------------------- 3: now make it swim-const sceneSwim = (ctx: Ctx, env: Env, f: number) => {- if (f < SWIM_OUT) {- useCam(ctx, env, HOME);- const typed = typedAt(SWIM_PROMPT, f, SW.times);- drawChat(ctx, env, f, { typed: f < SW.up ? typed : "", caret: f < SW.up && f >= 372, press: press(f, SW.down, SW.up), hot: ramp(f, SW.down - 6, SW.down) });- pointer(ctx, lerpP([GEN_C[0] + 200, GEN_C[1] + 150], [GEN_C[0] + 18, GEN_C[1] + 6], out3(ramp(f, SW.down - 12, SW.down))), press(f, SW.down, SW.up) * 0.8);- bug(ctx, env, f); return;- }- // the break-out: the card opens to the whole frame and the koi swims off- const u = inOut(ramp(f, SWIM_OUT, SWIM_FULL)), r = cardRect(1, SWIM_OUT), L = swimArt.src(env, f);- useCam(ctx, env, HOME);- if (u < 1) { ctx.globalAlpha = 1 - u * 0.8; drawChat(ctx, env, f, { typed: "", caret: false, press: 0, hot: 0, hideCard: 1 }); ctx.globalAlpha = 1; }- const x = lerp(r.x, 0, u), y = lerp(r.y, 0, u), w = lerp(r.s, W, u), h = lerp(r.s, H, u), sx = lerp(420, 0, u), sw = lerp(1080, 1920, u);- screen(ctx, env); ctx.save(); rr(ctx, x, y, w, h, 20 * (1 - u)); ctx.clip(); ctx.drawImage(L, sx, 0, sw, 1080, x, y, w, h); ctx.restore();- bug(ctx, env, f);-};--// ---------------------------------------------------------------- 4: the wall of 31 styles-// the punches are chosen by style, found on the wall where their row has carried them-const PUNCH_STYLES = ["scratchboard", "pixelArt", "toyBrick", "balloon"], PUNCH_TIMES = [0.4, 2.53, 4.67, 6.3];-const WALL_T0 = T2.wall[0] + 10, PUNCH_T0 = 0.9, PUNCH_GAP = PUNCH / FPS; // seconds into the wall-const PUNCHES: Punch[] = (() => {- const out: Punch[] = [];- PUNCH_STYLES.forEach((id, j) => {- const t = PUNCH_TIMES[j], camx = lerp(-240, 240, clamp(t / 8));- let best: Punch | null = null, bd = 1e9;- for (let row = 0; row < 4; row++) for (let k = -12; k < 20; k++) { if (cardOf(row, k).id !== id) continue; const speed = [52, -64, 58, -48][row], x = k * 364 + speed * (t + 12 / FPS) + (row % 2) * 182, d = Math.abs(x - camx) + Math.abs(row - 1.5) * 80; if (d < bd) { bd = d; best = { row, k, t0: t }; } }- if (best) out.push(best);- });- return out;-})();-const wallT = (f: number) => (f - WALL_T0) / FPS;-const drawWallAt = (ctx: Ctx, env: Env, f: number) => { const t = wallT(f), w = wallCam(t, PUNCHES, FPS, W, H, true); drawWall(ctx, env, t, w.cam, w.focus); return w; };-const sceneWall = (ctx: Ctx, env: Env, f: number) => {- if (f < WALL_T0) { // a whip pan off the swim onto the wall- const u = inOut(ramp(f, T2.wall[0], WALL_T0)), Ls = swimArt.src(env, f);- screen(ctx, env); ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, H);- smear(ctx, env, Ls, -W * u, 0, 40 * Math.sin(Math.PI * u));- const Lw = selfLayer(env, "wallwhip", Math.round(W * env.scale), Math.round(H * env.scale)); drawWallAt(Lw.ctx, env, WALL_T0);- screen(ctx, env); ctx.drawImage(Lw.canvas, W * (1 - u), 0, W, H); bug(ctx, env, f); return;- }- const w = drawWallAt(ctx, env, f), t = wallT(f);- void w; void t;- bug(ctx, env, f);-};--// ---------------------------------------------------------------- 5: crayon to bricks, and it flies-const BRICK_SPEED = (brickBalloon.meta.durationFrames - 1) / (T2.brick[1] - 6 - T2.brick[0]);-const brickFrame = (f: number) => Math.max(0, (f - T2.brick[0]) * BRICK_SPEED);-const sceneBrick = (ctx: Ctx, env: Env, f: number) => {- screen(ctx, env); ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, H);- // the balloon card fills the frame's height; as it takes flight it opens to the full width- const open = expo(ramp(f, T2.brick[0] + 120, T2.brick[0] + 160)), size = lerp(H, W, open), x = (W - size) / 2, y = (H - size) / 2;- const L = plateLayer(env, "brick", brickBalloon, brickFrame(f), 1080).canvas;- softShadow(ctx, x, y, size, size, 14 * (1 - open), 1.3); ctx.save(); rr(ctx, x, y, size, size, 14 * (1 - open)); ctx.clip(); ctx.drawImage(L, x, y, size, size); ctx.restore();- bug(ctx, env, f);-};--// ---------------------------------------------------------------- 6: a painter's hand, then 7: the card flips to a loop-const sceneHand = (ctx: Ctx, env: Env, f: number) => {- // the flight shrinks away as the chat comes back, scrolled to its newest message- const back = expo(ramp(f, T2.hand[0], T2.hand[0] + 24));- useCam(ctx, env, HOME);- const typed = typedAt(HAND_PROMPT, f, HD.times), chip = out3(ramp(f, 1058, 1066));- drawChat(ctx, env, f, { typed: f < HD.up ? typed : "", caret: f < HD.up && f >= 1066, press: press(f, HD.down, HD.up), hot: ramp(f, HD.down - 6, HD.down) });- const img = env.image?.("almond");- if (img && f < HD.up && chip > 0) { ctx.globalAlpha = chip; ctx.save(); rr(ctx, INPUT.x + INPUT.w - 420, INPUT.y + 16, 104, 72, 12); ctx.clip(); ctx.drawImage(img, INPUT.x + INPUT.w - 420, INPUT.y + 16, 104, 72); ctx.restore(); ctx.globalAlpha = 1; }- if (f >= HD.down - 14) pointer(ctx, lerpP([GEN_C[0] + 200, GEN_C[1] + 150], [GEN_C[0] + 18, GEN_C[1] + 6], out3(ramp(f, HD.down - 14, HD.down))), press(f, HD.down, HD.up) * 0.8);- if (back < 1) { screen(ctx, env); const s = lerp(1, 0.2, back), L = plateLayer(env, "brick", brickBalloon, brickFrame(T2.brick[1] - 1), 1080).canvas; ctx.globalAlpha = 1 - back; ctx.drawImage(L, 0, (1080 - 1920) / 2, 1920, 1920); ctx.globalAlpha = 1; void s; }- bug(ctx, env, f);-};-const sceneLoop = (ctx: Ctx, env: Env, f: number) => {- const flip = Math.cos(Math.PI * inOut(ramp(f, FLIP - 8, FLIP + 8))), r = cardRect(4, f), push = inOut(ramp(f, FLIP + 12, FLIP + 52));- useCam(ctx, env, camLerp(HOME, { c: [r.x + r.s / 2, r.y + r.s / 2], z: 1040 / r.s }, push));- drawChat(ctx, env, f, { typed: "", caret: false, press: 0, hot: 0, flip: Math.abs(flip) < 0.02 ? 0.02 : Math.abs(flip) });- bug(ctx, env, f);-};--// ---------------------------------------------------------------- 8: the website-export const WEB_SKIP = 118; // the webTour frame where Bit's hero is in view: the scroll-drawn hero is cut, nobody could tell what it was-const WEB0 = T2.web[0] + 10, webFrame = (f: number) => Math.max(0, Math.min(webTour.meta.durationFrames - 1, f - WEB0 + WEB_SKIP));-const sceneWeb = (ctx: Ctx, env: Env, f: number) => {- const L = plateLayer(env, "web", webTour, webFrame(f), 1920).canvas;- if (f < WEB0) { // a whip up off the embroidery onto the site- const u = inOut(ramp(f, T2.web[0], WEB0)), r = cardRect(4, f), Le = plateLayer(env, "emb", embroideryAlive, (f - FLIP) % embroideryAlive.meta.durationFrames, 1080).canvas;- screen(ctx, env); ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, H);- ctx.save(); ctx.translate(0, -H * u); ctx.drawImage(Le, (W - H) / 2, 0, H, H); ctx.restore(); void r;- ctx.drawImage(L, 0, H * (1 - u), W, H); bug(ctx, env, f); return;- }- screen(ctx, env); ctx.drawImage(L, 0, 0, W, H);- bug(ctx, env, f);-};--// ---------------------------------------------------------------- 9: a film-// the film's own arc as a trailer: its blueprint drawn, the butterfly coming alive in colour, flying off through the flowers-export const lepAt = (u: number) => (u < 0.36 ? lerp(60, 520, u / 0.36) : u < 0.62 ? lerp(560, 820, (u - 0.36) / 0.26) : lerp(900, 1420, (u - 0.62) / 0.38));-const sceneFilm = (ctx: Ctx, env: Env, f: number) => {- const L = plateLayer(env, "lep", mechanicalLepidoptera, lepAt(clamp((f - T2.film[0]) / (T2.film[1] - T2.film[0]))), 1080).canvas, u = expo(ramp(f, T2.film[0], T2.film[0] + 16));- screen(ctx, env); ctx.fillStyle = "#101010"; ctx.fillRect(0, 0, W, H);- const s = lerp(0.6, 1, u) * W; ctx.drawImage(L, (W - s) / 2, (H - s) / 2, s, s);- bug(ctx, env, f);-};--// ---------------------------------------------------------------- 10: the sentence, and 11: the end-const WORDS = ["Images", "Illustrations", "Loops", "Animations", "Films"]; // the kit adds the commas and the full stop-const sceneWords = (ctx: Ctx, env: Env, f: number) => {- screen(ctx, env); ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, H);- if (f < T2.words[0] + 30) { const u = expo(ramp(f, T2.words[0], T2.words[0] + 30)), L = plateLayer(env, "lep", mechanicalLepidoptera, lepAt(1), 1080).canvas; ctx.globalAlpha = 1 - u; const s = W * (1 - 0.3 * u); ctx.drawImage(L, (W - s) / 2, (H - s) / 2, s, s); ctx.globalAlpha = 1; }- sentence(ctx, env, WORDS, f, T2.words[0] + 30, { beat: BEAT, styles: ["marker", "ink", "thread", "crayon", "marker"], colors: ["#2f6fd6", C.ink, "#2e7d6e", "#d8452f", "#7a3fb0"], size: 70, top: 230 });- bug(ctx, env, f);-};-const sceneEnd = (ctx: Ctx, env: Env, f: number) => {- screen(ctx, env); ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, H);- const em = 120, b = logoBox(env, em), cx = W / 2, cy = 360;- logoCentred(ctx, env, cx, cy, em, ramp(f, T2.end[0], T2.end[0] + 36), { pen: f < T2.end[0] + 40 }); void b; void logo;- const a = ramp(f, T2.end[0] + 30, T2.end[0] + 44);- ctx.globalAlpha = a; ctx.textAlign = "center"; ctx.textBaseline = "middle";- ctx.fillStyle = C.soft; ctx.font = SANS(500, 28); ctx.fillText("Images · Illustrations · Loops · Animations · Films, all in pure code", cx, 560);- ctx.fillStyle = "#1f1c18"; rr(ctx, cx - 520, 640, 1040, 170, 22); ctx.fill();- ctx.fillStyle = "#ece4d6"; ctx.font = MONO(30); ctx.fillText("/plugin marketplace add alexgreensh/anidoodle", cx, 695); ctx.fillText("/plugin install anidoodle@alexgreensh-anidoodle", cx, 755);- ctx.fillStyle = C.soft; ctx.font = SANS(500, 24); ctx.fillText("Claude Code and Codex · github.com/alexgreensh/anidoodle", cx, 880);- ctx.textAlign = "left"; ctx.globalAlpha = 1;-};--// ---------------------------------------------------------------- the sound-const audio2 = (sr: number): [Float32Array, Float32Array] => {- const n = Math.round((N / FPS) * sr), L = new Float32Array(n), R = new Float32Array(n), m = renderPiece(launchLofi2(), sr);- for (let i = 0; i < n && i < m.L.length; i++) { L[i] = m.L[i]; R[i] = m.R[i]; }- const fade = Math.round(1.2 * sr); for (let i = 0; i < fade; i++) { const g = i / fade; L[n - 1 - i] *= g; R[n - 1 - i] *= g; }- const r = rng(4242), add = (t: number, len: number, fn: (s: number) => number, gain: number, pan = 0) => { const i0 = Math.round(t * sr); for (let i = 0; i < len * sr && i0 + i < n; i++) { if (i0 + i < 0) continue; const v = fn(i / sr) * gain; L[i0 + i] += v * (1 - Math.max(0, pan)); R[i0 + i] += v * (1 + Math.min(0, pan)); } };- const click = (fr: number) => { const f0 = 2600 + r() * 1400, ph = r() * 6; add(fr / FPS, 0.03, (s) => Math.sin(2 * Math.PI * f0 * s + ph) * Math.exp(-s / 0.004) + (r() - 0.5) * Math.exp(-s / 0.002) * 0.6, 0.05, (r() - 0.5) * 0.4); };- const thock = (fr: number) => add(fr / FPS, 0.14, (s) => Math.sin(2 * Math.PI * (70 + 90 * Math.exp(-s / 0.02)) * s) * Math.exp(-s / 0.05), 0.2);- const plip = (fr: number) => add(fr / FPS, 0.16, (s) => Math.sin(2 * Math.PI * (320 + 700 * Math.exp(-s / 0.03)) * s) * Math.exp(-s / 0.06), 0.12);- const whoosh = (fr: number, len = 0.5, g = 0.5) => { let z = 0; add(fr / FPS, len, (s) => { z += 0.14 * ((r() - 0.5) - z); return z * Math.sin((Math.PI * s) / len) ** 2; }, g); };- const scratch = (fr: number, len: number) => { let z = 0; add(fr / FPS, len, (s) => { z += 0.5 * ((r() - 0.5) - z); return z * (0.6 + 0.4 * Math.sin(s * 70)) * Math.min(1, s * 20) * Math.min(1, (len - s) * 20); }, 0.05); };- ASK.times.forEach(click); thock(ASK.down); plip(DROP0.land); scratch(2, 1.6);- SW.times.forEach(click); thock(SW.down); plip(SW.drop.land); whoosh(SWIM_OUT, 0.8);- HD.times.forEach(click); thock(HD.down); plip(HD.drop.land);- whoosh(T2.wall[0], 0.45); PUNCHES.forEach((p) => whoosh(WALL_T0 + p.t0 * FPS, 0.35, 0.4)); whoosh(T2.brick[0] + 120, 0.9);- whoosh(T2.hand[0], 0.5); whoosh(FLIP - 6, 0.35, 0.4); whoosh(T2.web[0], 0.45); whoosh(T2.film[0], 0.5); whoosh(T2.words[0], 0.6);- return [L, R];-};--// ---------------------------------------------------------------- the film-const shot = (id: keyof typeof T2, draw: (ctx: Ctx, env: Env, f: number) => void) => ({ id, start: T2[id][0], end: T2[id][1], draw: (ctx: Ctx, local: number, env: Env) => draw(ctx, env, T2[id][0] + local) });-export const launch2: Film = {- meta: { title: "anidoodle · launch, cut 2", W, H, fps: FPS, bpm: 90, durationFrames: N, raster: "cpu", kind: "launch" },- assets: { images: { almond: "assets/refs/vangogh-almond-blossom.jpg" } }, // public domain; provenance in engine/assets/refs/PROVENANCE.json- shots: [- shot("open", sceneOpen), shot("ask", sceneAsk), shot("code", sceneCode), shot("swim", sceneSwim), shot("wall", sceneWall), shot("brick", sceneBrick),- shot("hand", sceneHand), shot("loop", sceneLoop), shot("web", sceneWeb), shot("film", sceneFilm), shot("words", sceneWords), shot("end", sceneEnd),- ],- audio: audio2,-};-export const KEYS2 = () => ({ SW, HD, KOI_DONE, SWIM_OUT, PUNCHES, LAYOUT: LAYOUT.map((l) => [l.it.kind, l.y, l.h]) });--// the picture alone, at content frame f (launch3.ts cuts it together with the type frames)-export const content2 = (ctx: Ctx, env: Env, f: number) => { const g = Math.max(0, Math.min(N - 1, Math.round(f))), sh = launch2.shots.find((x) => g >= x.start && g < x.end)!; sh.draw(ctx, g - sh.start, env); };-// the interface's sound events in content frames (launch3.ts maps them onto the cut)-export const SFX2 = () => ({ clicks: [...ASK.times, ...SW.times, ...HD.times], thocks: [ASK.down, SW.down, HD.down], plips: [DROP0.land, HD.drop.land], punches: PUNCHES.map((p) => WALL_T0 + p.t0 * FPS), flip: FLIP - 6 });diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launch3.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launch3.tsdeleted file mode 100644index 3d5ce28..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launch3.ts+++ /dev/null@@ -1,107 +0,0 @@-// LAUNCH, CUT 3. Alex on cut 2: "every frame has ugly text overlaying visual elements... text must be-// a frame: white, big animated text, then the show." So the words never sit on the art. Cut 3 is-// cut 2's pictures (launch2.content2, all type removed) spliced with TYPE FRAMES: a sheet of paper-// sweeps in over the picture, one big word letters itself on in its own medium, and the paper sweeps-// off to reveal the next scene. (Chosen: the ink bloom, and every word in ink.) 29 bars of the score (launchLofi3), 77 s.-import type { Ctx, Env } from "./core";-import type { Film } from "./film";-import { C } from "./launchKit";-import { content2, SFX2, T2, WEB_SKIP } from "./launch2";-import { logoBug } from "./kinetic";-import { beatGrid, makeCut, pic, type, typeFrame, type Seg, type TypeSeg } from "./launchCut";-import { launchLofi3 } from "./music/pieces/launch";-import { renderPiece } from "./music/render";-import { rng } from "./core";--const W = 1920, H = 1080, FPS = 30;-// The cut is data (launchCut.ts): pic(from, to, len) plays a span of content2, type(...) is a full-frame-// word page. Re-timing the film is an edit to HEAD, never to scene code.-// Alex on cut 3: gentler pacing; ANIMATIONS before the swim request; the koi-and-code beat much-// shorter; the embroidery long enough to see; the site from Bit's hero on. The film beat's length is-// solved so "All in pure code." (content T2.words[0] + 140) lands on bar 26, the score's home chord.-const WEB_FROM = T2.web[0] + 10, WEB_LEN = 360 - WEB_SKIP;-const HEAD: Seg[] = [- pic(0, 200),- pic(200, 360, 90), // the koi and its code, twice as fast- type([{ text: "NO IMAGE MODEL.", style: "ink", color: C.ink }, { text: "JUST CODE.", style: "ink", color: C.accent }], 64, 359, 360),- pic(360, 372),- type([{ text: "ANIMATIONS", style: "ink", color: C.ink }], 50, 371, 372),- pic(372, 560),- type([{ text: "31 STYLES", style: "ink", color: C.ink }], 50, 559, 570),- pic(570, 800),- pic(800, 1040, 200),- pic(1040, 1200),- type([{ text: "LOOPS", style: "ink", color: C.ink }], 50, 1199, 1200),- pic(1200, 1360),- type([{ text: "INTERACTIVE", style: "ink", color: C.ink }], 50, 1359, WEB_FROM),- pic(WEB_FROM, WEB_FROM + WEB_LEN),- type([{ text: "FILMS", style: "ink", color: C.ink }], 60, WEB_FROM + WEB_LEN - 1, T2.film[0]),-];-// the claim lands on bar 26 (the score's home chord): the film beat takes whatever is left-const headLen = HEAD.reduce((a, s) => a + s.len, 0), FILM_LEN = beatGrid(90, FPS).solve(26, 140 + headLen, 90);-const SEGS: Seg[] = [...HEAD, pic(T2.film[0], T2.film[1], FILM_LEN), pic(T2.words[0], T2.words[1]), pic(T2.end[0], T2.end[1]), pic(T2.end[1] - 1, T2.end[1], 60)];-const CUT = makeCut(SEGS), { STARTS, at, contentOf } = CUT;-export const N3 = CUT.N;-// a content frame, mapped to the cut (for the sound events); events inside a cut-away go to its start-export const cutOf = CUT.cutOf;--// ---------------------------------------------------------------- a type frame-const IN = 14, OUT = 14; // gentle: the bloom opens and closes over half a second-// Alex's pick: B, the ink bloom. The Generate drop's own ink blooms from the centre over the picture,-// the page is inside the bloom, the word is written on it in ink by the pointed pen, and the ink-// shrinks back to a point to show the next scene.-const drawType = (ctx: Ctx, env: Env, s: TypeSeg, local: number, F: number) =>- typeFrame(ctx, env, s.lines, local, s.len, (first) => content2(ctx, env, first ? s.before : s.after), (c) => logoBug(c, env, F, 1700, 1040, 0.9, { t0: -100, fps: FPS }), { inF: IN, outF: OUT });--// ---------------------------------------------------------------- the sound-const audio3 = (sr: number): [Float32Array, Float32Array] => {- const n = Math.round((N3 / FPS) * sr), L = new Float32Array(n), R = new Float32Array(n), m = renderPiece(launchLofi3(), sr);- for (let i = 0; i < n && i < m.L.length; i++) { L[i] = m.L[i]; R[i] = m.R[i]; }- const fade = Math.round(1.2 * sr); for (let i = 0; i < fade; i++) { const g = i / fade; L[n - 1 - i] *= g; R[n - 1 - i] *= g; }- const r = rng(4242), add = (fr: number, len: number, fn: (s: number) => number, gain: number, pan = 0) => { if (fr < 0) return; const i0 = Math.round((fr / FPS) * sr); for (let i = 0; i < len * sr && i0 + i < n; i++) { const v = fn(i / sr) * gain; L[i0 + i] += v * (1 - Math.max(0, pan)); R[i0 + i] += v * (1 + Math.min(0, pan)); } };- const click = (fr: number) => { const f0 = 2600 + r() * 1400, ph = r() * 6; add(fr, 0.03, (s) => Math.sin(2 * Math.PI * f0 * s + ph) * Math.exp(-s / 0.004) + (r() - 0.5) * Math.exp(-s / 0.002) * 0.6, 0.05, (r() - 0.5) * 0.4); };- const thock = (fr: number) => add(fr, 0.14, (s) => Math.sin(2 * Math.PI * (70 + 90 * Math.exp(-s / 0.02)) * s) * Math.exp(-s / 0.05), 0.2);- const plip = (fr: number) => add(fr, 0.16, (s) => Math.sin(2 * Math.PI * (320 + 700 * Math.exp(-s / 0.03)) * s) * Math.exp(-s / 0.06), 0.12);- const whoosh = (fr: number, len = 0.4, g = 0.5) => { let z = 0; add(fr, len, (s) => { z += 0.14 * ((r() - 0.5) - z); return z * Math.sin((Math.PI * s) / len) ** 2; }, g); };- const scratch = (fr: number, len: number, g = 0.05) => { let z = 0; add(fr, len, (s) => { z += 0.5 * ((r() - 0.5) - z); return z * (0.6 + 0.4 * Math.sin(s * 70)) * Math.min(1, s * 20) * Math.min(1, (len - s) * 20); }, g); };- const e = SFX2();- e.clicks.forEach((c) => click(cutOf(c))); e.thocks.forEach((c) => thock(cutOf(c))); e.plips.forEach((c) => plip(cutOf(c)));- e.punches.forEach((c) => whoosh(cutOf(c), 0.3, 0.4)); whoosh(cutOf(e.flip), 0.3, 0.4); whoosh(cutOf(T2.brick[0] + 120), 0.9); whoosh(cutOf(T2.hand[0]), 0.5);- scratch(2, 1.6);- SEGS.forEach((s, i) => { if (s.kind !== "type") return; whoosh(STARTS[i], 0.32, 0.55); s.lines.forEach((_, k) => scratch(STARTS[i] + IN - 2 + k * 10, 0.6, 0.07)); whoosh(STARTS[i] + s.len - OUT, 0.32, 0.55); });- return [L, R];-};--// ---------------------------------------------------------------- holds (the approved cut, reviewed frame by frame)-// Every stretch the dead-air gate measures as still, looked at on a contact sheet and named. HOLDS are-// meant: something is being read or watched. LOCKED are waits the review found and did NOT excuse; the-// film is approved and unchanged, so they stay failures for the lead to decide.-const HOLDS3: [number, number][] = [- // every word page: the bloom opens, the word is written, it is read, the bloom closes onto the scene- ...SEGS.flatMap((s, i): [number, number][] => (s.kind === "type" ? [[STARTS[i], STARTS[i] + s.len + 1]] : [])),- [1, 161], // the hook: the first prompt typed in close-up and sent; the words are the motion- [416, 443], // the follow-up "now make it swim" typed into the thread- [884, 902], // the crayon balloon seen whole before the wave turns it to bricks (brickBalloon's own hold, at 2x)- [921, 926], // the finished mosaic rests before it lets go (brickBalloon's hold, at 2x)- [978, 982], // the built balloon stands complete before the burner lights (brickBalloon's hold, at 2x)- [1109, 1139], // "my koi, painted in this hand" typed, the Van Gogh reference attached- [1175, 1236], // the almond-blossom koi laid in stroke by stroke inside its card: real, but small in frame- [1238, 1246], // the finished almond koi seen whole before LOOPS- [1303, 1310], // the embroidery loop opens on the bee resting on the poppy (embroideryAlive's own hold)- [1975, 2141], // the sentence written word by word in five media, then the claim read- [2141, N3], // the end card blooms open and holds, install lines on screen (the last 60 frames frozen)-];-const LOCKED3: [number, number, string][] = [- [354, 367, "dead wait: the koi card sits unchanged for 13 frames between two word pages"],- [1080, 1091, "dead wait: the brick flight stops and the frame freezes for 11 frames before the chat returns"],- [1806, 1943, "stutter: the butterfly film plays at 0.6x by repeating frames (every 2nd-3rd frame identical)"],- [1955, 1975, "dead wait: the butterfly fades to empty paper and the blank page waits before the sentence"],-];--export const launch3: Film = {- meta: { title: "anidoodle · launch, cut 3", W, H, fps: FPS, bpm: 90, durationFrames: N3, raster: "cpu", kind: "launch", holds: HOLDS3, locked: LOCKED3 },- assets: { images: { almond: "assets/refs/vangogh-almond-blossom.jpg" } }, // public domain; provenance in engine/assets/refs/PROVENANCE.json- shots: [{ id: "cut", start: 0, end: N3, draw: (ctx, F, env) => { const { s, local } = at(F); if (s.kind === "pic") content2(ctx, env, contentOf(s, local)); else drawType(ctx, env, s, local, F); } }],- audio: audio3,-};-export const SEGS3 = () => SEGS.map((s, i) => [s.kind, STARTS[i], s.len, s.kind === "type" ? s.lines.map((l) => l.text).join(" / ") : `${s.from}-${s.to}`]);diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchClip.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchClip.tsdeleted file mode 100644index 3afd440..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchClip.ts+++ /dev/null@@ -1 +0,0 @@-export { launchClip } from "./launch";diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchCode.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchCode.tsdeleted file mode 100644index 1d55653..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchCode.ts+++ /dev/null@@ -1,64 +0,0 @@-// GENERATED from koi.ts (drawFish, verbatim, long lines cut at 78 chars): the code the launch-// film shows streaming beside the koi as it draws. Regenerate if drawFish changes.-export const KOI_CODE: string[] = [-"export const drawFish = (g: Gfx, k: KoiClock, b: Body, fins: ReturnType<typeo…",-" // the fish's shadow on the pond floor, flat and hard, down-right away from…",-" const floor = [b.outline, cau.shape, ...fins.map((f) => f.shape)].map((s) =…",-" g.group(\"plain\", () => lay(g, k(\"floor\", \"shade\"), floor, () => floor.forEa…",-"",-" // fins under the body: translucent, cel-shaded, a black base on the pector…",-" g.group(\"plain\", () => {",-" fins.forEach((f, i) => {",-" const el = `fin${i}`, fl = k(el, \"flat\"), sh = k(el, \"shade\"), dt = k(e…",-" const moto = () => { if (i < 2) fillShape(g, blob(...(i === 0 ? b.at(0.…",-" const cel = () => { fillShape(g, f.shape, FIN_S, 0.88); clipped(g, f.sh…",-" if (sh >= 1) cel();",-" else { lay(g, part(fl, 0, 2), [f.shape], () => fillShape(g, f.shape, FI…",-" f.rays.forEach((ray, kk) => inkP(g, ray, mix(INK, FIN_S, 0.35), { w: 1.…",-" inkP(g, f.shape, INK, { w: 4.2, closed: true, light: LIGHT, shadow: 0.8…",-" });",-" });",-"",-" // the body: shade cel underneath, the lit white pushed toward the light, t…",-" const bs = b.outline, bsL = bs.map(([x, y]) => [x + LIGHT[0] * 22, y + LIGH…",-" const bfl = k(\"body\", \"flat\"), bsh = k(\"body\", \"shade\");",-" g.group(\"plain\", () => {",-" if (bsh >= 1) fillShape(g, bs, WHITE_S);",-" else { lay(g, bfl, [bs], () => fillShape(g, bs, WHITE), 5201, 34, -0.35);…",-" clipped(g, bs, () => {",-" if (bsh >= 1) fillShape(g, bsL, WHITE);",-" // red hi: head crown, a saddle across the back, a patch toward the tai…",-" const hf = k(\"hi\", \"flat\"), hs = k(\"hi\", \"shade\");",-" const patches = KOI_HI;",-" patches.forEach(([t, s, dt, ds, seed], pi) => {",-" const r = rng(seed * 17), pts: P[] = [];",-" for (let i = 0; i < 16; i++) { const a = (i / 16) * Math.PI * 2, kk =…",-" const sh = smooth(pts, true, 6), ps = part(hs, pi, 5);",-" const cel = () => { fillShape(g, sh, HI_S); clipped(g, sh, () => fill…",-" if (ps >= 1) cel(); else { lay(g, part(hf, pi, 5), [sh], () => fillSh…",-" });",-" // sumi: a few black spots, never on the head",-" const sf = k(\"sumi\", \"flat\");",-" ([[0.3, 0.55, 0.028, 0.32, 31], [0.55, -0.55, 0.03, 0.3, 32], [0.61, 0.…",-" const r = rng(seed), pts: P[] = []; for (let i = 0; i < 12; i++) { co…",-" const sp = smooth(pts, true, 5); lay(g, part(sf, si, 5), [sp], () => …",-" });",-" // scales: a loose lattice of arcs, strongest on the lit back, gone int…",-" const r = rng(55), sc = k(\"scales\", \"detail\");",-" for (let t = 0.2; t < 0.93; t += 0.034) for (let s = -0.75; s <= 0.8; s…",-" const tt = t + (Math.round(s / 0.3) % 2 ? 0.017 : 0), ss = s + (r() -…",-" const lit = ss < 0.35 && !(r() < 0.3);",-" if (lit) inkP(g, smooth([q, m, u], false, 5), \"#2a1f3a\", { w: 1.5, sh…",-" void p;",-" }",-" // the wet highlight along the back, and a glint on the head",-" const hl = k(\"gloss\", \"detail\");",-" [[0.2, 0.3, -0.6, 7], [0.335, 0.42, -0.64, 6], [0.46, 0.5, -0.66, 4.5],…",-" const glint = blob(...b.at(0.075, -0.35), 22, 9, 91, 0.1, 10, -0.7);",-" lay(g, part(hl, 4, 5), [glint], () => fillShape(g, blob(...b.at(0.075, …",-" });",-" // dorsal fin down the spine: a narrow flutter of translucent fin with ra…",-" const df: P[] = [], dfr: P[] = [];",-" for (let i = 0; i <= 16; i++) { const f = i / 16, t = 0.36 + f * 0.3, h =…",-" const dorsal = [...smooth(df, false, 3), ...smooth(dfr, false, 3).reverse…"-];diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/typeOptions.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/typeOptions.tsdeleted file mode 100644index 6ccc213..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/typeOptions.ts+++ /dev/null@@ -1,78 +0,0 @@-// TYPE FRAME OPTIONS, for Alex to choose from before cut 3 renders: four ways a word gets its own-// frame between two scenes (A paper sweep, B ink bloom, C card flip, D push), each 2 s, and the same-// word in every lettering medium (typeStyles, one still per style).-import type { Ctx, Env, P } from "./core";-import type { Film } from "./film";-import { C, blot, expo, inOut, pathOf, ramp, selfLayer } from "./launchKit";-import { content2 } from "./launch2";-import { logoBug, measure, writeOn, type KStyle } from "./kinetic";--const W = 1920, H = 1080, LEN = 60, IN = 10, OUT = 10;-const BEFORE = 520, AFTER = 1600; // the swim going out, the website coming in-const WORD = "ANIMATIONS";--const sheet = (env: Env, local: number, style: KStyle, color: string, word = WORD) => {- const L = selfLayer(env, "sheet", Math.round(W * env.scale), Math.round(H * env.scale)), c = L.ctx;- c.setTransform(env.scale, 0, 0, env.scale, 0, 0); c.fillStyle = C.bg; c.fillRect(0, 0, W, H);- const size = Math.min(200, (1560 / measure(word, 100)) * 100);- writeOn(c, env, word, W / 2, H / 2 + size * 0.5, size, ramp(local, IN - 2, IN + 18), style, { color, align: "center" });- logoBug(c, env, 200, 1700, 1040, 0.9, { t0: -100 });- return L.canvas;-};-const pic = (ctx: Ctx, env: Env, local: number) => content2(ctx, env, local < LEN / 2 ? BEFORE : AFTER);-type Tr = (ctx: Ctx, env: Env, local: number) => void;-const S = (env: Env) => env.scale;--// A: a sheet of paper sweeps in from the right, sweeps off to the left-const sweep: Tr = (ctx, env, l) => {- pic(ctx, env, l); const u = expo(ramp(l, 0, IN)), v = expo(ramp(l, LEN - OUT, LEN)), x = v > 0 ? -W * v : W * (1 - u);- const Lc = sheet(env, l, "crayon", "#d8452f"); ctx.setTransform(1, 0, 0, 1, 0, 0);- const edge = (v > 0 ? x + W : x) * S(env), g = ctx.createLinearGradient(edge, 0, edge + (v > 0 ? 40 : -40) * S(env), 0); g.addColorStop(0, "rgba(40,25,10,0.22)"); g.addColorStop(1, "rgba(40,25,10,0)");- ctx.fillStyle = g; ctx.fillRect(v > 0 ? edge : edge - 40 * S(env), 0, 40 * S(env), H * S(env)); ctx.drawImage(Lc, x * S(env), 0);-};-// B: an ink blot blooms from the centre (the Generate drop's own ink), the page inside it-const bloom: Tr = (ctx, env, l) => {- pic(ctx, env, l); const u = expo(ramp(l, 0, IN + 2)), v = expo(ramp(l, LEN - OUT, LEN)), R = 1250 * (v > 0 ? 1 - v : u), c: P = [W / 2, H / 2];- if (R < 2) return;- const Lc = sheet(env, l, "ink", C.ink);- ctx.setTransform(S(env), 0, 0, S(env), 0, 0); ctx.save(); pathOf(ctx, blot(c, R + 26, 88)); ctx.fillStyle = C.ink; ctx.fill(); pathOf(ctx, blot(c, Math.max(0, R - 4), 88)); ctx.clip();- ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(Lc, 0, 0); ctx.restore();-};-// C: the picture flips over like a card; the word is on its back; it flips again to the next scene-const flip: Tr = (ctx, env, l) => {- ctx.setTransform(S(env), 0, 0, S(env), 0, 0); ctx.fillStyle = "#1b1916"; ctx.fillRect(0, 0, W, H);- const a = l < LEN / 2 ? Math.PI * inOut(ramp(l, 0, IN + 4)) : Math.PI + Math.PI * inOut(ramp(l, LEN - OUT - 4, LEN)), k = Math.cos(a), face = Math.abs(k) < 1e-3 ? 1e-3 : Math.abs(k), back = Math.cos(a) < 0;- const tmp = selfLayer(env, "flipface", Math.round(W * S(env)), Math.round(H * S(env)));- if (back) tmp.ctx.drawImage(sheet(env, l, "thread", "#2e7d6e"), 0, 0); else pic(tmp.ctx, env, l);- const sc = 1 - 0.12 * Math.sin(Math.min(Math.PI, Math.abs(a % Math.PI) * 1.0 + (a > Math.PI ? 0 : 0)));- ctx.setTransform(S(env) * face * sc, 0, 0, S(env) * sc, (W / 2) * S(env) * (1 - face * sc), (H / 2) * S(env) * (1 - sc));- ctx.drawImage(tmp.canvas, 0, 0, W, H);- ctx.setTransform(S(env), 0, 0, S(env), 0, 0); ctx.fillStyle = `rgba(0,0,0,${0.35 * (1 - face)})`; ctx.fillRect(W / 2 - (W / 2) * face * sc, H / 2 - (H / 2) * sc, W * face * sc, H * sc);-};-// D: a paper panel pushes the picture up out of frame, then pushes on to reveal the next-const push: Tr = (ctx, env, l) => {- const u = expo(ramp(l, 0, IN)), v = expo(ramp(l, LEN - OUT, LEN)), Lc = sheet(env, l, "marker", "#2f6fd6");- const tmp = selfLayer(env, "pushpic", Math.round(W * S(env)), Math.round(H * S(env))); pic(tmp.ctx, env, l);- ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.fillStyle = "#000"; ctx.fillRect(0, 0, W * S(env), H * S(env));- if (v === 0) { ctx.drawImage(tmp.canvas, 0, -H * u * S(env)); ctx.drawImage(Lc, 0, H * (1 - u) * S(env)); }- else { ctx.drawImage(Lc, 0, -H * v * S(env)); ctx.drawImage(tmp.canvas, 0, H * (1 - v) * S(env)); }-};--const TR: [string, Tr][] = [["sweep", sweep], ["bloom", bloom], ["flip", flip], ["push", push]];-export const typeOptions: Film = {- meta: { title: "type frame options", W, H, fps: 30, bpm: 90, durationFrames: LEN * TR.length, raster: "cpu" },- assets: { images: { almond: "assets/refs/vangogh-almond-blossom.jpg" } }, // public domain; provenance in engine/assets/refs/PROVENANCE.json- shots: TR.map(([id, fn], i) => ({ id, start: i * LEN, end: (i + 1) * LEN, draw: (ctx: Ctx, l: number, env: Env) => fn(ctx, env, l) })),-};--// the same word, finished, in every medium: one shot per style (20 frames each, stills are taken from them)-const STYLES: [KStyle, string][] = [["ink", C.ink], ["crayon", "#d8452f"], ["thread", "#2e7d6e"], ["marker", "#2f6fd6"], ["brick", ""], ["chalk", "#f4f1e6"]];-export const typeStyles: Film = {- meta: { title: "type styles", W, H, fps: 30, bpm: 90, durationFrames: 20 * STYLES.length },- assets: { images: {} },- shots: STYLES.map(([st, col], i) => ({ id: st, start: i * 20, end: (i + 1) * 20, draw: (ctx: Ctx, _l: number, env: Env) => {- ctx.setTransform(env.scale, 0, 0, env.scale, 0, 0); ctx.fillStyle = st === "chalk" ? "#2d3a33" : C.bg; ctx.fillRect(0, 0, W, H);- const size = Math.min(200, (1560 / measure(WORD, 100)) * 100);- writeOn(ctx, env, WORD, W / 2, H / 2 + size * 0.5, size, 1, st, { color: col || undefined, align: "center" });- } })),-};diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/typeStyles.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/typeStyles.tsdeleted file mode 100644index b007c95..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/typeStyles.ts+++ /dev/null@@ -1 +0,0 @@-export { typeStyles } from "./typeOptions";diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launch.ts b/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launch.tsdeleted file mode 100644index 396a2ea..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launch.ts+++ /dev/null@@ -1,4 +0,0 @@-import { launch } from "../canvas-core/launch";-import { mountFilm } from "./page";--mountFilm(launch);diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launch2.ts b/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launch2.tsdeleted file mode 100644index 1185b47..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launch2.ts+++ /dev/null@@ -1,4 +0,0 @@-import { launch2 } from "../canvas-core/launch2";-import { mountFilm } from "./page";--mountFilm(launch2);diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launch3.ts b/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launch3.tsdeleted file mode 100644index d85f8e0..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launch3.ts+++ /dev/null@@ -1,4 +0,0 @@-import { launch3 } from "../canvas-core/launch3";-import { mountFilm } from "./page";--mountFilm(launch3);diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launchClip.ts b/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launchClip.tsdeleted file mode 100644index 976f94c..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-launchClip.ts+++ /dev/null@@ -1,4 +0,0 @@-import { launchClip } from "../canvas-core/launch";-import { mountFilm } from "./page";--mountFilm(launchClip);diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-typeOptions.ts b/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-typeOptions.tsdeleted file mode 100644index c791c5f..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-typeOptions.ts+++ /dev/null@@ -1,4 +0,0 @@-import { typeOptions } from "../canvas-core/typeOptions";-import { mountFilm } from "./page";--mountFilm(typeOptions);diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-typeStyles.ts b/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-typeStyles.tsdeleted file mode 100644index fcdbe3e..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-typeStyles.ts+++ /dev/null@@ -1,4 +0,0 @@-import { typeStyles } from "../canvas-core/typeStyles";-import { mountFilm } from "./page";--mountFilm(typeStyles);diff --git a/plugins/anidoodle/skills/anidoodle/engine/tools/gallery.mjs b/plugins/anidoodle/skills/anidoodle/engine/tools/gallery.mjsdeleted file mode 100644index ee3f956..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/tools/gallery.mjs+++ /dev/null@@ -1,100 +0,0 @@-// GALLERY. The style sheet, drawn by the styles themselves: one tile per style, the LAST frame-// of its draw film — the finished piece every draw-on plate holds, and the whole of a still —-// rendered through the same machinery as still.mjs at scale 1. Tiles are labelled only when-// ffmpeg can set text in a system font; when it cannot, the names go in a legend file, because a-// sheet of unnamed tiles is a guessing game.-// node tools/gallery.mjs [--only id,id] [--dry]-import { execFileSync } from "node:child_process";-import { existsSync, mkdirSync, writeFileSync } from "node:fs";-import { dirname, join, resolve } from "node:path";-import { fileURLToPath } from "node:url";-import { buildPage } from "./build-page.mjs";-import { detect } from "./detect.mjs";-import * as playwright from "./adapters/playwright.mjs";-import { loadRegistry, ENGINE, ROOT } from "./registry.mjs";-import { overlay } from "./overlay.mjs";--process.chdir(ENGINE); // buildPage and the host pages resolve src/ against cwd, like every tool here-const GALLERY = resolve(ROOT, "assets/gallery");-const CELL = 520, LH = 64;--const VAL = new Set(["only"]);-const pos = [], opt = {};-for (let i = 2; i < process.argv.length; i++) { const a = process.argv[i]; if (a.startsWith("--")) opt[a.slice(2)] = VAL.has(a.slice(2)) ? process.argv[++i] : true; else pos.push(a); }-const die = (m) => { console.error(`gallery: ${m}`); process.exit(1); };--const entries = loadRegistry().filter((s) => s.drawFilm);-const only = opt.only ? String(opt.only).split(",").map((s) => s.trim()) : null;-if (only) { const bad = only.filter((id) => !entries.some((s) => s.id === id)); if (bad.length) die(`--only: no style with a film named ${bad.join(", ")} (have: ${entries.map((s) => s.id).join(", ")})`); }-const tiles = entries.filter((s) => !only || only.includes(s.id));-if (!tiles.length) die("no styles with a draw film");--// Labels need drawtext AND a font file we can name. This ffmpeg has drawbox but no drawtext, so-// on this machine the sheet falls back to the legend; a machine with freetype gets real labels.-const FONTS = ["/System/Library/Fonts/Helvetica.ttc", "/System/Library/Fonts/Supplemental/Arial.ttf", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", "/usr/share/fonts/dejavu/DejaVuSans.ttf", "C:/Windows/Fonts/arial.ttf"];-const findFont = (ff) => {- try { if (!execFileSync(ff, ["-hide_banner", "-filters"], { stdio: ["ignore", "pipe", "ignore"] }).toString().includes("drawtext")) return { ok: false, why: "ffmpeg was built without drawtext (no libfreetype)" }; }- catch { return { ok: false, why: "could not query ffmpeg's filters" }; }- const font = FONTS.find((p) => existsSync(p));- return font ? { ok: true, font } : { ok: false, why: "drawtext exists but no known system font file was found" };-};--// A still.mjs-style probe: bundle the film, read meta, no browser. Enough for --dry to say which-// frame is the last.-const metaOf = async (film) => (await import("data:text/javascript;base64," + Buffer.from((await (await import("esbuild")).build({ stdin: { contents: `export { ${film} as film } from "./src/canvas-core/${film}";`, resolveDir: process.cwd(), loader: "ts" }, bundle: true, format: "esm", write: false, platform: "neutral", plugins: [overlay] })).outputFiles[0].text).toString("base64"))).film.meta;--const cols = Math.ceil(Math.sqrt(tiles.length)), rows = Math.ceil(tiles.length / cols);-const plan = (font) => `grid ${cols}x${rows} of ${CELL}px tiles, ${font.ok ? `labels in ${font.font}` : `no labels (${font.why}) -> LEGEND.md`}`;--if (opt.dry) {- const font = findFont(process.env.FFMPEG || "ffmpeg");- console.log(`gallery (dry): ${tiles.length} styles with a film -> ${GALLERY}`);- for (const s of tiles) {- const page = existsSync(join(ENGINE, "src/hosts", `page-${s.drawFilm}.ts`));- const last = page ? String((await metaOf(s.drawFilm)).durationFrames - 1) : "?";- console.log(` ${s.id.padEnd(14)} film ${s.drawFilm.padEnd(18)} last frame ${last.padEnd(5)} -> assets/gallery/${s.id}.jpg${page ? "" : " (no host page, would be skipped)"}`);- }- console.log(` sheet: assets/gallery/styles.jpg ${plan(font)}`);- process.exit(0);-}--const env = detect();-if (!env.pw.ok || !env.browser.ok) die(`no browser to draw in.\n playwright: ${env.report.playwright}\n browser: ${env.report.browser}\n fix: npm install, then npx playwright-core install chromium`);-if (!env.ffmpeg.ok) die(`no ffmpeg for the sheet.\n ${env.ffmpeg.why}`);-mkdirSync(GALLERY, { recursive: true });--const drawn = [];-for (const s of tiles) {- if (!existsSync(join(ENGINE, "src/hosts", `page-${s.drawFilm}.ts`))) { console.log(` ${s.id}: draw film '${s.drawFilm}' has no host page yet, skipped`); continue; }- const page = await buildPage({ entry: `src/hosts/page-${s.drawFilm}.ts`, out: resolve(`dist/${s.drawFilm}.html`), title: s.drawFilm });- const session = await playwright.open(env, page.out, { scale: 1, workers: 1 });- const meta = await session.info(), last = meta.durationFrames - 1;- const f = await session.frame(last, 0);- await session.close();- const jpg = join(GALLERY, `${s.id}.jpg`);- execFileSync(env.ffmpeg.bin, ["-y", "-loglevel", "error", "-i", "pipe:0", "-frames:v", "1", "-q:v", "3", jpg], { input: f.png }); // mjpeg q3 ~= jpeg quality 88- console.log(` ${s.id.padEnd(14)} ${s.name.padEnd(32)} ${s.drawFilm} frame ${last} draw ${f.drawMs.toFixed(0)} ms -> ${jpg}`);- drawn.push(s);-}-if (!drawn.length) die("nothing rendered");--const font = findFont(env.ffmpeg.bin), esc = (s) => s.replace(/[\\:',%]/g, "\\$&"), rowH = CELL + (font.ok ? LH : 0);-const inputs = [], parts = drawn.flatMap((s, i) => {- inputs.push("-i", join(GALLERY, `${s.id}.jpg`));- return font.ok- ? [`[${i}:v]scale=${CELL}:${CELL},pad=${CELL}:${rowH}:0:0:color=0xf7f5f0,drawtext=fontfile='${esc(font.font)}':text='${esc(s.name)}':fontsize=22:fontcolor=0x1b1a1a:x=(w-text_w)/2:y=${CELL + 18},format=yuv420p[t${i}]`]- : [`[${i}:v]scale=${CELL}:${CELL},format=yuv420p[t${i}]`];-});-const cells = cols * rows, ins = drawn.map((_, i) => `[t${i}]`);-for (let b = drawn.length; b < cells; b++) { inputs.push("-f", "lavfi", "-i", `color=c=0xf7f5f0:s=${CELL}x${rowH}`); parts.push(`[${b}:v]format=yuv420p[b${b}]`); ins.push(`[b${b}]`); }-const layout = Array.from({ length: cells }, (_, i) => `${(i % cols) * CELL}_${Math.floor(i / cols) * rowH}`).join("|");-const sheet = join(GALLERY, "styles.jpg");-execFileSync(env.ffmpeg.bin, [...inputs, "-y", "-loglevel", "error", "-filter_complex", `${parts.join(";")};${ins.join("")}xstack=inputs=${cells}:layout=${layout},format=yuv420p[out]`, "-map", "[out]", "-frames:v", "1", "-q:v", "3", sheet]);--if (!font.ok) writeFileSync(join(GALLERY, "LEGEND.md"), [- "# Gallery legend", "",- `ffmpeg here cannot draw text (${font.why}), so styles.jpg carries no labels.`,- `Grid is ${cols} across and ${rows} down, in reading order:`, "",- ...drawn.map((s, i) => `${i + 1}. **${s.name}** (\`${s.id}\`) — assets/gallery/${s.id}.jpg`), "",-].join("\n"));-console.log(`\nsheet: ${sheet} ${drawn.length} tiles, ${plan(font)}`);diff --git a/plugins/anidoodle/skills/anidoodle/references/workflows/adapt-a-style.md b/plugins/anidoodle/skills/anidoodle/references/workflows/adapt-a-style.mdindex 285794f..071ef4e 100644--- a/plugins/anidoodle/skills/anidoodle/references/workflows/adapt-a-style.md+++ b/plugins/anidoodle/skills/anidoodle/references/workflows/adapt-a-style.md@@ -80,7 +80,7 @@ header before any code:- **NOT**: `paintedOil` models form in depth; this hand keeps the ground flat and decorative withone step of shadow. The subject is the film's own koi, never the painting's branch.-The reference itself ships at `engine/assets/refs/vangogh-almond-blossom.jpg`, the one image in+The reference itself lives in the anidoodle repository at `engine/assets/refs/` (not in the installed plugin), the one image inthe repo not drawn by code: public domain (Van Gogh died in 1890; a faithful photograph of a 2Dpublic-domain work), downloaded from Wikimedia Commons and kept byte-identical, with its source,licence and sha256 in `engine/assets/refs/PROVENANCE.json`. The launch films show it only as thediff --git a/plugins/anidoodle/skills/anidoodle/references/workflows/start-here.md b/plugins/anidoodle/skills/anidoodle/references/workflows/start-here.mdindex 4694b11..2272aff 100644--- a/plugins/anidoodle/skills/anidoodle/references/workflows/start-here.md+++ b/plugins/anidoodle/skills/anidoodle/references/workflows/start-here.md@@ -14,7 +14,7 @@ pick", pick, say what you picked and why in one line, and carry on.explainer, an infographic, a launch or product video, an interactive web piece, a drawinglesson, a character, or a style matched from their image. The table in `SKILL.md` routes eachone to its workflow file.-2. **Which style?** Show the gallery (`assets/styles.jpg`, one tile per hand; the list with+2. **Which style?** Show the gallery (https://github.com/alexgreensh/anidoodle/blob/main/skills/anidoodle/assets/styles.jpg, one tile per hand; the list witheach hand's medium is `references/styles/INDEX.md`). Recommend two or three hands that suit thesubject and the audience, with one reason each. Offer two other routes:- **"Match my image"**: they bring a picture and you adapt its hand (`adapt-a-style.md`).diff --git a/scripts/sync-codex-marketplace-plugin.sh b/scripts/sync-codex-marketplace-plugin.shindex 512eeab..478756c 100755--- a/scripts/sync-codex-marketplace-plugin.sh+++ b/scripts/sync-codex-marketplace-plugin.sh@@ -35,10 +35,14 @@ cp "${REPO_ROOT}/LICENSE" "${REPO_ROOT}/NOTICE" "${STAGE}/"mkdir -p "${STAGE}/assets"cp "${REPO_ROOT}/assets/icon.png" "${STAGE}/assets/icon.png"cd "${REPO_ROOT}"+# The installed plugin leaves out what only the repository needs: anidoodle's own launch films+# (launch, launch2, launch3, launchClip and their helpers and pages), the public-domain reference+# image they show, and the gallery sheet and the tool that rebuilds it (the docs link to it online).+EXCLUDE='/canvas-core/(launch|launch2|launch3|launchClip|launchCode|typeOptions|typeStyles)\.ts$|/hosts/page-(launch|launch2|launch3|launchClip|typeOptions|typeStyles)\.ts$|/engine/assets/refs/|/engine/tools/gallery\.mjs$|^skills/anidoodle/assets/styles\.jpg$'count=0while IFS= read -r f; domkdir -p "${STAGE}/$(dirname "$f")"; cp -p "$f" "${STAGE}/$f"; count=$((count + 1))-done < <(git ls-files skills/)+done < <(git ls-files skills/ | grep -v -E "${EXCLUDE}")[ -f "${STAGE}/skills/anidoodle/SKILL.md" ] || { echo "ERROR: SKILL.md missing after copy (is it committed?)" >&2; exit 4; }[ "${count}" -ge 50 ] || { echo "ERROR: only ${count} files copied; expected the whole skill" >&2; exit 4; }diff --git a/skills/anidoodle/SKILL.md b/skills/anidoodle/SKILL.mdindex 9dbb02f..3d6a0e4 100644--- a/skills/anidoodle/SKILL.md+++ b/skills/anidoodle/SKILL.md@@ -21,7 +21,7 @@ that prevents each of those.Read `references/workflows/start-here.md` and run its intake: one question at a time, onlywhat the request leaves open, your recommendation first. **What** are they making, in **which-style** (show `assets/styles.jpg`; the list is `references/styles/INDEX.md`), what+style** (show the gallery sheet, https://github.com/alexgreensh/anidoodle/blob/main/skills/anidoodle/assets/styles.jpg; the list is `references/styles/INDEX.md`), what**shape** (1x1, 9x16, 16x9, 4x5 or any W x H), how **long** (any length; never cap it), what**sound** (silent or a music style and mood), which **characters**. "You pick" means pick andsay why in one line. Write the answers into a short brief before drawing.diff --git a/skills/anidoodle/engine/package-lock.json b/skills/anidoodle/engine/package-lock.jsonindex 79123db..058f838 100644--- a/skills/anidoodle/engine/package-lock.json+++ b/skills/anidoodle/engine/package-lock.json@@ -1,12 +1,12 @@{"name": "anidoodle-engine",- "version": "0.5.1",+ "version": "0.5.2","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "anidoodle-engine",- "version": "0.5.1",+ "version": "0.5.2","dependencies": {"esbuild": "^0.25.0"},diff --git a/skills/anidoodle/engine/package.json b/skills/anidoodle/engine/package.jsonindex 084cba4..4b7d893 100644--- a/skills/anidoodle/engine/package.json+++ b/skills/anidoodle/engine/package.json@@ -1,6 +1,6 @@{"name": "anidoodle-engine",- "version": "0.5.1",+ "version": "0.5.2","private": true,"type": "module","description": "Portable art core + backend adapters for illustrations, animations and films drawn entirely in code.",diff --git a/skills/anidoodle/engine/src/canvas-core/bake.ts b/skills/anidoodle/engine/src/canvas-core/bake.tsindex f956cef..a485823 100644--- a/skills/anidoodle/engine/src/canvas-core/bake.ts+++ b/skills/anidoodle/engine/src/canvas-core/bake.ts@@ -2,7 +2,7 @@// blurred and toothed). A web page has 6. So an interactive piece does the drawing ONCE, at mount,// into sprites, and each frame is a composite of sprites plus a handful of live marks.//-// A sprite is a pure function of its key (and env.scale, which the key includes): contract rule 5.+// A sprite is a pure function of its id (and env.scale, which the id includes): contract rule 5.// It is cropped to exactly the device box the drawing touched, at integer device pixels, so an// untransformed blit puts back the very pixels the plate drew. Moving parts are blitted with a// rotation or a DOWN-scale about a pivot, never an up-scale (contract rule 6).@@ -13,15 +13,15 @@ export const stats = { baked: 0, bytes: 0, ms: 0 }; // for the host's report onlconst resettable = (c: unknown) => !!c && typeof (c as { reset?: unknown }).reset === "function";const scratch = (env: Env): Layer => {- const DW = Math.round(env.W * env.scale), DH = Math.round(env.H * env.scale), key = `bake:scratch:${DW}x${DH}`;- let L = env.cache.get(key) as Layer | undefined;- if (L && resettable(L.ctx)) (L.ctx as unknown as { reset(): void }).reset(); else { L = env.canvas(DW, DH); env.cache.set(key, L); } /* see bake(): pristine, or new */+ const DW = Math.round(env.W * env.scale), DH = Math.round(env.H * env.scale), id = `bake:scratch:${DW}x${DH}`;+ let L = env.cache.get(id) as Layer | undefined;+ if (L && resettable(L.ctx)) (L.ctx as unknown as { reset(): void }).reset(); else { L = env.canvas(DW, DH); env.cache.set(id, L); } /* see bake(): pristine, or new */return L;};// Draw `fn` with a fresh Gfx on a clean full-size scratch, crop what it composited, cache it.-export const bake = (env: Env, key: string, fn: (g: Gfx) => void, o: { medium?: Medium; frame?: number; full?: boolean; raw?: boolean } = {}): Sprite => {- const k = `sprite:${key}@${env.scale}`, hit = env.cache.get(k) as Sprite | undefined; if (hit) return hit;+export const bake = (env: Env, id: string, fn: (g: Gfx) => void, o: { medium?: Medium; frame?: number; full?: boolean; raw?: boolean } = {}): Sprite => {+ const k = `sprite:${id}@${env.scale}`, hit = env.cache.get(k) as Sprite | undefined; if (hit) return hit;const S = scratch(env), DW = Math.round(env.W * env.scale), DH = Math.round(env.H * env.scale), c = S.ctx;c.setTransform(1, 0, 0, 1, 0, 0); c.globalAlpha = 1; c.globalCompositeOperation = "source-over"; c.clearRect(0, 0, DW, DH);// Every bake starts from pristine surfaces. Measured in Chromium: a 2D canvas that has EVER filled@@ -94,5 +94,5 @@ export class Only extends Gfx {inkGroup(fn: () => void, o: Parameters<Gfx["inkGroup"]>[1] = {}) { const i = this.n++; this.census.push("inkGroup"); if (this.keep(i)) super.inkGroup(fn, o); }}// bake() for a part of a plate: `draw(g)` receives an Only that keeps groups in `keep`.-export const bakePart = (env: Env, key: string, keep: (i: number) => boolean, draw: (g: Gfx) => void, o: { medium?: Medium; frame?: number } = {}): Sprite =>- bake(env, key, (g0) => { const g = new Only(g0.main, env, o.frame ?? 0, o.medium ?? PENCIL, keep); draw(g); g0.drawn = g.drawn; }, o);+export const bakePart = (env: Env, id: string, keep: (i: number) => boolean, draw: (g: Gfx) => void, o: { medium?: Medium; frame?: number } = {}): Sprite =>+ bake(env, id, (g0) => { const g = new Only(g0.main, env, o.frame ?? 0, o.medium ?? PENCIL, keep); draw(g); g0.drawn = g.drawn; }, o);diff --git a/skills/anidoodle/references/workflows/adapt-a-style.md b/skills/anidoodle/references/workflows/adapt-a-style.mdindex 285794f..071ef4e 100644--- a/skills/anidoodle/references/workflows/adapt-a-style.md+++ b/skills/anidoodle/references/workflows/adapt-a-style.md@@ -80,7 +80,7 @@ header before any code:- **NOT**: `paintedOil` models form in depth; this hand keeps the ground flat and decorative withone step of shadow. The subject is the film's own koi, never the painting's branch.-The reference itself ships at `engine/assets/refs/vangogh-almond-blossom.jpg`, the one image in+The reference itself lives in the anidoodle repository at `engine/assets/refs/` (not in the installed plugin), the one image inthe repo not drawn by code: public domain (Van Gogh died in 1890; a faithful photograph of a 2Dpublic-domain work), downloaded from Wikimedia Commons and kept byte-identical, with its source,licence and sha256 in `engine/assets/refs/PROVENANCE.json`. The launch films show it only as thediff --git a/skills/anidoodle/references/workflows/start-here.md b/skills/anidoodle/references/workflows/start-here.mdindex 4694b11..2272aff 100644--- a/skills/anidoodle/references/workflows/start-here.md+++ b/skills/anidoodle/references/workflows/start-here.md@@ -14,7 +14,7 @@ pick", pick, say what you picked and why in one line, and carry on.explainer, an infographic, a launch or product video, an interactive web piece, a drawinglesson, a character, or a style matched from their image. The table in `SKILL.md` routes eachone to its workflow file.-2. **Which style?** Show the gallery (`assets/styles.jpg`, one tile per hand; the list with+2. **Which style?** Show the gallery (https://github.com/alexgreensh/anidoodle/blob/main/skills/anidoodle/assets/styles.jpg, one tile per hand; the list witheach hand's medium is `references/styles/INDEX.md`). Recommend two or three hands that suit thesubject and the audience, with one reason each. Offer two other routes:- **"Match my image"**: they bring a picture and you adapt its hand (`adapt-a-style.md`).