Skip to content

Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.

0.3.0: stills, loops and stickers as first-class, nine-style gallery

Alex Greenshpun8a66cfd4890b
diff --git a/README.md b/README.md
index 40b4fe1..fea4356 100644
--- a/README.md
+++ b/README.md
@@ -1,81 +1,120 @@
<p align="center">
- <img src="assets/banner.gif" width="100%" alt="anidoodle: an artist's table of code-drawn doodles, with the name writing itself in calligraphy"><br>
+ <img src="assets/banner.gif" width="100%" alt="anidoodle: an artist's table of code-drawn doodles, with the name writing itself in calligraphy">
</p>
-# anidoodle
+<h1 align="center">anidoodle</h1>
-**A film, drawn entirely in code. Every pixel is painted by a function, every note is synthesized, and the same seed draws the same picture forever.**
+<p align="center"><strong>Hand-drawn art, written as code.</strong></p>
<p align="center">
- <img src="assets/alive.gif" width="480" alt="A clockwork butterfly comes to life in watercolour and flits between ranunculus"><br>
- <em>This clockwork butterfly was written, not filmed. It drafts itself as a blueprint, wakes in watercolour, and flies off leaving the plate in the grass.</em>
+ Illustrations, animations and short films in nine hand-drawn styles.<br>
+ Every mark is a function and every note is arithmetic, so the same source<br>
+ redraws the same picture on every machine, at every size, for good.
</p>
-<p align="center"><strong>▶ <a href="assets/mechanical-lepidoptera.mp4">Watch the full 47-second film</a></strong> · 1080&times;1080, with an original score, every frame and sample generated in code</p>
+<p align="center">
+ <a href="https://github.com/alexgreensh/anidoodle/releases"><img src="https://img.shields.io/github/v/release/alexgreensh/anidoodle?color=c2410c&label=release" alt="Latest release"></a>
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-3b6ea5" alt="Apache 2.0"></a>
+ <img src="https://img.shields.io/badge/made%20of-pure%20code-6b8e23" alt="Made of pure code">
+ <img src="https://img.shields.io/badge/every%20render-identical-7c5c99" alt="Every render identical">
+</p>
-## The idea
+<p align="center">
+ <a href="#nine-styles-to-choose-from">Styles</a> ·
+ <a href="#what-you-can-make">What you can make</a> ·
+ <a href="#what-it-packs">What it packs</a> ·
+ <a href="#it-draws-then-it-moves">Motion</a> ·
+ <a href="#get-started">Get started</a>
+</p>
-anidoodle hands you the source of a picture: a small program that draws it. Change a seed and you get a sister image. Nudge a number and the wing lifts higher. Commit it and your art lives in git, beside your code, rebuilding identically on any machine, at any size, this year and next.
+## Nine styles to choose from
-One pure function paints each frame. A single call is a finished illustration. A run of them is a film. The same guarantees hold for both.
+<p align="center">
+ <img src="assets/styles.jpg" width="100%" alt="Nine illustrations, each in its own style: pencil and watercolour ranunculus, marker comic koi, ballpoint pocket watch, crayon hot-air balloon, ink and line-wash wren, chalkboard moon phases, cut-paper fox, risograph lighthouse, and a single-line engraved moon">
+</p>
-## What it packs
+Each style is its own way of making a mark: the taper of a nib, the bleed of a wash, the scumble of chalk on slate, the torn edge of cut paper, the halftone of a risograph drum, one engraved line spiralling out to become a moon. The subject changes shape in each hand, the way it would for nine different illustrators. Pick one for your brand and every picture after it arrives in the same hand. Every plate above, and the contact sheet itself, is drawn by code in this repo.
-The engine is the easy half. The craft is the part anidoodle carries for you, five lessons, each one earned by getting a film wrong first and written down so you start where the last project ended:
+## What you can make
-- **Story** decides everything. One transformation, one payoff, one visual token that returns, so a film has a spine and the medium shifts only when the story changes state. → [`references/storytelling.md`](references/storytelling.md)
-- **Realism** comes from naming it. The anatomy, the view, and the reference you opened, so a butterfly reads as a creature with a body and veins. → [`references/realism-and-craft.md`](references/realism-and-craft.md)
-- **Music** follows a recipe. Major key, plucked, a phrase that asks a question and resolves home, warm and sure. → [`references/music-recipe.md`](references/music-recipe.md)
-- **Determinism** is the guarantee. Pure functions and a seeded random, so anyone who has the source rebuilds the exact same film, forever. → [`references/determinism-and-contract.md`](references/determinism-and-contract.md)
-- **Method** keeps you fast. Prove the look on one still, then build straight through to the end, and spend approval where being wrong is expensive. → [`references/working-method.md`](references/working-method.md)
+| For | You get |
+|---|---|
+| **Your website** | A hero illustration, spot art for each feature, empty states and a 404, all in one hand. Transparent PNGs at any size from one source, so retina and print come free. |
+| **Explainers and reports** | How-it-works diagrams, cutaways and animated infographics, labelled in drafted lettering. Chalkboard, blueprint and ballpoint suit the serious ones. |
+| **Your brand** | A logo that draws itself on, a title sequence, a social card template that stays on brand for every post. |
+| **Social and chat** | Endless loops, GIFs and transparent animated stickers, sized for the feed. |
+| **Decks and docs** | A family of section illustrations from one program. A new seed gives a sister image in the same style. |
+| **Stories** | Storyboards and animatics that grow into a finished short film with an original score. |
-## It draws stills too
+Ask in plain words, *"a risograph lighthouse for our careers page, 1600×900"* or *"a chalkboard explainer of how our pricing tiers stack up"*, and anidoodle routes it to the right workflow and style recipe, asking only for what the request leaves open.
-A single call is a complete illustration. Render your landing-page hero at full size, a thumbnail, and a social card from the one source, on brand, at any resolution you ask for.
+## What it packs
-<p align="center">
- <img src="assets/act1.gif" width="460" alt="A cyanotype blueprint plate drawing itself, line by line"><br>
- <em>The marks are <strong>made</strong>, in the order a hand would make them.</em>
-</p>
+The engine is the easy half. The craft is the part anidoodle carries for you, six lessons, each one earned by getting a piece wrong first and written down so you start where the last project ended:
-**Reach for it when you want:** website and product art, hero images and empty states that stay on brand at every size; editorial diagrams and cutaways that move to show how a thing works; title sequences, animated logos, and brand stories that render the same in every pipeline; storyboards and animatics, sketched fast and grown into the finished film; and generative series, where one program yields a whole family of images from different seeds.
+- **Story** gives every piece a point. One idea and one focal subject for a still; one transformation, one payoff and one returning token for a film. → [`storytelling.md`](references/storytelling.md)
+- **Realism** comes from naming it. The anatomy, the view and the reference you opened, so a butterfly reads as a creature with a body and veins. → [`realism-and-craft.md`](references/realism-and-craft.md)
+- **Style** lives in the mark. Nine full recipes, a guide for picking one per job, and the steps for inventing your own. → [`styles.md`](references/styles.md)
+- **Music** follows a recipe. Major key, plucked, a phrase that asks a question and resolves home, warm and sure. → [`music-recipe.md`](references/music-recipe.md)
+- **Determinism** is the guarantee. Pure functions and a seeded random, so anyone with the source rebuilds the exact same piece. → [`determinism-and-contract.md`](references/determinism-and-contract.md)
+- **Method** keeps you fast. Prove the look on one still, build straight through, and spend approval where being wrong is expensive. → [`working-method.md`](references/working-method.md)
-## Many styles, one engine
+Every format ships from the same source: PNG, MP4 with its score, GIF, WebM and animated PNG with transparency, and one self-contained HTML file. → [`formats.md`](references/formats.md)
-<p align="center">
- <img src="assets/styles.png" width="900" alt="Eight subjects, each drawn in a different illustration style, all in code"><br>
- <em>Eight subjects, eight hands. Pick the style your art wants, and the engine draws it.</em>
-</p>
+## It draws, then it moves
+
+<table>
+ <tr>
+ <td width="50%" align="center"><img src="assets/act1.gif" alt="A cyanotype blueprint plate drawing itself, line by line"></td>
+ <td width="50%" align="center"><img src="assets/alive.gif" alt="A clockwork butterfly comes to life in watercolour and flits between ranunculus"></td>
+ </tr>
+ <tr>
+ <td align="center"><sub>Marks are <strong>made</strong>, in the order a hand would make them.</sub></td>
+ <td align="center"><sub>The blueprint wakes in watercolour and flies off into its meadow.</sub></td>
+ </tr>
+</table>
-Every style is its own way of making a mark: the taper of a nib, the bleed of a wash, the scumble of chalk on slate, the torn edge of cut paper, the halftone of a risograph drum. One engine drives them all, so eight looks read as eight different artists, and reaching a ninth is a page of code.
+<p align="center"><strong>▶ <a href="assets/mechanical-lepidoptera.mp4">Watch the full 47-second film</a></strong> · 1080×1080 with an original score, every frame and sample generated in code</p>
+
+One pure function paints each frame, so a finished illustration is that function called once, a sticker is the same function on a loop, and a film is it with a story and a score. The same guarantees hold for all three.
## Pay once, draw forever
-A picture model spends tokens and compute on every frame of every render, and it never draws the same thing twice. Code spends them once. The 47-second film is a single program: written one time, it renders all 1,410 frames and a full stereo score, at any size, on any machine, free every time it runs. That is about sixty tokens of code per frame on the first pass, and zero on every pass after. A single still is a few hundred lines. A whole family of images is just new seeds.
+A picture model spends tokens and compute on every frame of every render, and it draws something new each time. Code spends them once. The 47-second film is a single program: written one time, it renders all 1,410 frames and a full stereo score, at any size, on any machine, free every time it runs. That works out to about sixty tokens of code per frame on the first pass, and zero on every pass after. A still is a few hundred lines. A whole family of images is a list of seeds.
+
+## Get started
-## Try it
+anidoodle is an agent skill: one folder with a `SKILL.md` at the top. For Claude Code, clone it into your skills folder:
```bash
-node engine/tools/scaffold.mjs ~/my-film --film myFilm # a new project with a starter film
-cd ~/my-film && npm install
+git clone https://github.com/alexgreensh/anidoodle ~/.claude/skills/anidoodle
+```
+
+Then ask for what you want: *"draw a pencil & watercolour pear for our recipes page"*. To drive the engine yourself:
-node tools/still.mjs myFilm --out out/look.png # a single finished illustration
-node tools/emit.mjs myFilm --out out/my-film.html # a self-contained player, one file
-node tools/gate.mjs myFilm --mp4 out/my-film.mp4 # determinism, contract and dead-air in one pass
-node tools/render.mjs myFilm # the MP4
+```bash
+node ~/.claude/skills/anidoodle/engine/tools/scaffold.mjs ~/art --still hero --film intro
+cd ~/art && npm install && npx playwright-core install chromium
+
+node tools/still.mjs hero --out out/hero.png --scale 2 # a finished illustration, print size
+node tools/render.mjs intro --out out/intro.gif # a loop; also .mp4 with score, .webm with alpha
+node tools/emit.mjs intro --out out/intro.html # the whole piece as one offline file
+node tools/gate.mjs hero # determinism, contract and dead air in one pass
```
-`emit` writes one HTML file, around 100 KB, that plays the whole film with sound on a double-click, offline. It carries the recipe and draws the whole thing again from scratch every time you open it. Attach it to an email and you have shipped a studio.
+Node 20 or newer. Stills need only the browser above; anything that moves also uses `ffmpeg`.
+
+`emit` writes one HTML file, around 100 KB, that plays the piece with sound on a double-click, offline. It carries the recipe and draws everything again from scratch every time you open it. Attach it to an email and you have shipped a studio.
-Four backends share one art core, and the core stays blissfully unaware of which is drawing it: `playwright`, `html-player`, `remotion`, `hyperframes`.
+Four backends share one art core, and the core stays blissfully unaware of which one is drawing: `playwright`, `html-player`, `remotion`, `hyperframes`.
## The example film
-`example/` holds **Mechanical Lepidoptera**: 1,410 frames, 47 seconds, a clockwork butterfly that drafts itself, comes alive in watercolour, and leaves its blueprint in the grass. It is the whole engine in one piece: control points placed by hand over real anatomy, a cache key that names every input a pixel depends on, a score built from the recipe, and one unbroken move from built to alive. Open it, change a number, and watch what moves.
+`example/` holds **Mechanical Lepidoptera**: 1,410 frames, 47 seconds, a clockwork butterfly that drafts itself, comes alive in watercolour, and leaves its blueprint in the grass. It is the whole engine in one piece: control points placed by hand over real anatomy, a cache key that names every input a pixel depends on, a score built from the recipe, and one unbroken move from built to alive. The nine style plates sit beside the engine in `engine/src/canvas-core/`, each with its recipe written at the top. Open any of them, change a number, and watch what moves.
## Honest by design
-Sound and motion earn their claims. Every statement about the score or the movement carries a measurement or a human's eye behind it, and a green checkmark counts once it has been re-run. That discipline is why the same film comes back byte for byte, every time, on every machine.
+Sound and motion earn their claims. Every statement about the score or the movement carries a measurement or a human's eye behind it, and a green checkmark counts once it has been re-run. That discipline is why the same piece comes back byte for byte, every time, on every machine.
---
diff --git a/SKILL.md b/SKILL.md
index 434dbf9..5812577 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -1,6 +1,6 @@
---
name: anidoodle
-description: Draw, animate and illustrate entirely in code, no image or audio assets, deterministic on any backend. Use for a code-drawn film or animation, an illustration or still, a storyboard, or sketching a visual idea.
+description: Code-drawn illustrations, animations and scored films in nine hand-drawn styles, zero assets, identical every render. Use for hero art, explainers, stickers, loops, animated logos, storyboards or a short film.
metadata:
created_by: Alex Greenshpun (10x Company)
license: Apache-2.0
@@ -8,51 +8,73 @@ metadata:
# anidoodle
-A 30 to 90 second film where one pure function `renderFrame(film, ctx, frame, env)` draws every
-frame and a second pure function writes every audio sample. One generated HTML page IS the film;
-adapters turn it into an MP4. Nothing downloaded, nothing sampled, nothing random, so anyone can
-rebuild it bit for bit from source.
+Pictures, loops and films drawn entirely in code. One pure function, `renderFrame(film, ctx,
+frame, env)`, paints every frame; a second pure function writes every audio sample. A still is
+that function called once. Nothing downloaded, nothing sampled, nothing random, so the source
+rebuilds the same pixels on any machine, at any size, for as long as the file exists.
-That is the easy half. The films that get thrown away are never thrown away for engineering
-reasons. They are thrown away because they had no story, because the subject did not look real,
-because the music sounded like a ghost crying, and because the client's patience was spent
-approving stills of a film that did not yet exist.
+The engine is the easy half. Pieces get thrown away because they had no point, because the
+subject looked like a road-sign icon of itself, because the style was a palette swap, because the
+music sounded like a ghost crying, or because the client's patience went on approving fragments.
+This skill carries the craft that prevents each of those.
+
+## What are you making?
+
+| Making | Scaffold | Workflow | Read |
+|---|---|---|---|
+| A still: hero art, spot, cover, social card, diagram, a series | `--still <name>` | **Still**, below | `styles.md`, `formats.md` |
+| Motion without a story: loop, sticker, animated logo, ambient header | `--film <name>` | **Loop**, below | `formats.md`, `styles.md` |
+| A film: 30 to 90 s, a transformation, a score | `--film <name>` | **Film**, below | all of `references/` |
+
+Ask for the size, the style (or pick one from `references/styles.md` and say why) and where it
+will live, if the request leaves them open. Everything else has a default.
## The seven laws
-1. **Story is the spine.** One transformation, one payoff, one visual token that returns. Style is
- how you say it, never the point. → `references/storytelling.md`
+1. **Every piece has a point.** A still: one idea, one focal subject, one light. A film: one
+ transformation, one payoff, one visual token that returns. → `references/storytelling.md`
2. **State the realism.** "A butterfly" gets you the road-sign icon of a butterfly. Name the
anatomy, the view, and the reference you opened. → `references/realism-and-craft.md`
-3. **Music gets a recipe, never an adjective.** Major key, plucked, I-IV-V-I, no pads, no drones,
- no long reverb. You cannot hear your output, so you do not improvise. → `references/music-recipe.md`
+3. **A style is a way of making marks.** Change the medium, the edge and the order of the marks,
+ beyond the palette. → `references/styles.md`
4. **Prove the look on ONE still, then build end to end.** One still buys the look. After that,
gates cost more than they save. → `references/working-method.md`
5. **The contract is absolute.** Pure in `(frame, env)`, `rng(seed)` only, no clock, no
- `ctx.filter`, no assets. → `references/determinism-and-contract.md`
-6. **One directs, one builds, both write everything down.** When a session degrades, reset it; the
- files are the memory. → `references/working-method.md`
-7. **Texture is geometry and seeded tiles.** Anything a filter would have done, you do with noise
- you made yourself. → `references/realism-and-craft.md`
+ `ctx.filter`, no assets. Texture is geometry and seeded tiles. → `references/determinism-and-contract.md`
+6. **Music gets a recipe, never an adjective.** Major key, plucked, I-IV-V-I, no pads, no drones,
+ no long reverb. You cannot hear your output, so you do not improvise. → `references/music-recipe.md`
+7. **One directs, one builds, both write everything down.** When a session degrades, reset it;
+ the files are the memory. → `references/working-method.md`
-## Workflow
+## Workflows
+**Still.** (1) Say the idea in one sentence and name the focal subject and the light. (2) Open
+real reference for anything that exists, and note which. (3) Pick the style and read its plate's
+module first. (4) Draw: cast shadow, form, line, paper, in that medium's order. (5) Render with
+`still.mjs` at full size, critique it in writing against the craft bar. ✋ **One approval.**
+(6) Deliver at every size asked for from the same source, and say `reproducible` was printed.
+
+**Loop.** As a still, plus: every motion is periodic over the loop (whole cycles only), the
+subject never stops, something moves in every second. Check the seam (last frame against frame
+0). Export GIF, WebM or APNG per `references/formats.md`. ✋ **One approval, on the moving file.**
+
+**Film.**
1. **Write the story in three sentences** (setup, transformation, payoff) and name the token. If
you cannot, stop. Do not open an editor.
2. **Put it on the grid.** 120 bpm at 30 fps is a 15-frame beat. Cuts on multiples of 15, events on
multiples of 5. ONE cue table per film holds every frame number, and a checker runs at load.
3. **Open real reference** for anything that exists in the world, and write down which images.
-4. **ONE look still** — the hardest frame: hero subject, large, in its world, in the final medium
+4. **ONE look still**: the hardest frame, hero subject large, in its world, in the final medium
and light. Critique it yourself in writing first. ✋ **Approval gate.**
5. **ONE 8-second music sample** from the recipe. ✋ **Approval gate.** The client listens; you can't.
6. **Build the whole film.** No per-shot approvals. Mechanical checks run continuously and need
nobody: types, grid, contract scan, draw budget, determinism, dead air.
7. **Review the whole film once**, from the rendered file: contact sheet at one tile per beat, each
cut as a before/after pair, the dead-air numbers. One ranked fix list. One rebuild.
-8. **Verify and deliver.** ✋ **Final approval.** Say what you verified and what you cannot — you
+8. **Verify and deliver.** ✋ **Final approval.** Say what you verified and what you cannot: you
cannot hear it and you cannot watch it move.
-Three approval gates. Not thirty. Approval is a budget; spend it where being wrong is expensive.
+Three approval gates at most. Approval is a budget; spend it where being wrong is expensive.
## The craft bar
@@ -60,66 +82,66 @@ The test: would a proud human illustrator ship this, or is it mechanical shape-a
| The tell | What passes |
|---|---|
-| A row of style vignettes | One arc. The medium changes only when the STORY changes state |
-| Things fade or scale in | Marks are MADE, in the order a hand makes them |
-| Both sides do the same thing at once | One side leads, by a few frames, never half a cycle |
-| Every stroke the same weight and speed | Long strokes fast, fiddly ones slow, thick-thin, tapered |
-| Flat colour fields | Wash, then pattern wet-on-damp, then line; one named light; cast shadows |
| A subject built from ellipses and capsules | Hand-placed control points over real anatomy |
+| One style recoloured to look like another | The mark, the edge and the order of marks all change |
+| Flat colour fields | Wash, then pattern wet-on-damp, then line; one named light; cast shadows |
+| Every stroke the same weight and speed | Long strokes fast, fiddly ones slow, thick-thin, tapered |
| Even scatter, one flower stamped 200 times | Hand-placed drifts with bare rests; 4-5 authored views per species |
| Gradient sky, disc sun, oval bokeh | Granulating wash, sun as paper left light, lost edges |
| Decoration | Every element has a one-line reason or it is not drawn |
+| A row of style vignettes (film) | One arc. The medium changes only when the STORY changes state |
+| Things fade or scale in | Marks are MADE, in the order a hand makes them |
+| Both sides do the same thing at once | One side leads, by a few frames, never half a cycle |
| A hold | The camera may creep. The subject never stops |
-**No dead air**: something visibly moves in every second, from frame 0. Check it with the tool AND
-by eye — a creeping camera changes every pixel and satisfies the tool while the eye sees a still.
+**No dead air** in anything that moves: something visibly changes in every second, from frame 0.
+Check it with the tool AND by eye: a creeping camera changes every pixel and satisfies the tool
+while the eye sees a still.
## The engine
`engine/` is the portable art core plus the tooling. Nothing in `engine/src/canvas-core` knows
-about React, Remotion, the DOM, or any backend — that separation is verified, not asserted.
+about React, Remotion, the DOM, or any backend; that separation is verified, not asserted.
```bash
-node <skill>/engine/tools/scaffold.mjs ~/my-film --film myFilm # new project, starter film
-cd ~/my-film && npm install
-node tools/still.mjs myFilm --out out/look.png # step 4: the ONE look still
-node tools/gate.mjs myFilm --mp4 out/my-film.mp4 # determinism + contract + dead air
-node tools/emit.mjs myFilm --out out/my-film.html # the self-contained player
-node tools/render.mjs myFilm # the MP4
+node <skill>/engine/tools/scaffold.mjs ~/art --still hero --film intro # either or both
+cd ~/art && npm install && npx playwright-core install chromium
+node tools/still.mjs hero --out out/hero.png --scale 2 # a picture, with its reproducibility hash
+node tools/render.mjs intro # the MP4; --out x.gif | x.webm | x.apng for loops
+node tools/gate.mjs intro --mp4 out/intro.mp4 # determinism + contract + dead air
+node tools/emit.mjs intro --out out/intro.html # one self-contained offline player
```
| Tool | What it does |
|---|---|
-| `scaffold.mjs` | engine + (optionally) the example into one working project |
-| `still.mjs` | one frame, full size, with its hash so a re-render can be proved identical |
-| `gate.mjs` | the three bars: determinism, contract, dead air. Any adapter |
-| `emit.mjs` | one self-contained offline HTML file, then verifies the file it just wrote |
-| `render.mjs` / `snap.mjs` | MP4; contact sheets |
-| `deadair.mjs` | per-frame changed-pixel fraction |
+| `scaffold.mjs` | engine + a starter still and/or film (+ `--example`) into one working project |
+| `still.mjs` | one frame, full size, drawn twice, with its hash; needs a browser only |
+| `render.mjs` | MP4, GIF, WebM or APNG, then a determinism probe |
+| `gate.mjs` | determinism, contract, dead air, any adapter; marks checks a piece has no use for as `----` |
+| `emit.mjs` | one offline HTML file that redraws the piece, then verifies the file it wrote |
+| `snap.mjs` / `deadair.mjs` | contact sheets; per-frame changed-pixel fraction |
| `verify-frame-adapter.mjs` | holds a page-side seek adapter to its contract |
Four backends, one art core: `playwright`, `html-player`, `remotion`, `hyperframes`. Each is
roughly 100 lines and none is visible from the core. → `references/backends-and-adapters.md`
-## The worked example
-
-`example/` is MECHANICAL LEPIDOPTERA: 1410 frames, 47 s, a clockwork butterfly that is drawn,
-comes alive, and leaves its blueprint in the grass. Its full spec is `example/butterfly-film-spec.md`.
+## Worked examples
-**Study it. Do not copy it.** It is there so you can see what "hand-placed control points over real
-anatomy" actually looks like in code — `example/src/canvas-core/butterfly/alive/anatomy.ts` builds
-a discal cell and veins that fork and never cross; `butterfly/surface.ts` beside it shows a cache
-key that names everything its pixels depend on. Copying it gets you somebody else's film with your title on it, and the craft bar
-above is not satisfied by inheritance.
+- **The nine style plates** in `engine/src/canvas-core/` (`ranunculus`, `koi`, `pocketWatch`,
+ `balloon`, `wren`, `moonPhases`, `fox`, `lighthouse`, `mellan`): one still each, the recipe in
+ the header. `banner.ts` is an ambient loop; `mellanUnspool.ts` a still that draws itself.
+- **MECHANICAL LEPIDOPTERA** in `example/`: 1410 frames, 47 s, a clockwork butterfly that is
+ drawn, comes alive, and leaves its blueprint in the grass. Spec: `example/butterfly-film-spec.md`.
+ `butterfly/alive/anatomy.ts` is realism as code; `butterfly/surface.ts` is a cache key that
+ names everything its pixels depend on. `node <skill>/engine/tools/scaffold.mjs ~/study --example`
-```bash
-node <skill>/engine/tools/scaffold.mjs ~/study --example
-```
+**Study them. Do not copy them.** Copying gets you somebody else's picture with your title on
+it, and the craft bar is not satisfied by inheritance.
## Honest limits
You cannot hear the score and you cannot watch the film move. Every claim about either must come
from a measurement or from a human. Say which. A green checkmark is a claim, not evidence, until
-you re-run it — on this film the dead-air gate passed while a second of near-stillness sat in the
-cut, and a cache key that was wrong in one frame order survived every eye that read the code. The
-machine found that one; no human was ever going to.
+you re-run it: on the worked film the dead-air gate passed while a second of near-stillness sat
+in the cut, and a cache key that was wrong in one frame order survived every eye that read the
+code. The machine found that one; no human was ever going to.
diff --git a/assets/mellan-spiral.png b/assets/mellan-spiral.png
deleted file mode 100644
index 336fe5e..0000000
Binary files a/assets/mellan-spiral.png and /dev/null differ
diff --git a/assets/styles.jpg b/assets/styles.jpg
new file mode 100644
index 0000000..175f36b
Binary files /dev/null and b/assets/styles.jpg differ
diff --git a/assets/styles.png b/assets/styles.png
deleted file mode 100644
index 9c9c287..0000000
Binary files a/assets/styles.png and /dev/null differ
diff --git a/engine/package.json b/engine/package.json
index c442bc5..f7022f2 100644
--- a/engine/package.json
+++ b/engine/package.json
@@ -3,7 +3,7 @@
"version": "1.0.0",
"private": true,
"type": "module",
- "description": "Portable art core + backend adapters for a film drawn entirely by code.",
+ "description": "Portable art core + backend adapters for illustrations, animations and films drawn entirely in code.",
"scripts": {
"still": "node tools/still.mjs",
"gate": "node tools/gate.mjs",
diff --git a/engine/src/canvas-core/styleGallery.ts b/engine/src/canvas-core/styleGallery.ts
index 08f1c69..ef70dee 100644
--- a/engine/src/canvas-core/styleGallery.ts
+++ b/engine/src/canvas-core/styleGallery.ts
@@ -9,13 +9,14 @@ import { drawWren } from "./wren";
import { drawMoonPhases } from "./moonPhases";
import { drawFox } from "./fox";
import { drawLighthouse } from "./lighthouse";
+import { drawMellan } from "./mellan";
-// THE STYLE GALLERY. Eight subjects, eight hands, one engine, laid out as a contact sheet.
+// THE STYLE GALLERY. Nine styles, each on its own subject, laid out as a contact sheet.
// The sheet is itself a film drawn by code: every tile is its subject's own pure draw function,
// rendered at full size into an offscreen surface and set down on the sheet, so the gallery is
// exactly as asset-free and as reproducible as the pictures on it. Nothing here is a photograph.
-const TILE = 1000, GUT = 44, LAB = 92, HEAD = 150, COLS = 4, ROWS = 2;
+const TILE = 1000, GUT = 44, LAB = 92, HEAD = 150, COLS = 3, ROWS = 3;
const GW = COLS * TILE + (COLS + 1) * GUT, GH = HEAD + ROWS * (TILE + LAB) + (ROWS + 1) * GUT;
const SHEET = "#eee8dc", INKC = "#2a2521", MUTED = "#8a7f72";
@@ -28,6 +29,7 @@ const PLATES: { draw: (ctx: Ctx, f: number, env: Env) => void; style: string; su
{ draw: drawMoonPhases, style: "CHALKBOARD", subject: "PHASES OF THE MOON" },
{ draw: drawFox, style: "CUT-PAPER COLLAGE", subject: "FOX AT DUSK" },
{ draw: drawLighthouse, style: "RISOGRAPH", subject: "LIGHTHOUSE AT SUNSET" },
+ { draw: (ctx, f, env) => drawMellan(ctx, f, env, 1), style: "SINGLE-LINE ENGRAVING", subject: "THE MOON, ONE UNBROKEN SPIRAL" },
];
export const drawStyleGallery = (ctx: Ctx, _frame: number, env: Env) => {
@@ -53,8 +55,8 @@ export const drawStyleGallery = (ctx: Ctx, _frame: number, env: Env) => {
letter(g, p.style, x + 64, y + TILE + 30, { cap: 26, color: INKC, seed: 910 + i, w: 2.4, opacity: 0.95 });
letter(g, p.subject, x + 64, y + TILE + 66, { cap: 17, color: MUTED, seed: 920 + i, w: 1.6, opacity: 0.9 });
});
- letter(g, "ANIDOODLE / EIGHT HANDS, ONE ENGINE", GUT, 52, { cap: 46, color: INKC, seed: 1, w: 3.2, opacity: 0.95 });
- letter(g, "EVERY MARK DRAWN IN CODE. NO PHOTOGRAPHS, NO IMAGE OR AUDIO ASSETS, EVERY PLATE DETERMINISTIC.", GUT, 118, { cap: 19, color: MUTED, seed: 2, w: 1.7, opacity: 0.9 });
+ letter(g, "ANIDOODLE / NINE STYLES TO CHOOSE FROM", GUT, 52, { cap: 46, color: INKC, seed: 1, w: 3.2, opacity: 0.95 });
+ letter(g, "EVERY MARK DRAWN IN CODE. EVERY PLATE REBUILDS PIXEL FOR PIXEL FROM ITS OWN SOURCE.", GUT, 118, { cap: 19, color: MUTED, seed: 2, w: 1.7, opacity: 0.9 });
};
export const styleGallery: Film = {
diff --git a/engine/tools/adapters/html-player.mjs b/engine/tools/adapters/html-player.mjs
index dabd881..6aefff7 100644
--- a/engine/tools/adapters/html-player.mjs
+++ b/engine/tools/adapters/html-player.mjs
@@ -35,7 +35,7 @@ export const pageChecks = (html) => {
{ ok: has(/fetch\(|XMLHttpRequest|importScripts/g) === 0, label: "no network call in the bundle", detail: `${has(/fetch\(|XMLHttpRequest|importScripts/g)} found` },
{ ok: assets ? assets[1].trim() === "{}" : false, label: "the asset manifest is empty", detail: assets ? assets[1].trim() : "manifest absent" },
{ ok: /window\.FILM\s*=/.test(html), label: "exposes window.FILM so any host can drive it", detail: "" },
- { ok: /audio\s*[:(]/.test(html), label: "carries its own audio, synthesized in the page", detail: "" },
+ { ok: /audio\s*[:(]/.test(html), label: "any score is synthesized in the page, never loaded", detail: "" },
];
};
diff --git a/engine/tools/gate.mjs b/engine/tools/gate.mjs
index f327de9..f6bd2b1 100644
--- a/engine/tools/gate.mjs
+++ b/engine/tools/gate.mjs
@@ -24,6 +24,7 @@ const TMP = resolve(".tmp/gate"); mkdirSync(TMP, { recursive: true });
let fails = 0, checks = 0;
const say = (ok, label, detail = "") => { checks++; if (!ok) fails++; console.log(` ${ok ? "PASS" : "FAIL"} ${label}${detail ? " " + detail : ""}`); };
+const note = (label, detail = "") => console.log(` ---- ${label}${detail ? " " + detail : ""}`); // not applicable: printed, never counted
const head = (n, t) => console.log(`\n${n}. ${t}\n${"-".repeat(58)}`);
// ---------------------------------------------------------------- 2. the contract, statically
@@ -133,11 +134,15 @@ const run = async () => {
: ` DIAGNOSIS: frame ${bad} is stable within a session; the difference is between sessions.`);
}
}
- say(aud1 && aud2 ? aud1.pcm16 === aud2.pcm16 : false, "the synthesized audio is identical across sessions", aud1 ? `${aud1.frames} samples @ ${aud1.sampleRate} Hz` : "no audio");
+ // A silent piece (a still, a loop, a logo) has nothing to compare; a score that appears in one
+ // session and not the other is still a failure.
+ if (!aud1 && !aud2) note("no score in this piece", "audio check not applicable");
+ else say(aud1 && aud2 ? aud1.pcm16 === aud2.pcm16 : false, "the synthesized audio is identical across sessions", aud1 ? `${aud1.frames} samples @ ${aud1.sampleRate} Hz` : "no audio");
await s2.close();
const nFiles = contractScan();
- deadAir(resolve(opt.mp4 ?? `out/${film.replace(/([A-Z])/g, "-$1").toLowerCase()}.mp4`));
+ if (N === 1) { head(3, "DEAD AIR something visibly moves in every second"); note("a still, one frame long", "dead air not applicable"); }
+ else deadAir(resolve(opt.mp4 ?? `out/${film.replace(/([A-Z])/g, "-$1").toLowerCase()}.mp4`));
if (art) {
head(4, `ARTIFACT what this adapter delivers`);
diff --git a/engine/tools/render.mjs b/engine/tools/render.mjs
index 5933d51..f087ce4 100644
--- a/engine/tools/render.mjs
+++ b/engine/tools/render.mjs
@@ -1,5 +1,12 @@
-// node tools/render.mjs [film] [--scale 1] [--workers 4] [--out out/x.mp4]
+// node tools/render.mjs [film] [--scale 1] [--workers 4] [--out out/x.mp4|.gif|.webm|.apng] [--gif-fps 15] [--width 640]
// Auto-detects a backend, renders every frame through it, encodes with ffmpeg, then VERIFIES.
+// .mp4 the film, with its score
+// .gif loops and README heroes: silent, loops forever, ONE palette built from the whole piece
+// so a wash does not band differently from frame to frame
+// .webm VP9 with its alpha kept: stickers and overlays. Leave the background unpainted and
+// whatever sits behind the page shows through
+// .apng animated PNG, alpha kept, loops forever, plays in every browser
+// --width only applies to the silent formats; the MP4 is always the film's own size.
import { spawn, execFileSync } from "node:child_process";
import { mkdirSync, writeFileSync } from "node:fs";
import { cpus } from "node:os";
@@ -10,7 +17,7 @@ import * as playwright from "./adapters/playwright.mjs";
const arg = (k, d) => { const i = process.argv.indexOf(`--${k}`); return i > 0 ? process.argv[i + 1] : d; };
const film = process.argv[2] && !process.argv[2].startsWith("--") ? process.argv[2] : "fixtures";
-const scale = Number(arg("scale", 1)), workers = Number(arg("workers", Math.max(1, Math.min(4, Math.floor(cpus().length / 2))))), out = resolve(arg("out", `out/${film}.mp4`));
+const scale = Number(arg("scale", 1)), fmt = (arg("out", "").match(/\.(gif|webm|apng)$/i)?.[1] ?? "mp4").toLowerCase(), workers = Number(arg("workers", Math.max(1, Math.min(4, Math.floor(cpus().length / 2))))), out = resolve(arg("out", `out/${film}.mp4`));
const env = detect();
console.log("backends found:"); for (const [k, v] of Object.entries(env.report)) console.log(` ${k.padEnd(11)} ${v}`);
@@ -27,7 +34,16 @@ mkdirSync(resolve(".tmp"), { recursive: true }); const wav = resolve(`.tmp/${fil
if (a) { const pcm = Buffer.from(a.pcm16, "base64"), h = Buffer.alloc(44); h.write("RIFF", 0); h.writeUInt32LE(36 + pcm.length, 4); h.write("WAVEfmt ", 8); h.writeUInt32LE(16, 16); h.writeUInt16LE(1, 20); h.writeUInt16LE(2, 22); h.writeUInt32LE(a.sampleRate, 24); h.writeUInt32LE(a.sampleRate * 4, 28); h.writeUInt16LE(4, 32); h.writeUInt16LE(16, 34); h.write("data", 36); h.writeUInt32LE(pcm.length, 40); writeFileSync(wav, Buffer.concat([h, pcm])); }
mkdirSync(join(out, ".."), { recursive: true });
-const ff = spawn(env.ffmpeg.bin, ["-y", "-loglevel", "error", "-f", "image2pipe", "-framerate", String(meta.fps), "-c:v", "png", "-i", "-", ...(a ? ["-i", wav] : []), "-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "16", "-preset", "medium", ...(a ? ["-c:a", "aac", "-b:a", "192k", "-shortest"] : []), "-movflags", "+faststart", out], { stdio: ["pipe", "inherit", "inherit"] });
+const input = ["-y", "-loglevel", "error", "-f", "image2pipe", "-framerate", String(meta.fps), "-c:v", "png", "-i", "-"];
+const gifFps = Math.min(meta.fps, Number(arg("gif-fps", 15))), width = Number(arg("width", Math.min(640, Math.round(meta.W * scale))));
+const size = `scale=${width}:-2:flags=lanczos`;
+const encode = {
+ gif: [...input, "-vf", `fps=${gifFps},${size},split[a][b];[a]palettegen=stats_mode=full[p];[b][p]paletteuse=dither=sierra2_4a`, "-loop", "0", out],
+ webm: [...input, "-vf", size, "-c:v", "libvpx-vp9", "-pix_fmt", "yuva420p", "-b:v", "0", "-crf", "30", "-an", out],
+ apng: [...input, "-vf", size, "-f", "apng", "-plays", "0", out],
+ mp4: [...input, ...(a ? ["-i", wav] : []), "-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "16", "-preset", "medium", ...(a ? ["-c:a", "aac", "-b:a", "192k", "-shortest"] : []), "-movflags", "+faststart", out],
+}[fmt];
+const ff = spawn(env.ffmpeg.bin, encode, { stdio: ["pipe", "inherit", "inherit"] });
const done = new Promise((res, rej) => ff.on("close", (c) => (c ? rej(new Error(`ffmpeg exited ${c}`)) : res())));
// frames render in parallel across pages, and are fed to ffmpeg strictly in order
diff --git a/engine/tools/scaffold.mjs b/engine/tools/scaffold.mjs
index 8c8b9ef..c8009ae 100644
--- a/engine/tools/scaffold.mjs
+++ b/engine/tools/scaffold.mjs
@@ -1,12 +1,14 @@
-// SCAFFOLD. Turn the skill's engine into a working film project.
+// SCAFFOLD. Turn the skill's engine into a working project: a still, a film, or both.
//
-// node <skill>/engine/tools/scaffold.mjs <dir> [--film myFilm] [--example]
+// node <skill>/engine/tools/scaffold.mjs <dir> [--still myPicture] [--film myFilm] [--example]
//
// The engine ships as parts, not as a project: `engine/src` holds the portable art core and the
// one page host, `example/src` holds the worked butterfly. A film needs them in ONE tree, because
// every tool here resolves `src/canvas-core/<film>.ts` and `src/hosts/page-<film>.ts` against the
// working directory. That is the whole job.
//
+// --still <name> write a one-frame picture module (a still is a film one frame long, so every
+// tool works on it unchanged) and its host page, ready to render
// --film <name> write a minimal film module and its host page, ready to render
// --example copy the mechanical-butterfly in as well, to READ. It is proof of craft, not
// a template: copying it gets you somebody else's film with your title on it.
@@ -18,18 +20,19 @@ const HERE = dirname(fileURLToPath(import.meta.url));
const ENGINE = resolve(HERE, "..");
const SKILL = resolve(ENGINE, "..");
-const VAL = new Set(["film"]);
+const VAL = new Set(["film", "still"]);
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(`scaffold: ${m}`); process.exit(1); };
-const target = resolve(pos[0] ?? die("usage: node tools/scaffold.mjs <dir> [--film myFilm] [--example]"));
-const film = opt.film && opt.film !== true ? String(opt.film) : null;
-if (film && !/^[a-zA-Z][a-zA-Z0-9]*$/.test(film)) die(`--film '${film}' must be a bare identifier: it becomes a module name and an export name`);
+const target = resolve(pos[0] ?? die("usage: node tools/scaffold.mjs <dir> [--still myPicture] [--film myFilm] [--example]"));
+const name = (flag) => { const v = opt[flag] && opt[flag] !== true ? String(opt[flag]) : null; if (v && !/^[a-zA-Z][a-zA-Z0-9]*$/.test(v)) die(`--${flag} '${v}' must be a bare identifier: it becomes a module name and an export name`); return v; };
+const film = name("film"), still = name("still");
+if (film && still && film === still) die("--film and --still need different names");
mkdirSync(target, { recursive: true });
cpSync(join(ENGINE, "src"), join(target, "src"), { recursive: true });
cpSync(join(ENGINE, "tools"), join(target, "tools"), { recursive: true });
-for (const f of ["package.json", "tsconfig.json"]) if (existsSync(join(ENGINE, f))) cpSync(join(ENGINE, f), join(target, f));
+for (const f of ["package.json", "package-lock.json", "tsconfig.json"]) if (existsSync(join(ENGINE, f))) cpSync(join(ENGINE, f), join(target, f));
if (opt.example) {
const ex = join(SKILL, "example", "src");
@@ -74,8 +77,66 @@ export const ${film}: Film = {
writeFileSync(join(target, "src/hosts", `page-${film}.ts`), `import { ${film} } from "../canvas-core/${film}";\nimport { mountFilm } from "./page";\nmountFilm(${film});\n`);
}
+// A still is a film one frame long. The starter is a small study done the way the gallery plates
+// are: one named light, a cast shadow, the form washed in, then the pencil, then the paper. It is
+// there to show the ORDER of the marks; replace the pear, keep the order.
+if (still) {
+ const mod = join(target, "src/canvas-core", `${still}.ts`);
+ if (existsSync(mod)) die(`${mod} already exists; refusing to overwrite a picture module`);
+ writeFileSync(mod, `import { Gfx, PENCIL, line, oval, type Ctx, type Env, type P } from "./core";
+import { Film } from "./film";
+
+// ONE light for the whole picture, upper left. Every form is lit from it and every shadow falls
+// away from it: this one decision is most of what makes a drawing read as solid.
+const LIGHT: P = [-7, -9];
+
+// Hand-placed control points round a pear: a narrow shoulder, a waist, a heavy seat. Placed by
+// eye over the real fruit, never built from ellipses; that is the difference between a pear and
+// the icon of one.
+const PEAR: P[] = [[536, 318], [566, 330], [584, 372], [590, 430], [616, 482], [660, 540], [684, 612], [674, 690], [630, 748], [556, 776], [478, 766], [420, 722], [396, 652], [410, 574], [452, 510], [484, 452], [494, 384], [508, 336]];
+const STEM: P[] = [[532, 324], [528, 286], [540, 246], [556, 228]];
+const LEAF: P[] = [[532, 272], [566, 236], [620, 218], [666, 226], [636, 258], [586, 276]];
+const SHADE: P[] = [[586, 420], [612, 480], [656, 540], [680, 612], [670, 688], [628, 744], [572, 766], [604, 716], [628, 650], [622, 574], [596, 500]]; // the core shadow, hugging the side away from the light
+
+export const draw${still[0].toUpperCase() + still.slice(1)} = (ctx: Ctx, _frame: number, env: Env) => {
+ // A still has no line boil across frames: its only randomness is the seeded geometry below.
+ const g = new Gfx(ctx, env, 0, PENCIL);
+ ctx.setTransform(env.scale, 0, 0, env.scale, 0, 0);
+ ctx.fillStyle = "#fbf6ec"; ctx.fillRect(0, 0, env.W, env.H);
+
+ // 1. the cast shadow first, so the fruit sits ON the table and never floats over it
+ g.group("paint", () => g.wash(oval(600, 772, 190, 34, 16), "#a79db8", { seed: 3, alpha: 0.42, dx: 0, dy: 0, shrink: 1 }));
+ // 2. the form: a shadow colour under, the lit colour pushed toward the light, one lifted highlight
+ g.group("paint", () => {
+ g.form(PEAR, "#e2c15c", "#8f8a3c", { seed: 5, light: LIGHT, hi: [486, 590, 12, 30, -24] });
+ g.wash(SHADE, "#7d6a2e", { seed: 6, alpha: 0.26, dx: 0, dy: 0, shrink: 1, rim: false });
+ g.wash(oval(492, 668, 74, 96, 12), "#d9804f", { seed: 8, alpha: 0.09, dx: 0, dy: 0, shrink: 1, rim: false }); // a blush, lost at every edge
+ g.form(LEAF, "#98ad6f", "#5d7454", { seed: 7, light: LIGHT, alpha: 0.95 });
+ });
+ // 3. the pencil, over the paint: a contour that swells and lifts, then the few lines that matter
+ g.group("ink", () => {
+ g.pen(PEAR, { seed: 11, closed: true, w: 1.3, opacity: 0.78, wobble: 0.8, boil: 0 });
+ g.pen(STEM, { seed: 12, w: 2.6, opacity: 0.9, boil: 0, taper: 0.6 });
+ g.pen(LEAF, { seed: 13, closed: true, w: 0.9, opacity: 0.55, boil: 0 });
+ g.pen(line([536, 270], [660, 230], -6), { seed: 14, w: 0.6, opacity: 0.45, boil: 0, retrace: false });
+ });
+ // 4. the sheet itself, over everything
+ g.paper("paper", 0.12);
+ g.paper("coldpress", 0.18);
+};
+
+export const ${still}: Film = {
+ meta: { title: "${still}", W: 1080, H: 1080, fps: 30, bpm: 120, durationFrames: 1 },
+ assets: { images: {} },
+ shots: [{ id: "${still}", start: 0, end: 1, draw: draw${still[0].toUpperCase() + still.slice(1)} }],
+};
+`);
+ writeFileSync(join(target, "src/hosts", `page-${still}.ts`), `import { ${still} } from "../canvas-core/${still}";\nimport { mountFilm } from "./page";\nmountFilm(${still});\n`);
+}
+
const tree = (dir, depth = 0) => readdirSync(dir, { withFileTypes: true }).filter((e) => e.name !== "node_modules").slice(0, 6).map((e) => `${" ".repeat(depth + 1)}${e.name}${e.isDirectory() ? "/" : ""}`).join("\n");
console.log(`scaffolded ${target}\n${tree(target)}\n`);
console.log(`next:\n cd ${target}\n npm install`);
+if (still) console.log(` node tools/still.mjs ${still} --out out/${still}.png # the picture; --scale 2 for print size`);
if (film) console.log(` node tools/still.mjs ${film} --out out/look.png # the ONE look still\n node tools/gate.mjs ${film} --mp4 out/${film.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase()}.mp4`);
if (opt.example) console.log(` node tools/gate.mjs mechanicalLepidoptera --mp4 out/mechanical-lepidoptera.mp4 # the worked example`);
diff --git a/engine/tools/still.mjs b/engine/tools/still.mjs
index 4902fe5..fc5f5b3 100644
--- a/engine/tools/still.mjs
+++ b/engine/tools/still.mjs
@@ -1,5 +1,5 @@
// STILL. One frame of one film, at full resolution, to a path a human can open.
-// node tools/still.mjs <film> --shot <id> --out out/x.png [--scale 1]
+// node tools/still.mjs <film> [--shot <id>] [--frame N] [--out out/x.png] [--scale 1]
// The look still is rendered many times before a single frame of motion is, so
// this does exactly that and nothing else: build the page, draw the frame, write the PNG, print
// the draw cost and the frame's hash so a re-render can be proved identical.
@@ -14,11 +14,12 @@ const VAL = new Set(["shot", "out", "scale", "frame"]);
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(`still: ${m}`); process.exit(1); };
-const film = pos[0] ?? die("usage: node tools/still.mjs <film> --shot <id> --out out/x.png [--scale 1]");
+const film = pos[0] ?? die("usage: node tools/still.mjs <film> [--shot <id>] [--frame N] [--out out/x.png] [--scale 1]");
const scale = Number(opt.scale ?? 1);
const env = detect();
-if (!env.chosen) die("no render backend found; the HTML player still works: node tools/build-page.mjs " + film);
+// A still needs a browser and nothing else: ffmpeg only matters once there is motion to encode.
+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`);
const page = await buildPage({ entry: `src/hosts/page-${film}.ts`, out: resolve(`dist/${film}.html`), title: film });
const session = await playwright.open(env, page.out, { scale, workers: 1 });
const meta = await session.info();
diff --git a/references/formats.md b/references/formats.md
new file mode 100644
index 0000000..921b117
--- /dev/null
+++ b/references/formats.md
@@ -0,0 +1,63 @@
+# Formats: what you are making, and how each one ships
+
+Everything is a `Film`: meta, shots that tile `[0, duration)`, and optionally a score. A still
+is a film one frame long, so every tool works on every format. Scaffold the kind you need:
+
+```bash
+node <skill>/engine/tools/scaffold.mjs ~/art --still hero # a picture
+node <skill>/engine/tools/scaffold.mjs ~/art --film intro # something that moves
+```
+
+## Stills: hero art, spots, covers, cards, diagrams
+
+- **Size is `meta.W` x `meta.H`**, in logical units; `--scale` multiplies it at render time, so
+ one source gives a thumbnail (`--scale 0.5`), the page (`1`) and print (`--scale 3`). Common
+ shapes: 1600x900 web hero, 1200x630 social card, 1080x1080 square post, 1080x1350 portrait
+ post, 2550x3300 letter at 300 dpi.
+- **`node tools/still.mjs hero --out out/hero.png`** draws it twice and prints `reproducible`
+ when both hashes agree. That line is the receipt that the same file will come back tomorrow.
+- **Transparent background**: skip the paper fill and the page stays clear, so a spot
+ illustration or an icon drops onto any website colour. Leave `g.paper()` off as well: over
+ clear pixels it lays its grain down as a grey veil. Carry the tooth in the marks instead
+ (`ink` and `paint` groups texture themselves).
+- **A series** is one draw function and many seeds or parameters: a set of blog headers, a card
+ per team member, a family of empty states. Put the variation in a table at the top of the
+ module and render each row; `styleGallery.ts` shows how several plates compose onto one sheet.
+- **An explainer or infographic** still: draw the thing, then label it with `drafting.ts`
+ `letter()` and leader lines drawn with `g.pen`. Numbers are content, so every figure on the
+ plate comes from a named source in a comment beside it.
+
+The approval gate for a still is the still itself: one render, a written self-critique against
+the craft table, then show it.
+
+## Motion without a story: loops, stickers, logos, ambient art
+
+- **Seamless loop**: drive everything from `t = local / DURATION` through functions that repeat
+ a whole number of times over `[0, 1)` (`sin(2 * PI * k * t)`, integer `k`). Frame `DURATION`
+ then equals frame 0 and the seam disappears. Check it: render the last frame and frame 0 and
+ compare them to a mid-loop neighbour pair.
+- **Animated logo / sticker**: 2 to 4 seconds, the mark DRAWN on (`progress` on `g.pen`,
+ `letter`), a settle, a small idle. Leave the background unpainted for transparency.
+- **Ambient / idle art** (a site header that breathes, a banner): the subject never stops; the
+ motion is small and everywhere. `banner.ts` is the worked example.
+- **Dead air still applies**: the gate measures it on any piece longer than one frame.
+
+## Films: the story ones
+
+30 to 90 seconds, a transformation, a score, the full workflow in `SKILL.md`, the doctrine in
+`storytelling.md`, `music-recipe.md` and `working-method.md`. `example/` is the worked one.
+
+## Delivering
+
+| Output | Command | For |
+|---|---|---|
+| PNG | `node tools/still.mjs <name> --out out/x.png [--scale 2]` | stills, print, anything static |
+| MP4 | `node tools/render.mjs <name>` | films with their score, social video |
+| GIF | `node tools/render.mjs <name> --out out/x.gif [--width 640] [--gif-fps 15]` | loops, README heroes, email |
+| WebM | `node tools/render.mjs <name> --out out/x.webm [--width 512]` | stickers and overlays, alpha kept (VP9) |
+| APNG | `node tools/render.mjs <name> --out out/x.apng [--width 512]` | alpha loops that play in every browser |
+| HTML | `node tools/emit.mjs <name> --out out/x.html` | the piece itself: one offline file that redraws it, with sound, on a double-click |
+
+A still needs a browser only (`npx playwright-core install chromium`). Anything that moves also needs
+`ffmpeg`. `gate.mjs` runs on all of them and marks the checks that do not apply to the piece,
+a silent loop's audio or a still's dead air, as `----` rather than passing them.
diff --git a/references/styles.md b/references/styles.md
new file mode 100644
index 0000000..a288faf
--- /dev/null
+++ b/references/styles.md
@@ -0,0 +1,93 @@
+# Styles: nine hands, and the kit they are drawn with
+
+A style is a way of making a MARK, and it goes deeper than a palette. The same fox drawn by a
+crayon kid, a collage artist and a printmaker changes shape, edge and light, and it changes in
+the order the marks go down. Recolouring one drawing gives you one drawing in nine outfits.
+Every plate below is a working module in `engine/src/canvas-core/`: open it before you draw in
+its style, because the header comment is the recipe and the code is the proof.
+
+Render any of them: `node tools/still.mjs koi --out out/koi.png`. The whole sheet:
+`node tools/still.mjs styleGallery`.
+
+## The nine
+
+| # | Style | Module | The mark that makes it |
+|---|---|---|---|
+| 1 | Pencil & watercolour | `ranunculus.ts` | washes that never quite fill their outline, form shaded toward ONE light, graphite over the paint |
+| 2 | Marker comic | `koi.ts` | flat cel fills with a hard shadow edge, one heavy contour that thickens away from the light |
+| 3 | Ballpoint sketch | `pocketWatch.ts` | one biro, near-constant weight; tone comes only from WHERE hatching sits (single, cross, third direction) plus the blob where a firm stroke stops |
+| 4 | Crayon | `balloon.ts` | back-and-forth scribble fills that skip the paper's valleys, a darker crayon over the shade side, a white one burnishing the highlight, a fat contour gone over twice |
+| 5 | Ink & line-wash | `wren.ts` | wet washes first that flood past the line and settle along each shape's BOTTOM edge, backruns, then a flexible nib, thick on the press, hair-thin on the lift, contours left open where light eats the edge |
+| 6 | Chalkboard | `moonPhases.ts` | side-of-the-chalk scumble, lit limbs worked twice, every stroke broken by the board's tooth with dust either side, ghosts of old lessons |
+| 7 | Cut-paper collage | `fox.ts` | zero drawn lines: torn pieces with a white fibrous edge, scissor pieces crisp, each lifting off the one below with a soft shadow |
+| 8 | Risograph | `lighthouse.ts` | one layer per drum, multiplied through its own registration offset; every other colour is an OVERPRINT; tone is a halftone screen per ink angle; white is bare paper |
+| 9 | Single-line engraving | `mellan.ts` | one unbroken spiral whose width follows a procedural tone field: the whole picture is a single stroke |
+
+Two more hands live in the worked film (`example/`): a **cyanotype blueprint** (ruling pen,
+`draftTooth` + `blueMottle` tiles, `inkGroup` halos, inclined gothic lettering) and a **storybook
+pencil + watercolour** character (`storybook.ts`). `print.ts` is the same character in riso.
+
+## Picking one
+
+Pick for the JOB before the looks. The same idea reads differently in each.
+
+| The piece is | Reach for |
+|---|---|
+| warm, human, a brand with a smile | pencil & watercolour, crayon, cut paper |
+| a serious topic, a report, a founder essay | ballpoint, ink & line-wash, engraving |
+| an explainer, a how-it-works, an infographic | chalkboard, blueprint, ballpoint with drafted labels |
+| loud, social, a launch | marker comic, risograph |
+| a poster, a cover, one image people keep | engraving, risograph, cut paper |
+
+A brand picks ONE hand and keeps it: every hero, spot and card afterwards in the same mark is
+what makes a set feel like a system.
+
+## Your own style
+
+Start from the nearest plate and change the MARK, never just the colours:
+
+1. **Name the medium physically.** What touches the paper, how wet, how it lifts, what the paper
+ does back. Write it as the header comment before any code, like the nine above.
+2. **Set a `Medium`** for pen-based hands: `{ nib, taper, pressure, retrace, wobble, rough }`.
+ Compare `PENCIL`, `BIRO_M` (pocketWatch), `CRAYON_M` (balloon), `INK_M` (wren), `CHALK_M`
+ (moonPhases), `LITHO` (riso). A biro has almost no taper; a flexible nib has a lot of pressure.
+3. **Decide the order of the marks.** Wash then line (line-wash), line then wash (pencil &
+ watercolour), plate by plate (riso), piece by piece (collage). The order is half the style.
+4. **Pick the paper**: which tiles, at what opacity, applied last.
+5. **Render one still of the hardest subject in it** and critique it against the craft table in
+ `realism-and-craft.md` before you use the style for anything else.
+
+## The kit
+
+Everything is geometry plus a few composited layers. No filters, no assets.
+
+**`core.ts`** is the drawing surface and shape helpers.
+- `new Gfx(ctx, env, frame, medium)`, the surface. `frame` drives line boil in motion; a still passes 0.
+- `g.group("paint" | "ink" | "plain", fn, { blend, alpha, off, textures, blur })`: draw on a
+ layer, texture it once, composite only what was touched. `paint` softens + granulates, `ink`
+ gets pencil tooth, `plain` is for cut or printed media.
+- `g.pen(pts, { w, color, seed, closed, wobble, boil, taper, opacity, retrace, progress })`:
+ a tapered, pressure-shaped stroke. `progress < 1` draws it partway, cut on the centreline,
+ which is how a line is seen being MADE.
+- `g.form(pts, color, shade, { light, hi })`: a shaded volume toward one light, optional highlight.
+- `g.wash(pts, color, { alpha, dx, dy, shrink, rim })`: watercolour that misses its outline, pigment at the rim.
+- `g.fill`, `g.hatch`, `g.glow`, `g.paper(tile, opacity)`, `g.vignette`, `g.inkGroup` (line with a halo).
+- Shapes: `oval`, `softBox`, `arc`, `line(a, b, bow)`, `tube(centre, r0, r1)`, `poly`, `turn`,
+ `sample` (smooth a polyline), `jitter`, `displace` (noise-displaced geometry), `halftone`.
+- Randomness: `rng(seed)`, `fractal(seed, x, y, fx, fy, octaves)`.
+- Tiles: `paper`, `coldpress`, `pencilTooth`, `washGran`, `risoSpeck`, `risoMottle`, `draftTooth`, `blueMottle`.
+
+**`gallery.ts`** holds the representational helpers the plates share: `body(ctrl, halfWidth)`
+(a spine with a width profile, for fish, birds, limbs), `profile(knots)`, `ink(g, centre, color, opts)`
+(a contour ribbon that thickens away from the light), `blob` (an organic closed shape),
+`hatchRuns` (hatching clipped to a shape), `fillShape`, `clipped`, `inside`, `mix`, `resample`.
+
+**`riso.ts`** covers printmaking: `INK` colours, `drum(g, offset, fn)`, `screen(...)` (a halftone driven by a
+tone function), `REG` offsets, `cut` (a hand-cut edge), `plateMarks`, `across` (a 0..1 gradient across a shape).
+
+**Lettering, drawn as strokes so no font is ever loaded.**
+- `drafting.ts`: `letter(g, text, x, y, { cap, color, seed, w, progress })`, single-stroke
+ inclined gothic capitals, the lettering of engineering drawings. Labels, callouts, captions,
+ infographic numbers. `progress` writes it on.
+- `lettering.ts`: pointed-pen script, width from how much each stretch travels downward. It
+ spells one authored word (the banner's); a new word means authoring its centrelines the same way.