Hand-drawn 2D animation written as code: detail bible, a detailed ant rig, brush/watercolour pen, frame-matched recreation loop, synthesised sound. Node canvas + ffmpeg.
JavaScript
Add faceted low-poly look and a 30 s ambient loop example
buildwithhanif942dff2ab5b4
diff --git a/README.md b/README.mdindex edbf8d4..9e90596 100644--- a/README.md+++ b/README.md@@ -37,6 +37,12 @@ overwrites a good file with a failed encode.## The example films+`examples/claude-balloon/` — a 30 s seamless loop in faceted low-poly poster style: the orange hero drifts+through a dusk canyon in a hot-air balloon, birds cross, clouds wrap, the river shimmers. Ambient score.++++`examples/claude-game/` — 30 s, 16:9 video-game short: an orange block hero runs, jumps and flips acrossa textured platform level, punches, kicks and stomps bugs, then fights a boss. Hit-stop on every contact,screen shake, sparks, comic words, damage numbers, a combo counter, a boss HP bar, a charged special, K.O.,@@ -96,6 +102,7 @@ plugins/claude-animation/skills/claude-animation/lib/textures.mjs paper, light bands, sun, moon, stars, grass, soil, night sky, fruit cells, film finishlib/nature.mjs sprout, melon leaf, tendril, vine, blossom, bee, droplib/colony.mjs leaf, leaf piece, egg, larva, cocoon, seed, fungus, roots, nest cross-section+ lib/lowpoly.mjs faceted low-poly landscapes: lit triangles from gradient ramps, haze, clouds, ridgeslib/fx.mjs hit-stop, screen shake, particles, rings, flashes, comic words, damage numbers, afterimageslib/rigs/critter.mjs a blocky action hero (run, jump, flip, punch, kick, hurt, charge)lib/rigs/bug.mjs a beetle enemy and boss@@ -105,9 +112,11 @@ plugins/claude-animation/skills/claude-animation/scripts/sound.mjs synthesised SFX on a cue timeline + bed + loudnorm + muxscripts/music.mjs an original ukulele bed of any lengthscripts/chiptune.mjs an original video-game soundtrack with timed sections+ scripts/ambient.mjs an original ambient bed (pads, bells, wind) that loopsscripts/rig-sheet.mjs the pose sheet a rig must passtemplates/ film-template.mjs, beat-sheet.mdreferences/ workflow, detail, characters, motion, styles, sound, traps, prior-art+examples/claude-balloon/ the 30 s low-poly ambient loopexamples/claude-game/ the 30 s video-game shortexamples/ant-colony/ the 32 s colony film```diff --git a/docs/balloon.jpg b/docs/balloon.jpgnew file mode 100644index 0000000..5015671Binary files /dev/null and b/docs/balloon.jpg differdiff --git a/examples/claude-balloon/film.mjs b/examples/claude-balloon/film.mjsnew file mode 100644index 0000000..3e47319--- /dev/null+++ b/examples/claude-balloon/film.mjs@@ -0,0 +1,134 @@+// film.mjs — "Claude's Balloon": a 30 s ambient loop in the faceted low-poly poster style.+// node film.mjs sheet 0,6,12,18,24,29.9 | verify | cues | render+//+// STYLE BIBLE: flat vector, faceted (lib/lowpoly.mjs), no outlines on the landscape. Dusk ramp: plum sky →+// rose → peach at the horizon; canyon rocks orange → magenta → deep plum, lit from the left. Distant layers+// fade toward the haze colour. The only outlined things are the balloon rig and Claude (the character reads+// as "drawn" against a painted world). Every motion is periodic in 30 s, so the file loops seamlessly.+import path from "node:path";+import fs from "node:fs";+import { fileURLToPath } from "node:url";+const HERE = path.dirname(fileURLToPath(import.meta.url));+const LIB = process.env.CLAUDE_ANIMATION_LIB || path.join(HERE, "../../plugins/claude-animation/skills/claude-animation/lib");+const { clamp, lerp, ss, eIO, at, line, ellipse, stroke, fill, poly, smooth, hatch, rrect, rng, rad, hash, createCanvas, INK } = await import(path.join(LIB, "core.mjs"));+const { RAMPS, facetMass, ridge, skyGradient, facetCloud, rampColor } = await import(path.join(LIB, "lowpoly.mjs"));+const { starburst } = await import(path.join(LIB, "fx.mjs"));+const { critter } = await import(path.join(LIB, "rigs/critter.mjs"));+const { filmFinish } = await import(path.join(LIB, "textures.mjs"));+const { run } = await import(path.join(LIB, "film.mjs"));+const { GlobalFonts } = await import(path.join(LIB, "../node_modules/@napi-rs/canvas/index.js"));+const FD = process.env.FONT_DIR || path.join(process.env.HOME, ".claude/skills/tesseract-edit/assets/fonts");+if (fs.existsSync(path.join(FD, "Inter/Inter_28pt-Medium.ttf"))) GlobalFonts.registerFromPath(path.join(FD, "Inter/Inter_28pt-Medium.ttf"), "IMed");++const W = 1920, H = 1080, FPS = 30, DUR = 30, TAU = Math.PI * 2;+const HAZE = "#E8A08A";+const loop = (t, period) => ((t % period) + period) % period / period; // 0..1 phase that repeats++// ---------------------------------------------------------------- the painted world (baked once)+function buildWorld() {+ const sky = createCanvas(W, H), s = sky.getContext("2d");+ skyGradient(s, W, H, [[0, "#2E1B48"], [.38, "#8A3E6E"], [.62, "#D8667A"], [.8, "#F2A07A"], [1, "#FBD3A0"]], [1250, 600, 64, "#FFE7B8"]);+ const r = rng(3); for (let i = 0; i < 90; i++) { const x = r() * W, y = r() * 330, a = .25 + .5 * (1 - y / 330); s.fillStyle = `rgba(255,240,230,${a * r()})`; s.beginPath(); s.arc(x, y, .8 + r() * 1.6, 0, 7); s.fill(); }+ const far = facetMass(W, H, ridge(0, W, H, [610, 540, 575, 505, 560, 520, 590, 560], 2, 22), { ramp: RAMPS.dusk, fade: .58, haze: HAZE, cell: 74, seed: 3 });+ const mid = facetMass(W, H, ridge(0, W, H, [720, 660, 700, 630, 690, 650, 710, 680], 5, 34), { ramp: RAMPS.mesa, fade: .32, haze: HAZE, cell: 66, seed: 4 });+ // mesas with flat tops in the middle distance+ const mesaPoly = (x0, x1, top, base, lean = 30) => [[x0, base], [x0 + lean, top + 14], [x0 + lean + 30, top], [x1 - lean - 30, top], [x1 - lean, top + 16], [x1, base]];+ const mesas = createCanvas(W, H), m = mesas.getContext("2d");+ for (const [x0, x1, top, sd] of [[520, 820, 560, 11], [1040, 1300, 590, 12]]) m.drawImage(facetMass(W, H, mesaPoly(x0, x1, top, 860), { ramp: RAMPS.mesa, fade: .18, haze: HAZE, cell: 50, dome: [(x0 + x1) / 2, (x1 - x0) / 2], seed: sd }), 0, 0);+ // the river winding out of the canyon+ const riverP = [[700, H], [780, 1000], [880, 940], [930, 890], [960, 862], [1000, 856], [1030, 866], [1010, 900], [1080, 950], [1180, 1010], [1260, H]];+ const river = facetMass(W, H, riverP, { ramp: ["#3A2450", "#5A3468", "#8A4A7A", "#C0708A", "#E8A09A", "#F8D6B8"], light: [-.2, -.9, .6], cell: 40, zAmp: 16, bottomDark: .25, ridge: .8, contrast: .7, seed: 8 });+ const floor = facetMass(W, H, [[380, H], [380, 850], [700, 840], [1200, 845], [1560, 850], [1560, H]], { ramp: RAMPS.canyon, fade: .1, haze: HAZE, cell: 60, bottomDark: .7, seed: 9 });+ // foreground cliffs framing the view+ const left = [[0, H], [0, 170], [70, 128], [190, 150], [270, 230], [330, 420], [390, 640], [430, 860], [470, H]];+ const right = [[W, H], [W, 150], [1850, 118], [1730, 170], [1640, 300], [1590, 520], [1540, 760], [1500, H]];+ const cliffs = createCanvas(W, H), c = cliffs.getContext("2d");+ c.drawImage(facetMass(W, H, left, { ramp: RAMPS.canyon, cell: 58, dome: [190, 250], seed: 5 }), 0, 0);+ c.drawImage(facetMass(W, H, right, { ramp: RAMPS.canyon, cell: 58, dome: [1730, 240], seed: 6 }), 0, 0);+ // a little lit window hut on the left cliff top: someone lives here+ c.save(); poly(c, [[70, 128], [70, 96], [98, 74], [126, 96], [126, 128]]); fill(c, "#5A2A3A"); poly(c, rrect(88, 102, 20, 18, 3)); fill(c, "#FFD27A"); c.restore();+ const clouds = [facetCloud(460, 170, 2), facetCloud(340, 130, 5), facetCloud(560, 190, 9), facetCloud(300, 110, 13)];+ return { sky, far, mid, mesas, river, floor, cliffs, clouds };+}++// ---------------------------------------------------------------- the balloon (envelope baked once)+const EW = 300, EH = 350;+function buildEnvelope() {+ const P = []; for (let i = 0; i <= 60; i++) { const a = -Math.PI / 2 + i / 60 * TAU, x = Math.cos(a), y = Math.sin(a); const taper = y > 0 ? 1 - .55 * Math.pow(y, 1.6) : 1;+ P.push([EW / 2 + x * EW * .48 * taper, EH * .46 + y * EH * .46 * (y > 0 ? 1.08 : 1)]); }+ const base = facetMass(EW, EH + 20, P, { ramp: RAMPS.balloon, light: [-.8, -.4, .5], cell: 30, zAmp: 12, dome: [EW / 2, EW * .48], bottomDark: .35, ridge: .2, contrast: 1.2, seed: 21 });+ const cream = facetMass(EW, EH + 20, P, { ramp: ["#8A6A5A", "#C8A890", "#E8D0B8", "#F6E6D2", "#FFF4E6", "#FFFFFF"], light: [-.8, -.4, .5], cell: 30, zAmp: 12, dome: [EW / 2, EW * .48], bottomDark: .35, ridge: .2, contrast: 1.2, seed: 21 });+ const c = createCanvas(EW, EH + 20), x = c.getContext("2d"); x.drawImage(base, 0, 0);+ // cream gores: vertical bands that follow the envelope's curve+ x.save(); x.beginPath(); for (const k of [-.62, -.12, .38]) { const u0 = k, u1 = k + .24;+ for (let i = 0; i <= 30; i++) { const yy = i / 30 * EH, w2 = EW * .48 * Math.sqrt(Math.max(0, 1 - Math.pow((yy - EH * .46) / (EH * .5), 2))); const xx = EW / 2 + Math.sin(u0 * Math.PI / 2) * w2; i ? x.lineTo(xx, yy) : x.moveTo(xx, yy); }+ for (let i = 30; i >= 0; i--) { const yy = i / 30 * EH, w2 = EW * .48 * Math.sqrt(Math.max(0, 1 - Math.pow((yy - EH * .46) / (EH * .5), 2))); x.lineTo(EW / 2 + Math.sin(u1 * Math.PI / 2) * w2, yy); } x.closePath(); }+ x.clip(); x.drawImage(cream, 0, 0); x.restore();+ starburst(x, EW / 2 + 18, EH * .42, 46, { rays: 10, color: "#D97757", inner: .4, outline: false, rot: .1 });+ x.save(); poly(x, P); stroke(x, 3, "rgba(42,15,46,.85)"); x.restore();+ return c;+}+function balloon(ctx, x, y, tilt, t, S, burn) {+ ctx.save(); ctx.translate(x, y); ctx.rotate(tilt);+ // burner glow lights the envelope from inside+ if (burn > 0) { const g = ctx.createRadialGradient(0, 40, 10, 0, -60, 260); g.addColorStop(0, `rgba(255,200,110,${.55 * burn})`); g.addColorStop(1, "rgba(255,200,110,0)"); ctx.fillStyle = g; ctx.fillRect(-300, -380, 600, 600); }+ ctx.drawImage(S.env, -EW / 2, -EH - 60);+ if (burn > 0) { ctx.save(); ctx.globalCompositeOperation = "screen"; ctx.globalAlpha = .35 * burn; ctx.drawImage(S.env, -EW / 2, -EH - 60); ctx.restore(); }+ // ropes+ for (const [ax, bx] of [[-58, -48], [-22, -18], [22, 18], [58, 48]]) line(ctx, [[ax, -70], [bx, 64]], 2, "rgba(42,15,46,.9)");+ // burner + flame+ poly(ctx, rrect(-16, 30, 32, 18, 4)); fill(ctx, "#6A6A72"); stroke(ctx, 2);+ if (burn > 0) { const fl = 1 + .2 * Math.sin(t * 40); ctx.save(); ctx.globalAlpha = burn; ctx.beginPath(); ctx.moveTo(-12, 32); ctx.quadraticCurveTo(-14, -10 * fl, 0, -46 * fl); ctx.quadraticCurveTo(14, -10 * fl, 12, 32); ctx.closePath();+ const fg = ctx.createLinearGradient(0, 32, 0, -46); fg.addColorStop(0, "#FFF2B0"); fg.addColorStop(.5, "#FFB24A"); fg.addColorStop(1, "rgba(255,90,40,.2)"); ctx.fillStyle = fg; ctx.fill(); ctx.restore(); }+ // Claude in the basket: body first, basket front over its legs+ const look = Math.sin(t * .8) * .5 + .5, blink = (t % 3.7) < .12, wave = ss(11.6, 12.1, t) * (1 - ss(14.4, 14.9, t));+ critter(ctx, 0, 86, .62, { t, face: blink ? "blink" : wave > .5 ? "happy" : "normal", flip: look < .15, arms: wave > .5 ? "up" : "rest", sq: 1 + .02 * Math.sin(t * 3) });+ const B = rrect(-60, 64, 120, 70, 10); poly(ctx, B); const bg = ctx.createLinearGradient(0, 64, 0, 134); bg.addColorStop(0, "#C8905A"); bg.addColorStop(1, "#7A4A2A"); ctx.fillStyle = bg; ctx.fill();+ ctx.save(); poly(ctx, B); ctx.clip(); hatch(ctx, () => poly(ctx, B), rad(60), 9, "#5A3218", 1.6, .5, [-60, 60, 60, 140]); hatch(ctx, () => poly(ctx, B), rad(-60), 9, "#E8B880", 1.2, .35, [-60, 60, 60, 140]); ctx.restore();+ poly(ctx, rrect(-66, 58, 132, 14, 6)); fill(ctx, "#A8703E"); stroke(ctx, 2.6); poly(ctx, B); stroke(ctx, 3);+ // a pennant trailing from the basket+ const fw = Math.sin(t * 4); ctx.beginPath(); ctx.moveTo(-60, 70); ctx.quadraticCurveTo(-110, 78 + fw * 6, -150, 74 + fw * 10); ctx.lineTo(-104, 92 + fw * 4); ctx.closePath(); fill(ctx, "#FFF4E6"); stroke(ctx, 2);+ ctx.restore();+}+// ---------------------------------------------------------------- birds+function bird(ctx, x, y, s, flap) {+ const up = Math.sin(flap) * 14; ctx.save(); ctx.translate(x, y); ctx.scale(s, s);+ ctx.beginPath(); ctx.moveTo(-26, -up); ctx.quadraticCurveTo(-12, -8 - up * .4, 0, 0); ctx.quadraticCurveTo(12, -8 - up * .4, 26, -up); ctx.quadraticCurveTo(12, -2, 0, 5); ctx.quadraticCurveTo(-12, -2, -26, -up); ctx.closePath(); fill(ctx, "#3A1A40"); ctx.restore();+}++// ---------------------------------------------------------------- frame+const BURNS = [3.0, 9.4, 16.2, 22.6, 28.4];+const burnAt = (t) => Math.max(0, ...BURNS.map((b) => { const d = t - b; return d < 0 || d > 1.1 ? 0 : Math.min(1, d / .08) * (1 - ss(.7, 1.1, d)); }));+function frame(ctx, t, S) {+ ctx.drawImage(S.W.sky, 0, 0);+ // sun rays turning slowly+ ctx.save(); ctx.translate(1250, 600); ctx.rotate(t * TAU / 60); ctx.globalAlpha = .06; for (let i = 0; i < 14; i++) { ctx.rotate(TAU / 14); ctx.beginPath(); ctx.moveTo(0, 0); ctx.lineTo(1400, -70); ctx.lineTo(1400, 70); ctx.closePath(); ctx.fillStyle = "#FFE7B8"; ctx.fill(); } ctx.restore();+ // clouds: far ones slow, near ones faster; each wraps exactly once or twice per 30 s+ [[0, 180, 1, .75], [1, 120, 2, .55], [2, 250, 1, 1], [3, 300, 2, .8]].forEach(([i, y, laps, a]) => { const c = S.W.clouds[i], span = W + c.width, x = W - ((loop(t, DUR / laps) * span + i * 530) % span);+ ctx.save(); ctx.globalAlpha = a; ctx.drawImage(c, x, y); ctx.restore(); });+ ctx.drawImage(S.W.far, 0, 0); ctx.drawImage(S.W.mid, 0, 0); ctx.drawImage(S.W.mesas, 0, 0); ctx.drawImage(S.W.floor, 0, 0); ctx.drawImage(S.W.river, 0, 0);+ // river shimmer: short light dashes sliding downstream+ ctx.save(); const r = rng(4); for (let i = 0; i < 26; i++) { const u = (loop(t, 6) + r()) % 1, bx = lerp(940, 1060, r()), y = 875 + u * 200, x = bx + (y - 875) * (bx < 1000 ? -.9 : .9), w = 14 + r() * 26;+ ctx.globalAlpha = .5 * Math.sin(u * Math.PI); line(ctx, [[x - w / 2, y], [x + w / 2, y]], 3, "#EAF2FA"); } ctx.restore();+ // birds: a loose V crossing right to left, twice per loop+ for (let k = 0; k < 2; k++) { const u = loop(t + k * 15, 15), bx = lerp(W + 200, -300, u), by = 300 + 40 * Math.sin(u * 5);+ [[0, 0], [60, 26], [60, -22], [120, 50], [120, -44]].forEach(([dx, dy], i) => bird(ctx, bx + dx, by + dy + Math.sin(t * 3 + i) * 5, .9 - i * .05, t * 11 + i * .9)); }+ // the balloon drifts across once per loop (enters left, exits right)+ const u = loop(t, DUR), bx = lerp(-320, W + 320, u), by = 590 + 30 * Math.sin(u * TAU * 3) - 70 * Math.sin(u * Math.PI), tilt = .03 * Math.cos(u * TAU * 3);+ ctx.save(); ctx.translate(bx, by); ctx.scale(1.2, 1.2); balloon(ctx, 0, 0, tilt, t, S, burnAt(t)); ctx.restore();+ ctx.drawImage(S.W.cliffs, 0, 0);+ // a few embers of light drifting up from the canyon floor+ ctx.save(); const r2 = rng(9); for (let i = 0; i < 18; i++) { const u2 = (loop(t, 10) + r2()) % 1, x = 500 + r2() * 950 + Math.sin(u2 * 8 + i) * 20, y = 900 - u2 * 520; ctx.globalAlpha = .6 * Math.sin(u2 * Math.PI);+ const g = ctx.createRadialGradient(x, y, 0, x, y, 7); g.addColorStop(0, "#FFE7B8"); g.addColorStop(1, "rgba(255,231,184,0)"); ctx.fillStyle = g; ctx.fillRect(x - 7, y - 7, 14, 14); } ctx.restore();+ ctx.save(); ctx.font = "22px IMed"; ctx.fillStyle = "rgba(255,240,230,.75)"; ctx.textAlign = "center"; ctx.fillText("made with code · claude-animation", 960, 1052); ctx.restore();+ S.finish(ctx, Math.round(t * FPS));+}+function cues() {+ const Q = []; BURNS.forEach((b) => Q.push({ sfx: "burner", t: b - .03, vol: .5, dur: 1.1 }));+ for (let k = 0; k < 2; k++) { const t0 = 15 * k; [3.2, 3.5, 5.1, 5.3, 8.4, 11.8, 12.0].forEach((d, i) => Q.push({ sfx: "chirp", t: t0 + d, vol: .22, pitch: .9 + (i % 3) * .12, pan: .6 - d / 10 })); }+ return Q;+}+if (process.argv[2] === "cues") { fs.writeFileSync(path.join(HERE, "cues.json"), JSON.stringify(cues())); console.log("wrote cues.json"); process.exit(0); }+run({ name: "claude-balloon", W, H, fps: FPS, dur: DUR, out: path.join(HERE, "out"),+ setup() { return { W: buildWorld(), env: buildEnvelope(), finish: filmFinish(W, H, { grain: .06, flicker: 0, vignette: .12 }) }; },+ frame: (ctx, t, i, S) => frame(ctx, t, S) });diff --git a/examples/claude-balloon/make.sh b/examples/claude-balloon/make.shnew file mode 100755index 0000000..a1c896d--- /dev/null+++ b/examples/claude-balloon/make.sh@@ -0,0 +1,10 @@+#!/bin/bash+# make.sh — the 30 s seamless loop: render, ambient bed (4 bars of 7.5 s so the audio loops too), burner + birds+set -e+cd "$(dirname "$0")"+SK=../../plugins/claude-animation/skills/claude-animation+node film.mjs verify+node film.mjs render+node film.mjs cues+node $SK/scripts/ambient.mjs out/ambient.wav --dur 30 --bar 7.5 --wind .25+node $SK/scripts/sound.mjs cues.json out/claude-balloon.mp4 out/claude-balloon-final.mp4 --bed out/ambient.wav --bed-vol .7 --lufs -16diff --git a/plugins/claude-animation/skills/claude-animation/SKILL.md b/plugins/claude-animation/skills/claude-animation/SKILL.mdindex 2bea25c..f670ff7 100644--- a/plugins/claude-animation/skills/claude-animation/SKILL.md+++ b/plugins/claude-animation/skills/claude-animation/SKILL.md@@ -20,6 +20,7 @@ recap and a set of storybook insect films — and took a render to find.| **Make it more detailed** (materials, textures, characters) | `references/detail.md` — the detail bible. Read it before drawing any surface || Draw / pose / walk the ant, or build a new creature rig | `references/characters.md`, `lib/rigs/ant.mjs` || A colony: leaves, brood, fungus, roots, a nest cross-section with walkable tunnels | `lib/colony.mjs` |+| **Faceted low-poly poster art** (flat vector landscapes, ambient seamless loops) | `lib/lowpoly.mjs`, `references/styles.md` § 5, `examples/claude-balloon/` || **Action / video-game feel**: jumps, punches, hit-stop, shake, sparks, combo, boss bar | `lib/fx.mjs`, `lib/rigs/critter.mjs`, `lib/rigs/bug.mjs`, `examples/claude-game/` || People (bean body, stick limbs, watercolour) | `lib/rigs/bean.mjs` || Timing, acting, cuts, camera, transitions | `references/motion.md` |@@ -38,6 +39,7 @@ recap and a set of storybook insect films — and took a render to find.| `nature.mjs` | `sprout melonLeaf tendril vine blossom bee drop` || `rigs/ant.mjs` | `ant(ctx, x, groundY, s, pose)` — the detailed ant (`pose.look` = ink / fill / tex layers for build-up reveals); `antGuides()` blue construction lines; `seed()` || `colony.mjs` | `leaf leafPiece egg larva cocoon seedGrain fungus roots nestCanvas` (chambers + tunnels baked into soil, returns `pathOf` walkers) |+| `lowpoly.mjs` | `facetMass` (bake a mass into lit triangles from a ramp, with dome / fade / haze), `ridge`, `skyGradient`, `facetCloud`, `RAMPS` (canyon, dusk, mesa, forest, ice, water, balloon, cloud) || `fx.mjs` | `timeWarp` (hit-stop: game time freezes on contact, effects keep running), `shake`, `burstParticles` (spark / debris / dust / confetti / ember), `landDust`, `ring`, `flashAlpha`, `comicText`, `floatText`, `afterimages`, `starburst`, `heart` || `rigs/critter.mjs` | a blocky action hero: run, jump, flip, squash & stretch, punch, kick, hurt, charge aura, expressions || `rigs/bug.mjs` | a beetle enemy (and boss with horns): scuttle, jaw, flash, squash, spin |@@ -86,7 +88,8 @@ node $SK/scripts/music.mjs bed.wav --dur 5 --end 4.4node $SK/scripts/sound.mjs cues.json out/template.mp4 out/final.mp4 --bed bed.wav```-Worked films in the repo: `examples/claude-game/` — a 30 s video-game short (platforming, bugs, a boss fight+Worked films in the repo: `examples/claude-balloon/` — a 30 s seamless ambient loop in faceted low-poly+(every motion periodic in 30 s, audio in 4 × 7.5 s bars so it loops too); `examples/claude-game/` — a 30 s video-game short (platforming, bugs, a boss fightwith hit-stop, combo, special, K.O., chiptune from `scripts/chiptune.mjs`); and `examples/ant-colony/` — 32 s, 16:9: a sketch → ink → colour → polish build-up,a leafcutter cutting and carrying a leaf through a meadow, a dive into a nest cross-section (fungus garden,nursery, queen, stores, tunnels full of traffic), 240 sound cues from the timeline; renders in ~27 s.diff --git a/plugins/claude-animation/skills/claude-animation/lib/lowpoly.mjs b/plugins/claude-animation/skills/claude-animation/lib/lowpoly.mjsnew file mode 100644index 0000000..808bb10--- /dev/null+++ b/plugins/claude-animation/skills/claude-animation/lib/lowpoly.mjs@@ -0,0 +1,75 @@+// lowpoly.mjs — faceted flat-vector illustration (the "poster landscape" look): every mass is cut into+// triangles, each triangle lit as a flat plane from one light direction and coloured from a gradient ramp.+// No outlines. Depth comes from layers that fade toward the sky colour (atmospheric perspective).+//+// const rock = facetMass(W, H, polygon, { ramp: RAMPS.canyon, light: [-.7, -.5, .5], cell: 38, dome: [cx, halfWidth] })+// ctx.drawImage(rock, 0, 0) // bake once in setup(), blit every frame+//+// ramp: colours from shadow to lit. The shading value is (normal · light), bent by `contrast`, darkened+// toward the bottom by `bottomDark`, and pulled toward `haze` by `fade` for distant layers.+import { createCanvas, clamp, lerp, hash } from "./core.mjs";++export const RAMPS = {+ canyon: ["#2A0F2E", "#5A1840", "#9C2A4A", "#D8452F", "#F2702A", "#FF9A3C"],+ dusk: ["#2B1B45", "#4B2A63", "#7A3A78", "#B14E7A", "#E07A6E", "#F7B18A"],+ mesa: ["#3A1A2A", "#6B2A3A", "#A8434A", "#D46A4A", "#EE9A5E", "#F9C88A"],+ forest: ["#0F2A2A", "#18423A", "#24604A", "#3C8A5A", "#6BB06A", "#A8D48A"],+ ice: ["#1E2A4A", "#2E4A7A", "#4A76A8", "#7AA8D0", "#B8D8EC", "#EEF6FA"],+ water: ["#1A2450", "#2A3C78", "#3E5E9C", "#5E86BC", "#9CB8DA", "#DCE8F4"],+ balloon: ["#6A2A1E", "#A8452E", "#D2633E", "#E8835A", "#F4A97E", "#FFD0B0"],+ cloud: ["#B88A9C", "#D2A6B0", "#E8C4C4", "#F6DCD4", "#FFEDE4", "#FFF8F2"],+};+const hexRgb = (h) => { const n = parseInt(h.slice(1), 16); return [n >> 16, (n >> 8) & 255, n & 255]; };+export function rampColor(ramp, v) { const k = clamp(v) * (ramp.length - 1), i = Math.min(ramp.length - 2, Math.floor(k)), f = k - i, a = hexRgb(ramp[i]), b = hexRgb(ramp[i + 1]); return a.map((c, j) => Math.round(lerp(c, b[j], f))); }+const rgb = (c) => `rgb(${c[0]},${c[1]},${c[2]})`;+const mix = (a, b, k) => a.map((v, i) => Math.round(lerp(v, b[i], k)));++// 2-D value noise, fractal+function vnoise(x, y, s) { const xi = Math.floor(x), yi = Math.floor(y), xf = x - xi, yf = y - yi, u = xf * xf * (3 - 2 * xf), v = yf * yf * (3 - 2 * yf);+ const h = (a, b) => hash(a * 157.31 + b * 311.7 + s * 17.17); return lerp(lerp(h(xi, yi), h(xi + 1, yi), u), lerp(h(xi, yi + 1), h(xi + 1, yi + 1), u), v); }+export const fbm = (x, y, s = 1) => (vnoise(x, y, s) * .6 + vnoise(x * 2.1, y * 2.1, s + 3) * .3 + vnoise(x * 4.3, y * 4.3, s + 7) * .1);++// Bake a faceted mass into its own canvas (size W×H, polygon in that canvas's coordinates).+// opts: ramp, light [x,y,z] (x<0 = lit from the left), cell (facet size px), jitter (0..0.5), zAmp (relief),+// freq (noise scale), dome [cx, halfWidth] (a rounded pillar), ridge (bias: brighter near the top),+// bottomDark (0..1), contrast, fade (0..1 toward haze), haze (hex), seed+export function facetMass(W, H, poly, o = {}) {+ const { ramp = RAMPS.canyon, light = [-.7, -.55, .45], cell = 56, jitter = .22, zAmp = 55, freq = .004, dome = null, ridge = .25, bottomDark = .45, contrast = 1.15, fade = 0, haze = "#F4E6D8", seed = 1 } = o;+ const c = createCanvas(W, H), x = c.getContext("2d");+ let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity; for (const [px, py] of poly) { x0 = Math.min(x0, px); y0 = Math.min(y0, py); x1 = Math.max(x1, px); y1 = Math.max(y1, py); }+ x0 -= cell; y0 -= cell; x1 += cell; y1 += cell;+ const nx = Math.ceil((x1 - x0) / cell) + 1, ny = Math.ceil((y1 - y0) / cell) + 1, P = [];+ const L = Math.hypot(...light), lx = light[0] / L, ly = light[1] / L, lz = light[2] / L, hz = hexRgb(haze);+ const z = (px, py) => { let v = fbm(px * freq, py * freq, seed) * zAmp; if (dome) { const d = clamp(1 - Math.pow((px - dome[0]) / dome[1], 2), 0, 1); v += Math.sqrt(d) * dome[1] * .9; } return v; };+ for (let j = 0; j < ny; j++) for (let i = 0; i < nx; i++) { const jx = (hash(i * 7.1 + j * 13.3 + seed) - .5) * 2 * jitter * cell, jy = (hash(i * 3.7 + j * 5.9 + seed * 2) - .5) * 2 * jitter * cell;+ const px = x0 + i * cell + (j % 2 ? cell / 2 : 0) + jx, py = y0 + j * cell + jy; P.push([px, py, z(px, py)]); }+ x.save(); x.beginPath(); poly.forEach(([px, py], i) => i ? x.lineTo(px, py) : x.moveTo(px, py)); x.closePath(); x.clip();+ const tri = (a, b, d) => { const ux = b[0] - a[0], uy = b[1] - a[1], uz = b[2] - a[2], vx = d[0] - a[0], vy = d[1] - a[1], vz = d[2] - a[2];+ let Nx = uy * vz - uz * vy, Ny = uz * vx - ux * vz, Nz = ux * vy - uy * vx; if (Nz < 0) { Nx = -Nx; Ny = -Ny; Nz = -Nz; } const n = Math.hypot(Nx, Ny, Nz) || 1;+ let v = (Nx * lx + Ny * ly + Nz * lz) / n; v = clamp((v - .1) * contrast + .45);+ const cy = (a[1] + b[1] + d[1]) / 3, depth = clamp((cy - y0) / (y1 - y0)); v = clamp(v + ridge * (1 - depth) * .5 - bottomDark * depth * .6);+ let col = rampColor(ramp, v); if (fade) col = mix(col, hz, fade);+ x.beginPath(); x.moveTo(a[0], a[1]); x.lineTo(b[0], b[1]); x.lineTo(d[0], d[1]); x.closePath(); x.fillStyle = rgb(col); x.fill(); x.strokeStyle = rgb(col); x.lineWidth = 1.2; x.stroke(); };+ for (let j = 0; j < ny - 1; j++) for (let i = 0; i < nx - 1; i++) { const a = P[j * nx + i], b = P[j * nx + i + 1], d = P[(j + 1) * nx + i], e = P[(j + 1) * nx + i + 1];+ if ((i + j) % 2) { tri(a, b, e); tri(a, e, d); } else { tri(a, b, d); tri(b, e, d); } }+ x.restore(); return c;+}+// ridge line helper: a mountain-range outline from control heights, closed down to `base`+export function ridge(x0, x1, base, heights, seed = 1, rough = 18) {+ const P = [[x0, base]], n = heights.length; for (let i = 0; i <= 60; i++) { const u = i / 60, k = u * (n - 1), a = Math.floor(k), f = k - a, h = lerp(heights[a], heights[Math.min(n - 1, a + 1)], f * f * (3 - 2 * f));+ P.push([lerp(x0, x1, u), h + (hash(i * 3.3 + seed) - .5) * rough]); } P.push([x1, base]); return P;+}+// a smooth sky: vertical stops [[0, "#hex"], [1, "#hex"]] plus a sun glow+export function skyGradient(ctx, W, H, stops, sun = null) {+ const g = ctx.createLinearGradient(0, 0, 0, H); for (const [o, c] of stops) g.addColorStop(o, c); ctx.fillStyle = g; ctx.fillRect(0, 0, W, H);+ if (sun) { const [sx, sy, r, col] = sun, gl = ctx.createRadialGradient(sx, sy, r * .6, sx, sy, r * 5); gl.addColorStop(0, col + "AA"); gl.addColorStop(1, col + "00"); ctx.fillStyle = gl; ctx.fillRect(0, 0, W, H);+ ctx.beginPath(); ctx.arc(sx, sy, r, 0, Math.PI * 2); ctx.fillStyle = col; ctx.fill(); }+}+// a faceted cloud baked to its own canvas+export function facetCloud(w, h, seed = 1, ramp = RAMPS.cloud) {+ // a union of 4-5 domes on a flat base, sampled into one outline+ const bumps = Array.from({ length: 5 }, (_, i) => [w * (.14 + i * .18 + (hash(i + seed) - .5) * .06), h * (.28 + .5 * hash(i * 3 + seed)) * (i === 0 || i === 4 ? .6 : 1), w * (.13 + .06 * hash(i * 5 + seed))]);+ const top = (x) => { let y = h; for (const [cx, r, rw] of bumps) { const d = (x - cx) / rw; if (Math.abs(d) < 1) y = Math.min(y, h - r * Math.sqrt(1 - d * d) - h * .12); } return y; };+ const P = [[w * .04, h]]; for (let i = 0; i <= 60; i++) { const x = w * (.04 + .92 * i / 60); P.push([x, top(x)]); } P.push([w * .96, h]);+ return facetMass(w, h + 4, P, { ramp, light: [-.4, -.8, .5], cell: 34, zAmp: 20, dome: [w / 2, w * .46], bottomDark: .05, ridge: .6, contrast: .7, seed });+}diff --git a/plugins/claude-animation/skills/claude-animation/references/styles.md b/plugins/claude-animation/skills/claude-animation/references/styles.mdindex 7a12f42..ca10a40 100644--- a/plugins/claude-animation/skills/claude-animation/references/styles.md+++ b/plugins/claude-animation/skills/claude-animation/references/styles.md@@ -42,6 +42,22 @@ layer above a person matte, back half below it. Flat ring (vertical radius ≈ 1(~0.34 rad/s), land on the headline facing camera and hold ~2 s before turning. Temporal supersampling(6 samples) for motion blur while it flies in or out.+## 5. Faceted low-poly poster (ambient loops)++The "website footer / poster landscape" look: flat vector, no outlines on the world, every mass cut into+lit triangles, depth from layers that fade into the haze. Calm, art-first, made to loop.+- `facetMass(W, H, polygon, { ramp, light, cell, dome, fade, haze })`, baked once per layer in `setup()`.+ Big cells (50–75 px) with low jitter (~0.22); small cells and high jitter read as noise, not facets.+- Layers back to front: sky gradient + sun glow → far ridge (fade .55) → mid ridge (.3) → mesas (.18) →+ floor + water → the moving subject → foreground framing masses (no fade, darkest shadows).+- Pillars and cliffs get `dome: [centreX, halfWidth]` so the lit side and the shadow side split like a+ column; ramps run plum → magenta → orange (canyon) or navy → blue → pale (ice).+- The character is the only outlined thing: it reads as "drawn" against a painted world.+- Loops: every motion periodic in the loop length (clouds wrap exactly 1–2 times, birds every half-loop,+ the subject crosses once, rotations by a symmetric multiple). Check frame 0 against the last frame.+- Sound: `scripts/ambient.mjs` (pads, sparse bells, wind) with bars that divide the loop, plus a few+ diegetic sounds (`burner`, `chirp`). No music hook.+## Matching a new referenceMake a swatch sheet before the film: paper, ink line at three weights, each material's three layers, onediff --git a/plugins/claude-animation/skills/claude-animation/scripts/ambient.mjs b/plugins/claude-animation/skills/claude-animation/scripts/ambient.mjsnew file mode 100644index 0000000..4fc9ad1--- /dev/null+++ b/plugins/claude-animation/skills/claude-animation/scripts/ambient.mjs@@ -0,0 +1,24 @@+// ambient.mjs — an original ambient bed synthesised in code: slow detuned pads (Dmaj9 → Bm7 → Gmaj7 → A6sus),+// a sparse pentatonic bell line, and filtered wind. For loops and "art" pieces: no drums, no hook.+// node ambient.mjs out.wav --dur 30 --bar 7.5 --wind .25+// The last bar resolves back to the first chord so a 30 s file with --bar 7.5 loops cleanly.+import fs from "node:fs";+const A = process.argv, opt = (k, d) => A.includes(k) ? A[A.indexOf(k) + 1] : d;+const OUT = A[2] && !A[2].startsWith("--") ? A[2] : "ambient.wav";+const SR = 44100, DUR = parseFloat(opt("--dur", "30")), BAR = parseFloat(opt("--bar", "7.5")), WIND = parseFloat(opt("--wind", ".25"));+const N = Math.floor(SR * DUR), L = new Float32Array(N), R = new Float32Array(N), hz = (m) => 440 * Math.pow(2, (m - 69) / 12);+const CH = [[50, 57, 61, 64, 66], [47, 54, 57, 62, 66], [43, 50, 54, 59, 62], [45, 52, 57, 59, 64]];+for (let b = 0; b * BAR < DUR; b++) { const t0 = b * BAR, c = CH[b % 4];+ c.forEach((m, k) => { const f = hz(m), s0 = Math.round(t0 * SR), n = Math.round((BAR + 2) * SR), det = [1, 1.004, .996];+ for (let i = 0; i < n && s0 + i < N; i++) { const t = i / SR, env = Math.min(1, t / 2.2) * Math.min(1, (BAR + 2 - t) / 2.5); let v = 0;+ for (const d of det) v += Math.sin(2 * Math.PI * f * d * t + k) + .3 * Math.sin(4 * Math.PI * f * d * t);+ v *= env * (k === 0 ? .06 : .035); const p = (k - 2) * .15; L[s0 + i] += v * (1 - p); R[s0 + i] += v * (1 + p); } }); }+const PENT = [74, 76, 78, 81, 83, 86, 88]; let seed = 5; const rnd = () => (seed = (seed * 16807) % 2147483647) / 2147483647;+for (let t = 1.2; t < DUR - 1.5; t += 1.3 + rnd() * 1.6) { const m = PENT[Math.floor(rnd() * PENT.length)], f = hz(m), s0 = Math.round(t * SR), n = Math.round(2.4 * SR), pan = rnd() - .5;+ for (let i = 0; i < n && s0 + i < N; i++) { const tt = i / SR, v = (Math.sin(2 * Math.PI * f * tt) + .35 * Math.sin(2 * Math.PI * f * 2.76 * tt) * Math.exp(-tt * 5)) * Math.exp(-tt * 1.8) * Math.min(1, i / 80) * .07; L[s0 + i] += v * (1 - pan); R[s0 + i] += v * (1 + pan); } }+let lp = 0, lp2 = 0, ns = 9; for (let i = 0; i < N; i++) { ns = (ns * 1103515245 + 12345) & 0x7fffffff; const w = ns / 0x7fffffff * 2 - 1, t = i / SR, cut = .012 + .01 * (1 + Math.sin(t * .7) * Math.sin(t * .23));+ lp += cut * (w - lp); lp2 += cut * (lp - lp2); const v = lp2 * WIND * 4 * (.6 + .4 * Math.sin(t * .5)); L[i] += v; R[i] += v * .9; }+let pk = 0; for (let i = 0; i < N; i++) pk = Math.max(pk, Math.abs(L[i]), Math.abs(R[i])); const g = .8 / (pk || 1), buf = Buffer.alloc(44 + N * 4);+buf.write("RIFF", 0); buf.writeUInt32LE(36 + N * 4, 4); buf.write("WAVEfmt ", 8); buf.writeUInt32LE(16, 16); buf.writeUInt16LE(1, 20); buf.writeUInt16LE(2, 22); buf.writeUInt32LE(SR, 24); buf.writeUInt32LE(SR * 4, 28); buf.writeUInt16LE(4, 32); buf.writeUInt16LE(16, 34); buf.write("data", 36); buf.writeUInt32LE(N * 4, 40);+for (let i = 0; i < N; i++) { buf.writeInt16LE(Math.round(Math.tanh(L[i] * g) * 32767), 44 + i * 4); buf.writeInt16LE(Math.round(Math.tanh(R[i] * g) * 32767), 46 + i * 4); }+fs.writeFileSync(OUT, buf); console.log("ambient", DUR, "s");diff --git a/plugins/claude-animation/skills/claude-animation/scripts/sound.mjs b/plugins/claude-animation/skills/claude-animation/scripts/sound.mjsindex 2b3fb7d..342b67c 100644--- a/plugins/claude-animation/skills/claude-animation/scripts/sound.mjs+++ b/plugins/claude-animation/skills/claude-animation/scripts/sound.mjs@@ -5,7 +5,7 @@//// cues.json: [{ "sfx": "pop", "t": 0.94, "vol": .5 }, { "sfx": "whoosh", "t": 1.08, "dur": .5 }, ...]// sfx: pop | whoosh | whip | tick | thump | crack | sparkle | buzz | scratch | drip | boing | riser |-// splash | click | step | fall | chime (optional per cue: vol, dur, pan -1..1, pitch multiplier)+// splash | click | step | fall | chime | chirp | burner (optional per cue: vol, dur, pan -1..1, pitch multiplier)// Place a cue ~0.03 s BEFORE its visual: sound that lands late reads as broken, early reads as synced.// The mix gets a two-pass loudnorm (default -16 LUFS), then a 4x-oversampled limiter at -3.1 dBFS (AAC adds ~1.5 dB of inter-sample overshoot) so dense// hit-heavy mixes can't overshoot (a game mix hit +1.6 dBTP without it), and is muxed onto the picture.@@ -35,6 +35,8 @@ export const SFX = {step: (d = .04) => tone(d, (t, u) => (Math.sin(2 * Math.PI * 900 * t) * .6 + R() * .3) * Math.exp(-t * 140) * .5),fall: (d = .45) => tone(d, (t, u) => Math.sin(2 * Math.PI * (1800 - 1300 * u) * t) * Math.min(1, u * 8) * (1 - u) * .35),chime: (d = 1.2) => tone(d, (t, u) => [1047, 1319, 1568, 2093].reduce((s, f, k) => s + (t > k * .07 ? Math.sin(2 * Math.PI * f * t) * Math.exp(-(t - k * .07) * 3.5) : 0), 0) * .2),+ chirp: (d = .18) => tone(d, (t, u) => Math.sin(2 * Math.PI * (2600 + 1800 * Math.sin(u * Math.PI)) * t) * Math.sin(u * Math.PI) * (u < .45 || u > .55 ? 1 : .2) * .35),+ burner: (d = 1.0) => { const a = bandNoise(d, 180, 900, (u) => .5 + .5 * Math.sin(u * Math.PI)); return tone(d, (t, u) => a[Math.floor(u * (a.length - 1))] * 1.4 * Math.min(1, u * 8) * (1 - u)); },buzz: (d = .6) => { let ph = 0; return tone(d, (t, u) => { ph += (215 + 18 * Math.sin(t * 38)) / SR; return (2 * (ph % 1) - 1) * .3 * Math.min(1, t / .08, (d - t) / .2) * (.7 + .3 * Math.sin(t * 90)); }); },};function readWav(file) { // 16-bit PCM wav -> mono float at its own rate (resampled nearest to SR)