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
launch kit: shared typing, drop and answer card in launchKit; the cut as data (makeCut, beatGrid, bloomFrame, typeFrame) in launchCut; launch3 pixel-identical (8/8 still md5)
Alex Greenshpun0ab75bdaeb94
diff --git a/skills/anidoodle/engine/src/canvas-core/launch2.ts b/skills/anidoodle/engine/src/canvas-core/launch2.tsindex 01dacaf..fb6fbed 100644--- a/skills/anidoodle/engine/src/canvas-core/launch2.ts+++ b/skills/anidoodle/engine/src/canvas-core/launch2.ts@@ -10,8 +10,8 @@import type { Ctx, Env, P } from "./core";import type { Film } from "./film";import {- C, GEN, HOME, INPUT, MONO, REPLY, SANS, TEXT, blot, camLerp, caretAt, clamp, drawChatFrame, expo, inOut, lerp, lerpP,- out3, pathOf, plateLayer, pointer, press, ramp, rr, selfLayer, softShadow, useCam, type Cam,+ 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";@@ -36,8 +36,6 @@ export const T2 = {const N = T2.end[1];// ---------------------------------------------------------------- small helpers-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.6 * rate : 0); out.push(t); } return out; };-const typedAt = (text: string, f: number, times: number[]) => text.slice(0, times.filter((t) => f >= t).length);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@@ -100,13 +98,7 @@ const drawCard = (ctx: Ctx, env: Env, it: Extract<Item, { kind: "card" }>, x: nuctx.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) => {- if (f < d.t0 - 6 || f >= d.land) return;- 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, 30 * (0.3 + 0.7 * w), 0, Math.PI * 2); ctx.fill(); return; }- const at = (g: number): P => { const u = ramp(g, d.t0, d.land), e = inOut(u); return [lerp(GEN_C[0], to[0], e), lerp(GEN.y - 16, to[1], e) - Math.sin(Math.PI * u) * 150]; };- for (let k = 24; k >= 0; k--) { const p = at(f - k * 0.1); ctx.fillStyle = C.ink; ctx.globalAlpha = k === 0 ? 1 : 0.22 * (1 - k / 25); ctx.beginPath(); ctx.arc(p[0], p[1], 30 * (1 - k * 0.022), 0, Math.PI * 2); ctx.fill(); }- ctx.globalAlpha = 1;-};+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 });diff --git a/skills/anidoodle/engine/src/canvas-core/launch3.ts b/skills/anidoodle/engine/src/canvas-core/launch3.tsindex c337148..2b36c57 100644--- a/skills/anidoodle/engine/src/canvas-core/launch3.ts+++ b/skills/anidoodle/engine/src/canvas-core/launch3.ts@@ -5,18 +5,17 @@// 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, blot, expo, pathOf, ramp, selfLayer } from "./launchKit";+import { C } from "./launchKit";import { content2, SFX2, T2, WEB_SKIP } from "./launch2";-import { logoBug, measure, writeOn, type KStyle } from "./kinetic";+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;-type Line = { text: string; style: KStyle; color: string };-type Seg = { kind: "pic"; from: number; to: number; len: number } | { kind: "type"; lines: Line[]; len: number; before: number; after: number };-const pic = (from: number, to: number, len = to - from): Seg => ({ kind: "pic", from, to, len });-const type = (lines: Line[], len: number, before: number, after = before): Seg => ({ kind: "type", lines, len, before, after });+// 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.@@ -38,35 +37,21 @@ const HEAD: Seg[] = [pic(WEB_FROM, WEB_FROM + WEB_LEN),type([{ text: "FILMS", style: "ink", color: C.ink }], 60, WEB_FROM + WEB_LEN - 1, T2.film[0]),];-const headLen = HEAD.reduce((a, s) => a + s.len, 0), CLAIM = 26 * 80, FILM_LEN = CLAIM - 140 - headLen;-if (FILM_LEN < 90) throw new Error(`launch3: the film beat would be ${FILM_LEN} frames; the cut before it is too long for the claim to land on bar 26`);+// 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 STARTS = (() => { let t = 0; return SEGS.map((s) => { const a = t; t += s.len; return a; }); })();-export const N3 = STARTS[STARTS.length - 1] + SEGS[SEGS.length - 1].len;-const at = (F: number) => { let i = SEGS.length - 1; while (i > 0 && STARTS[i] > F) i--; return { s: SEGS[i], local: F - STARTS[i] }; };-const contentOf = (s: Extract<Seg, { kind: "pic" }>, local: number) => s.from + ((s.to - s.from) * local) / s.len;+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 = (c: number) => { for (let i = 0; i < SEGS.length; i++) { const s = SEGS[i]; if (s.kind === "pic" && c >= s.from && c < s.to) return STARTS[i] + ((c - s.from) * s.len) / (s.to - s.from); } return -1; };+export const cutOf = CUT.cutOf;// ---------------------------------------------------------------- a type frameconst 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: Extract<Seg, { kind: "type" }>, local: number, F: number) => {- const u = expo(ramp(local, 0, IN + 2)), v = expo(ramp(local, s.len - OUT, s.len)), R = 1250 * (v > 0 ? 1 - v : u);- content2(ctx, env, local < s.len / 2 ? s.before : s.after);- if (R < 2) return;- 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 n = s.lines.length, size = Math.min(n === 1 ? 190 : 130, ...s.lines.map((l) => (1560 / measure(l.text, 100)) * 100)), gap = size * 1.45, y0 = H / 2 - ((n - 1) * gap) / 2 + size * 0.5;- s.lines.forEach((l, i) => writeOn(c, env, l.text, W / 2, y0 + i * gap, size, ramp(local, IN - 2 + i * 20, IN + 16 + i * 20), l.style, { color: l.color, align: "center", seed: 7 + i }));- logoBug(c, env, F, 1700, 1040, 0.9, { t0: -100, fps: FPS });- const ctr: [number, number] = [W / 2, H / 2];- ctx.setTransform(env.scale, 0, 0, env.scale, 0, 0); ctx.save();- pathOf(ctx, blot(ctr, R + 26, 88)); ctx.fillStyle = C.ink; ctx.fill(); pathOf(ctx, blot(ctr, Math.max(0, R - 4), 88)); ctx.clip();- ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(L.canvas, 0, 0); ctx.restore();-};+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 soundconst audio3 = (sr: number): [Float32Array, Float32Array] => {diff --git a/skills/anidoodle/engine/src/canvas-core/launchCut.ts b/skills/anidoodle/engine/src/canvas-core/launchCut.tsnew file mode 100644index 0000000..ad01e07--- /dev/null+++ b/skills/anidoodle/engine/src/canvas-core/launchCut.ts@@ -0,0 +1,89 @@+// LAUNCH CUT. A launch film is two things: the CONTENT (a continuous timeline of pictures, the chat,+// the plates) and the CUT, a list of data segments that picks spans of that content, re-times them,+// and splices full-frame TYPE FRAMES between them. Re-timing a film is then an edit to a list, never+// to scene code. launch3.ts is the worked example; launchTemplate.ts builds your own film on it.+//+// const cut = makeCut([pic(0, 200), type(lines, 64, 199, 200), pic(200, 360, 90), ...]);+// cut.N the cut's length in frames+// cut.at(F) which segment frame F is in, and the local frame inside it+// cut.contentOf(s,l) the content frame a picture segment shows at local frame l+// cut.cutOf(c) where content frame c lands in the cut (for sound events), -1 if cut away+//+// Type frames are an ink bloom: ink opens from the centre over the picture, a page is inside the+// bloom, the words letter themselves on it, and the ink closes to a point on the next picture.+// Words never sit over the art.+import type { Ctx, Env, P } from "./core";+import { C, blot, expo, pathOf, ramp, selfLayer } from "./launchKit";+import { measure, writeOn, type KStyle } from "./kinetic";++export type TypeLine = { text: string; style: KStyle; color: string };+export type PicSeg = { kind: "pic"; from: number; to: number; len: number };+export type TypeSeg = { kind: "type"; lines: TypeLine[]; len: number; before: number; after: number };+export type Seg = PicSeg | TypeSeg;+// a span of content [from, to) played over `len` frames (len < to - from plays it faster)+export const pic = (from: number, to: number, len = to - from): Seg => ({ kind: "pic", from, to, len });+// a type frame of `len` frames; the bloom opens over content frame `before`, closes onto `after`+export const type = (lines: TypeLine[], len: number, before: number, after = before): Seg => ({ kind: "type", lines, len, before, after });++export const makeCut = (SEGS: Seg[]) => {+ const STARTS = (() => { let t = 0; return SEGS.map((s) => { const a = t; t += s.len; return a; }); })();+ const N = STARTS[STARTS.length - 1] + SEGS[SEGS.length - 1].len;+ const at = (F: number) => { let i = SEGS.length - 1; while (i > 0 && STARTS[i] > F) i--; return { s: SEGS[i], local: F - STARTS[i] }; };+ const contentOf = (s: PicSeg, local: number) => s.from + ((s.to - s.from) * local) / s.len;+ const cutOf = (c: number) => { for (let i = 0; i < SEGS.length; i++) { const s = SEGS[i]; if (s.kind === "pic" && c >= s.from && c < s.to) return STARTS[i] + ((c - s.from) * s.len) / (s.to - s.from); } return -1; };+ return { SEGS, STARTS, N, at, contentOf, cutOf };+};++// The beat grid: at `bpm` and `fps`, how many frames a beat and a bar (4 beats) last. Cut on+// downbeats (bar starts), land the claim on a chosen bar, and solve one flexible segment's length+// so it does: `solve(bar, fixedFrames)` = frames left for the flexible segment, or throw.+export const beatGrid = (bpm: number, fps: number) => {+ const beat = (60 / bpm) * fps, bar = beat * 4;+ return {+ beat, bar,+ frameOf: (barNo: number, beatNo = 0) => Math.round(barNo * bar + beatNo * beat),+ solve: (barNo: number, fixed: number, min = 60) => {+ const left = Math.round(barNo * bar) - fixed;+ if (left < min) throw new Error(`beatGrid: only ${left} frames left to land on bar ${barNo}; shorten the cut before it or pick a later bar`);+ return left;+ },+ };+};++// ---------------------------------------------------------------- the bloom+export type BloomOpts = { inF?: number; outF?: number; close?: boolean; radius?: number; seed?: number; bg?: string; ink?: string; W?: number; H?: number };+// A full-frame page inside an ink bloom. `under` draws the picture the bloom opens over (and closes+// onto); `page` draws the page, in screen coordinates, on an offscreen sheet. With close: false the+// bloom stays open (an end card).+// the bloom's radius at a local frame: a page is fully covered while it is 1110 or more (1920x1080)+export const bloomRadius = (local: number, len: number, o: BloomOpts = {}) => {+ const IN = o.inF ?? 14, OUT = o.outF ?? 14, u = expo(ramp(local, 0, IN + 2)), v = o.close === false ? 0 : expo(ramp(local, len - OUT, len));+ return (o.radius ?? 1250) * (v > 0 ? 1 - v : u);+};+export const bloomFrame = (ctx: Ctx, env: Env, local: number, len: number, under: (first: boolean) => void, page: (c: Ctx) => void, o: BloomOpts = {}) => {+ const IN = o.inF ?? 14, OUT = o.outF ?? 14, W = o.W ?? 1920, H = o.H ?? 1080;+ const u = expo(ramp(local, 0, IN + 2)), v = o.close === false ? 0 : expo(ramp(local, len - OUT, len)), R = (o.radius ?? 1250) * (v > 0 ? 1 - v : u);+ under(local < len / 2);+ if (R < 2) return;+ 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 = o.bg ?? C.bg; c.fillRect(0, 0, W, H);+ page(c);+ const ctr: P = [W / 2, H / 2], seed = o.seed ?? 88;+ ctx.setTransform(env.scale, 0, 0, env.scale, 0, 0); ctx.save();+ pathOf(ctx, blot(ctr, R + 26, seed)); ctx.fillStyle = o.ink ?? C.ink; ctx.fill(); pathOf(ctx, blot(ctr, Math.max(0, R - 4), seed)); ctx.clip();+ ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(L.canvas, 0, 0); ctx.restore();+};++// A type frame: one to three lines, each written on by its own tool, 20 frames apart, sized to fit.+// `bug` draws a corner brand mark on the page (the logo recurs on every frame of the film).+// `lead`: when the first line starts, relative to the bloom being open (default -2); `stagger`: frames+// between lines (default 20); a line takes 18 frames to write.+export type TypeOpts = BloomOpts & { maxW?: number; lead?: number; stagger?: number };+export const typeFrame = (ctx: Ctx, env: Env, lines: TypeLine[], local: number, len: number, under: (first: boolean) => void, bug?: (c: Ctx) => void, o: TypeOpts = {}) => {+ const IN = o.inF ?? 14, W = o.W ?? 1920, H = o.H ?? 1080, maxW = o.maxW ?? 1560, lead = o.lead ?? -2, st = o.stagger ?? 20;+ bloomFrame(ctx, env, local, len, under, (c) => {+ const n = lines.length, size = Math.min(n === 1 ? 190 : 130, ...lines.map((l) => (maxW / measure(l.text, 100)) * 100)), gap = size * 1.45, y0 = H / 2 - ((n - 1) * gap) / 2 + size * 0.5;+ lines.forEach((l, i) => writeOn(c, env, l.text, W / 2, y0 + i * gap, size, ramp(local, IN + lead + i * st, IN + lead + 18 + i * st), l.style, { color: l.color, align: "center", seed: 7 + i }));+ bug?.(c);+ }, o);+};diff --git a/skills/anidoodle/engine/src/canvas-core/launchKit.ts b/skills/anidoodle/engine/src/canvas-core/launchKit.tsindex 08efe06..ee6d24f 100644--- a/skills/anidoodle/engine/src/canvas-core/launchKit.ts+++ b/skills/anidoodle/engine/src/canvas-core/launchKit.ts@@ -114,6 +114,8 @@ export type ChatState = {attach?: { img: CanvasImageSource; label: string } | null;genPress?: number; genHot?: number; // the button: press depth 0..1, hover glow 0..1label?: string; labelAlpha?: number; // the reply's byline+ // your product: the thread's name and subline, the button's word, the accent (defaults: anidoodle's own)+ title?: string; subtitle?: string; genLabel?: string; accent?: string;};export const drawChatFrame = (ctx: Ctx, s: ChatState) => {@@ -122,8 +124,9 @@ export const drawChatFrame = (ctx: Ctx, s: ChatState) => {ctx.fillStyle = C.card; rr(ctx, CHAT.x, CHAT.y, CHAT.w, CHAT.h, CHAT.r); ctx.fill();// the thread's head: a small ink dot and a name, nothing that belongs to anyone elsectx.fillStyle = C.ink; ctx.beginPath(); ctx.arc(CHAT.x + 58, CHAT.y + 52, 9, 0, Math.PI * 2); ctx.fill();- ctx.font = SANS(600, 22); ctx.fillStyle = C.ink; ctx.textBaseline = "middle"; ctx.fillText("anidoodle", CHAT.x + 80, CHAT.y + 53);- ctx.font = SANS(500, 18); ctx.fillStyle = C.mute; ctx.fillText("drawn in code", CHAT.x + 196, CHAT.y + 54);+ ctx.font = SANS(600, 22); ctx.fillStyle = C.ink; ctx.textBaseline = "middle"; ctx.fillText(s.title ?? "anidoodle", CHAT.x + 80, CHAT.y + 53);+ const subX = s.title === undefined ? CHAT.x + 196 : CHAT.x + 80 + ctx.measureText(s.title).width + 16;+ ctx.font = SANS(500, 18); ctx.fillStyle = C.mute; ctx.fillText(s.subtitle ?? "drawn in code", subX, CHAT.y + 54);ctx.fillStyle = C.line; ctx.fillRect(CHAT.x + 32, CHAT.y + 98, CHAT.w - 64, 1.5);// the sent message, right alignedif (s.sent) {@@ -142,15 +145,17 @@ export const drawChatFrame = (ctx: Ctx, s: ChatState) => {ctx.font = SANS(500, TEXT.px); ctx.textBaseline = "alphabetic";if (!s.typed && s.placeholder) { ctx.fillStyle = C.mute; ctx.fillText(s.placeholder, TEXT.x, TEXT.base); }ctx.fillStyle = C.ink; ctx.fillText(s.typed, TEXT.x, TEXT.base);- if (s.caret) { const x = TEXT.x + ctx.measureText(s.typed).width + 3; ctx.fillStyle = C.accent; ctx.fillRect(x, TEXT.base - 32, 3, 40); }+ const acc = s.accent ?? C.accent;+ if (s.caret) { const x = TEXT.x + ctx.measureText(s.typed).width + 3; ctx.fillStyle = acc; ctx.fillRect(x, TEXT.base - 32, 3, 40); }// Generateconst pr = s.genPress ?? 0, hot = s.genHot ?? 0, k = 1 - 0.07 * pr, gx = GEN.x + (GEN.w * (1 - k)) / 2, gy = GEN.y + (GEN.h * (1 - k)) / 2;- ctx.fillStyle = hot > 0 ? mixHex(C.accent, C.accentDeep, 0.35 * hot + 0.4 * pr) : C.accent; rr(ctx, gx, gy, GEN.w * k, GEN.h * k, GEN.r * k); ctx.fill();- ctx.fillStyle = "#fff"; ctx.font = SANS(600, 24 * k); ctx.textBaseline = "middle"; ctx.textAlign = "center"; ctx.fillText("Generate", GEN.x + GEN.w / 2, GEN.y + GEN.h / 2 + 1); ctx.textAlign = "left";+ ctx.fillStyle = hot > 0 ? mixHex(acc, s.accent ? deepen(acc) : C.accentDeep, 0.35 * hot + 0.4 * pr) : acc; rr(ctx, gx, gy, GEN.w * k, GEN.h * k, GEN.r * k); ctx.fill();+ ctx.fillStyle = "#fff"; ctx.font = SANS(600, 24 * k); ctx.textBaseline = "middle"; ctx.textAlign = "center"; ctx.fillText(s.genLabel ?? "Generate", GEN.x + GEN.w / 2, GEN.y + GEN.h / 2 + 1); ctx.textAlign = "left";};export const caretAt = (ctx: Ctx, typed: string): P => { ctx.font = SANS(500, TEXT.px); return [TEXT.x + ctx.measureText(typed).width, TEXT.base - 12]; };const hx = (h: string) => [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16));+const deepen = (h: string) => "#" + hx(h).map((v) => Math.round(v * 0.78).toString(16).padStart(2, "0")).join("");export const mixHex = (a: string, b: string, t: number) => { const x = hx(a), y = hx(b); return `rgb(${x.map((v, i) => Math.round(lerp(v, y[i], clamp(t)))).join(",")})`; };// the art card: paper, a hairline, and whatever layer is inside, clipped to the rounded square@@ -161,3 +166,31 @@ export const artCard = (ctx: Ctx, x: number, y: number, s: number, L: Layer | nuctx.restore();ctx.lineWidth = 1.5; ctx.strokeStyle = "rgba(0,0,0,0.08)"; rr(ctx, x, y, s, s, r); ctx.stroke();};++// ---------------------------------------------------------------- typing, the drop, the answer card+// Human typing: the time each character lands, uneven and seeded, spaces a little slower.+export 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.6 * rate : 0); out.push(t); } return out; };+export const typedAt = (text: string, f: number, times: number[]) => text.slice(0, times.filter((t) => f >= t).length);+// The drop: a bead of ink lifts off Generate and arcs to where the answer card will land.+export type Drop = { t0: number; land: number; full: number };+export const inkDrop = (ctx: Ctx, f: number, d: { t0: number; land: number }, to: P) => {+ const GEN_C: P = [GEN.x + GEN.w / 2, GEN.y + GEN.h / 2];+ if (f < d.t0 - 6 || f >= d.land) return;+ 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, 30 * (0.3 + 0.7 * w), 0, Math.PI * 2); ctx.fill(); return; }+ const at = (g: number): P => { const u = ramp(g, d.t0, d.land), e = inOut(u); return [lerp(GEN_C[0], to[0], e), lerp(GEN.y - 16, to[1], e) - Math.sin(Math.PI * u) * 150]; };+ for (let k = 24; k >= 0; k--) { const p = at(f - k * 0.1); ctx.fillStyle = C.ink; ctx.globalAlpha = k === 0 ? 1 : 0.22 * (1 - k / 25); ctx.beginPath(); ctx.arc(p[0], p[1], 30 * (1 - k * 0.022), 0, Math.PI * 2); ctx.fill(); }+ ctx.globalAlpha = 1;+};+// The answer card in the thread: a byline, then the art, revealed by the landed drop blooming open.+// `art` is any layer (plateLayer gives a live plate); `crop` picks a source rectangle.+export const inkCard = (ctx: Ctx, x: number, y: number, s: number, f: number, d: Drop, art: Layer, label: string, crop?: [number, number, number, number]) => {+ ctx.fillStyle = C.ink; ctx.globalAlpha = ramp(f, d.land, d.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(label, x + 26, y - 15); ctx.globalAlpha = 1;+ const grow = out3(ramp(f, d.land, d.full)), c: P = [x + s / 2, y + s / 2];+ 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 (crop) ctx.drawImage(art.canvas, ...crop, x, y, s, s); else ctx.drawImage(art.canvas, x, y, s, s);+ ctx.restore();+};