ai.withmb · free skill · DIRECTOR

The Reel Director skill

Same face, a new world every line, and nobody opens an editor. This is the full Claude Code skill behind the reel, every file, nothing blurred, plus how to make it yours.

How it thinks

Most people ask the AI for a cool video and hope. This skill makes Claude work like a director's assistant. Nothing gets rendered until there is a plan where every second already has a picture, a sound and a reason.

  1. BriefThe one idea, the call to action, who is on screen, the voice, the length.
  2. Beat sheetOne row per sentence with its time, its world, what moves, the words on screen and the sound. You approve it.
  3. LookWorlds picked from the library, 3 to 5 stills rendered for you to check.
  4. BuildOne HTML page timed to your real voice, rendered to MP4.
  5. Sound and exportHits, pops and whooshes on the right frames, music ducked under you, Reels-ready file.

Set it up in 3 steps

1. Make the folder

In your project, create .claude/skills/reel-director/. Claude Code finds skills there on its own.

reel-director/ ├── SKILL.md ├── references/ script-template · eyes · ears · hooks · export · learnings ├── scripts/ render.mjs · mix.py └── worlds/ worlds.js

2. Add the files

Open each file below, tap Copy, and save it under the same name. Or paste this page's link into Claude Code and ask it to create the folder for you.

3. Ask for your first reel

Use the reel-director skill. Here is my script: [paste it]. I'm on camera as a cut-out from [my video file]. Write the beat sheet first and wait for my OK before building anything.
Claude CodeNode 18+ffmpegChrome or ChromiumPython 3 + numpy

Make it yours

Skill packs make everyone look the same. These four edits are what make it your style.

Your coloursAsk Claude to add a world to eyes.md built from your brand palette, and to use it for your opening and ending.
Your faceRecord yourself against any background. Claude cuts you out and drops you into every world, so viewers learn your face, not a mascot.
Your worldsDescribe a look in plain words ("a rainy neon street", "a comic page"). Claude writes the spec into eyes.md and builds a painter for it.
Your rulesAfter every video, tell Claude what you liked and what you didn't. It goes into learnings.md, and the next reel starts smarter.

Every file

SKILL.mdThe brain. Tells Claude the five passes and the hard rules.
---
name: reel-director
description: Direct and build a short vertical video (Reel, TikTok, Short) end to end with Claude Code. Use when someone wants an animated or motion-graphics video made from a script or idea, with a world per scene, synced sound and captions, rendered to MP4.
---

# Reel Director

You are the director's assistant. The edit is the last 10 percent. The other 90 percent is a
written plan where every second already has a picture, a sound and a reason. Never open the
renderer before the plan is approved.

## The five passes

Work through these in order. Each pass ends with something the human can look at and approve.

1. **Brief.** Ask only what you cannot infer: the one idea the viewer must leave with, the
   call to action, who is on screen (a real person cut-out, an avatar, a mascot or nobody),
   the voice source (recorded take or text to speech), and the target length (default 25 to 40 s).
2. **Beat sheet.** Fill `references/script-template.md`. One row per spoken sentence: the line,
   its start time, the world it lives in, what moves, the on-screen words (3 max), and the sound.
   Show it as a table and wait for approval. This is the step that makes the video.
3. **Look.** Pick worlds from `references/eyes.md`. Rule of thumb: one world per sentence for
   high-energy edits, one world per idea for calmer ones. Render 3 to 5 stills at key beats
   (`scripts/render.mjs stills`) and show them before rendering motion.
4. **Build.** One HTML page per video that draws to a canvas and exposes `window.renderAt(t)`,
   `window.TOTAL` and `window.ready`. Time everything from the real voice word timings, never
   from guesses. Render with `scripts/render.mjs video`.
5. **Sound and export.** Follow `references/ears.md` to place cues, mix with `scripts/mix.py`,
   then mux and check against `references/export.md`.

## Hard rules

- Hooks and pacing come from `references/hooks.md`. Read it before writing the beat sheet.
- Captions run from the first spoken word to the last. Max 3 words at a time. The current word
  is highlighted. Captions never cover a face.
- Keep the platform safe zones clear of text (see `references/hooks.md`).
- Every scene change lands on a spoken word. Every on-screen word appears on the frame it is said.
- One character or presenter stays recognisable across every world. Change the world around
  them, not who they are.
- Max two typefaces on screen at once.

## The skill learns

After every video, add what worked and what failed to `references/learnings.md`: a rule that
worked becomes a "do", a fix the human asked for becomes a "never". Read that file before each
new beat sheet. This is how the skill gets better with every reel.

## Files

- `references/script-template.md` - the beat sheet format, with a filled example
- `references/eyes.md` - the world library: palette, type, camera, how text enters, transitions
- `references/ears.md` - sound design rules and cue timing
- `references/hooks.md` - first-seconds rules, pacing, captions, safe zones, CTA
- `references/export.md` - render and upload settings that keep quality on Instagram
- `references/learnings.md` - the growing do and never list
- `scripts/render.mjs` - renders the page to stills or MP4 with headless Chrome and ffmpeg
- `scripts/mix.py` - voice + sound cues + ducked music, loudness-normalised
- `worlds/` - ready-made world painters you can reuse in a page
references/script-template.mdThe beat sheet Claude fills before anything is built.
# Beat sheet template

Write this before anything is built. Times come from the real voice take (speech-to-text word
timings). Until a take exists, estimate 2.6 words per second and mark times with `~`.

## Header

- **One idea:** the single sentence the viewer should remember
- **Hook (0 to 1.5 s):** what is seen AND heard in the first second and a half
- **Presenter:** real cut-out / avatar / mascot / none
- **Length:** target seconds
- **CTA:** the comment keyword or action, and what they get
- **Ending frame:** what the last frame shows (it doubles as the loop point)

## Rows

| # | Start | Line (spoken) | World | Motion | On screen (max 3 words) | Sound |
|---|-------|---------------|-------|--------|-------------------------|-------|

Rules for filling rows:
- One row per spoken sentence. Split a sentence in two if it runs longer than 3 seconds.
- **World** names an entry in `eyes.md`. Do not repeat the same world in two rows in a row
  unless the idea is the same.
- **Motion** says what moves and when, tied to a word: "push-in 4% on *free*".
- **On screen** words are the punchline of the line, not a copy of the caption.
- **Sound** names the cue type from `ears.md` and the word it hits on.

## Filled example (10 seconds)

**One idea:** a written system beats re-prompting. **Hook:** presenter drops into a pixel
level with a hit on the first word. **CTA:** comment DIRECTOR.

| # | Start | Line | World | Motion | On screen | Sound |
|---|-------|------|-------|--------|-----------|-------|
| 1 | 0.00 | "Everyone asks how I make these." | Pixel level | Presenter lands, coins burst on *make* | HOW? | impact on *asks*, pop on *make* |
| 2 | 2.10 | "It isn't the prompt." | Papyrus | Hieroglyph frame wipes in on *isn't* | NOT THE PROMPT | whoosh before, tap on *prompt* |
| 3 | 3.60 | "It's a written plan Claude follows." | Blueprint | Lines draw on *plan*, push-in 3% | A PLAN | swipe, ticks while lines draw |
| 4 | 6.20 | "Comment DIRECTOR and it's yours." | Hologram | Keyword types on *DIRECTOR* | DIRECTOR | rising tone, chime at end |
references/eyes.mdThe world library: palette, type, camera and transitions for 12 looks.
# Eyes: the world library

Each world is a complete look: palette, type, camera, how text enters, and how you leave it.
The presenter stays the same in every world; only the world changes. Worlds marked
**(painter)** have ready code in `worlds/worlds.js`. The rest are specs to build from.

How to add a world: copy an entry, fill every field, build a painter, render one still,
and add it here only once it looks right at phone size.

---

### Pixel level (painter)
- **Palette:** sky #5C94FC, ground #C84C0C, brick shadow #8C2C00, cloud #FCFCFC, coin #F8B800
- **Type:** chunky pixel font or a heavy sans with hard 6 px drop shadow, all caps
- **Camera:** locked side view; ground scrolls left; presenter "lands" with a 2-frame squash
- **Text enters:** drops from the top in steps (no easing, 3 to 4 frame snaps), coin sparkle
- **Leave by:** pixel dissolve (blocks of 24 px switch to the next world in random order)
- **Sound:** 8-bit blips for pops, a coin chime on the key word

### Papyrus (painter)
- **Palette:** papyrus #E9D3A0, ink #2B1D0E, lapis #1F4E8C, carnelian #B5452B, gold #D4A437
- **Type:** serif italic for the key word, small caps sans for labels
- **Camera:** slow pan right along a painted wall, 2 to 3 percent push-in
- **Text enters:** painted on left to right with a brush-reveal mask, 0.3 s
- **Leave by:** the wall slides off as a scroll rolls up
- **Sound:** soft sand swipe, low drum hit

### Blueprint (painter)
- **Palette:** paper #0E3A6B, grid #2C5D93, line #EAF2FF, accent #FFD24A
- **Type:** mono for labels, condensed sans for the key word
- **Camera:** top-down, slight rotation drift (0.5 deg)
- **Text enters:** strokes draw on (line dash animation), then fill
- **Leave by:** grid lines race outward and wipe to the next world
- **Sound:** pencil ticks while lines draw, paper swipe out

### Hologram (painter)
- **Palette:** void #02070D, cyan #3BE8FF, teal #0FA3B1, white #E8FDFF
- **Type:** wide sans, tracked out 8 percent; mono for HUD labels
- **Camera:** slow orbit feel via parallax rings, scanlines, subtle flicker (2 percent)
- **Text enters:** glitch-in (3 frames horizontal offset) then stable glow
- **Leave by:** collapse to a horizontal line, then flash
- **Sound:** rising tone, digital shimmer, chime to close

### Night city
- **Palette:** asphalt #0B0B12, neon pink #FF3D7F, neon blue #3DA9FF, rain #9AA4B2
- **Type:** neon-tube script for the key word, sans for support
- **Camera:** low angle, rain streaks, reflections under the presenter
- **Text enters:** neon flicker on (on, off, on), hum
- **Leave by:** lights short out to black
- **Sound:** rain bed only in this scene, electric buzz on text

### Paper cut-out
- **Palette:** kraft #C9A27E, cream #F4EBDD, tomato #E2553B, ink #222
- **Type:** rounded heavy sans, slightly rotated per word
- **Camera:** flat, layers move at different speeds (parallax)
- **Text enters:** each word slaps in with a 5 deg rotation and a paper shadow
- **Leave by:** the top layer tears away
- **Sound:** paper rustle, soft slap

### Oil painting
- **Palette:** taken from a swirled sky: ultramarine, cadmium yellow, cobalt, ochre
- **Type:** brush serif
- **Camera:** brush strokes flow around the presenter (flow field), 3 percent push
- **Text enters:** painted stroke reveal
- **Leave by:** paint smears sideways
- **Sound:** wet brush swipe, cello note

### Stained glass
- **Palette:** lead #1A1A1A, ruby #A3162E, cobalt #1B3FA0, emerald #127A4A, amber #E6A21A
- **Type:** blackletter for a single title word only, sans for the rest
- **Camera:** light rays sweep across, dust in the beams
- **Text enters:** glass pieces light up behind the letters
- **Leave by:** the window shatters into tiles
- **Sound:** choir pad swell, glass tink

### Voxel room
- **Palette:** warm room, deep red #6B0F0F, wood #8A4B2A, lamp #FFE3A3
- **Type:** big 3D extruded sans placed on the wall in perspective
- **Camera:** isometric, slow dolly in
- **Text enters:** letters build from cubes
- **Leave by:** cubes fall away
- **Sound:** block clicks, room tone

### Terminal
- **Palette:** #0A0F0A, phosphor green #39FF88 or amber #FFB000
- **Type:** mono only
- **Camera:** flat, CRT curvature and scanlines
- **Text enters:** typed character by character with a cursor
- **Leave by:** screen powers off to a dot
- **Sound:** key clicks, power-down

### Comic panel
- **Palette:** CMYK primaries on cream with halftone dots
- **Type:** comic lettering, speech balloons, onomatopoeia
- **Camera:** panel to panel cuts, speed lines
- **Text enters:** balloon pops with an overshoot
- **Leave by:** page turn
- **Sound:** pow hits, page flip

### Real screen
- **Palette:** the product's own UI
- **Type:** brand sans of the account
- **Camera:** screen recording in a device frame, 4 percent push to the area that matters
- **Text enters:** highlight box draws around the UI element as it is named
- **Leave by:** device slides out
- **Sound:** soft clicks on each UI action
- **When:** any time a real tool, repo or page is named. Proof beats illustration.
references/ears.mdSound rules: where hits, whooshes and pops land, and how loud.
# Ears: sound design

Sound is half of why a fast edit feels expensive. Every cut that is seen should also be heard.

## Layers (top to bottom)

1. **Voice** is always on top and always intelligible. Clean it first: isolate the voice
   (for example with an audio isolation API), trim leading silence, cut breaths and pauses
   longer than about 0.35 s, then level it. Do not over-compress.
2. **Cues** (SFX) sit 8 to 14 dB under the voice peak.
3. **Music** sits about 30 dB under full scale and ducks a further 50 to 60 percent while the
   voice is speaking. It fades out over the last 1.2 s.

## Cue vocabulary

| Moment | Cue | Timing |
|--------|-----|--------|
| Hook / first word | impact or hit | the peak lands on the first stressed syllable |
| World change | whoosh or swipe | starts 0.25 to 0.3 s BEFORE the cut so the peak lands on it |
| Word pops on screen | soft pop or tap | on the frame the word appears |
| Things counting, typing, drawing | quick ticks, pitched up slightly each time | 0.05 to 0.15 s apart |
| Reveal or big claim | swell or riser into a hit | riser ends exactly on the word |
| Ending / CTA | a short chime or sting | on the last word, let it ring under the final frame |

## Rules

- Align a cue by its loudest point, not its start, unless it is a swipe or sting.
- Vary pitch by 3 to 10 percent when the same cue repeats, so it never sounds like a loop.
- No constant air or whoosh bed. Silence between cues is fine.
- Never put a cue on top of a word that carries meaning if it masks it.
- Master: about -15 LUFS integrated, true peak under -1.5 dBTP, 48 kHz.
references/hooks.mdWhat keeps people watching: first 3 seconds, pacing, captions, safe zones.
# Hooks: what keeps people watching

These rules follow Instagram's own published guidance for Reels (Creators account and
Instagram @creators posts) and how its ranking signals work: watch time, whether people watch
past the first few seconds, shares (sends) and saves, and original content.

## First 3 seconds

- Something moves in frame 1. No logo, no fade from black, no slow intro.
- The first spoken line states the payoff or the tension, not a greeting.
- Show and say the same thing: if the voice says "this", the screen shows "this".
- A text hook (max 6 words) can sit on screen for the first 1.5 to 2 s, then becomes captions.

## Pacing

- A visual change (cut, world, zoom, word pop) every 1.5 to 3 seconds.
- One idea per scene. If a scene needs two sentences of explanation, it is two scenes.
- Push-ins stay small (3 to 6 percent). Big zooms read as cheap.
- Text enters fast (0.2 to 0.35 s, ease-out) on the word it belongs to.

## Captions and text

- Burned-in captions from first word to last. Many people watch with the sound off.
- Max 3 words at a time, current word highlighted.
- Never place text over a face.

## Safe zones (1080 x 1920)

Keep text out of the top 220 px (profile and audio row), the bottom 380 px (caption, buttons)
and the right 140 px (like, comment and share buttons).

## Originality

- Instagram favours original content and limits reach for reposted or watermarked clips.
  Build every frame yourself, no other platform's watermark, no reused footage.
- Use your own presenter or character so the account becomes recognisable.

## Ending and CTA

- One CTA only. A comment keyword works because a comment is a strong signal and the DM
  delivers the reward.
- Say what they get ("the full skill, free") and make the keyword big and readable.
- End on a clean frame that loops naturally back into the first one.

## Length

- 20 to 45 seconds for explainers. Cut anything the viewer could miss without losing the idea.
references/export.mdRender and upload settings so Instagram keeps the quality.
# Export settings for Reels

Instagram re-encodes everything you upload. Give it a clean, high-bitrate master in the
format it expects, so its compression has the most to work with.

| Setting | Value |
|---------|-------|
| Frame | 1080 x 1920 (9:16) |
| Frame rate | 30 fps, constant |
| Video codec | H.264 (libx264), High profile, yuv420p |
| Quality | CRF 16 to 18 (roughly 12 to 25 Mbps for motion graphics) |
| Audio | AAC, 48 kHz, 320 kbps, stereo or mono |
| Loudness | about -15 LUFS, true peak under -1.5 dBTP |
| Container | MP4 with `+faststart` |
| Length | under 90 s for full Reels features |

## ffmpeg

```bash
ffmpeg -i video.mp4 -i final.wav -map 0:v -map 1:a \
  -c:v libx264 -profile:v high -preset slow -crf 17 -pix_fmt yuv420p -r 30 \
  -c:a aac -b:a 320k -ar 48000 -movflags +faststart -shortest out.mp4
```

## Before upload

- Watch it once on a phone, sound off, then once with sound.
- Check the first frame (it is the default cover) and the last frame (it is the loop point).
- Upload from the phone app or a scheduler over Wi-Fi. Turn on "upload at highest quality"
  in the Instagram app (Settings, Data usage and media quality).
- Thin lines and tiny text shimmer after Instagram's compression. Keep strokes 3 px or more
  and text 40 px or more.
references/learnings.mdThe do and never list that grows with every video.
# Learnings (grows with every video)

Read before writing a beat sheet. Add to it after every video.

## Do
- Time every cut and caption from the real voice word timings.
- Show real screens when a tool is named. Graphics alone feel monotone.
- Keep one presenter recognisable across every world.
- Trim leading silence so the first frame already speaks.

## Never
- Never leave a stretch of speech without captions.
- Never put text over the presenter's face.
- Never run a constant whoosh or air bed under the whole video.
- Never ship without watching it muted on a phone once.

## Log
| Date | Video | Rule added | Why |
|------|-------|------------|-----|
scripts/render.mjsTurns the HTML page into an MP4 with headless Chrome and ffmpeg.
// Render an animation page to stills or a video. Self-contained: it serves the page's folder itself, drives headless
// Chrome frame by frame (window.renderAt(t) on canvas #c) and pipes the frames to ffmpeg.
//
//   node render.mjs stills <page.html> <outDir> <t1> <t2> ...  [--gpu] [--root <dir>]
//   node render.mjs video  <page.html> <out.mp4> [--fps 24] [--scale 2] [--gpu] [--root <dir>] [--audio <file.wav>] [--alpha]
//   node render.mjs events <page.html> <out.json> [--gpu]   (writes the page's window.EVENTS: [{name, t}], for sound sync)
//
//   --gpu    real GPU (needed for WebGL / 3D pages; without it headless Chrome has no WebGL2)
//   --scale  2 = 4K (3840x2160) from a 1920x1080 page that reads ?scale=
//   --root   folder to serve (default: the page's own folder; use the project root if the page loads ../ files)
//   --alpha  ProRes 4444 .mov with transparency (the page must leave its background clear)
// Needs: Node 18+, ffmpeg on PATH, Google Chrome or Chromium (set CHROME=/path if it isn't found).
import { spawn } from 'node:child_process';
import { createServer } from 'node:http';
import { readFileSync, writeFileSync, mkdirSync, existsSync, statSync } from 'node:fs';
import { resolve, dirname, relative, extname, join, sep } from 'node:path';
import { tmpdir } from 'node:os';
import { setTimeout as wait } from 'node:timers/promises';

const argv = process.argv.slice(2), flag = n => { const i = argv.indexOf(n); if (i < 0) return null; const v = argv[i + 1]; argv.splice(i, 2); return v; };
const bool = n => { const i = argv.indexOf(n); if (i < 0) return false; argv.splice(i, 1); return true; };
const GPU = bool('--gpu'), ALPHA = bool('--alpha'), FPS = +(flag('--fps') || 24), SCALE = +(flag('--scale') || 2), ROOT0 = flag('--root'), AUDIO = flag('--audio');
const [mode, pageArg, out, ...rest] = argv;
if (!mode || !pageArg || !out) { console.log(readFileSync(new URL(import.meta.url)).toString().split('\n').slice(0, 14).join('\n')); process.exit(1); }
const page = resolve(pageArg), ROOT = resolve(ROOT0 || dirname(page)), rel = relative(ROOT, page).split(sep).join('/');

const CHROME = process.env.CHROME || ['/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/Applications/Chromium.app/Contents/MacOS/Chromium',
  'C:/Program Files/Google/Chrome/Application/chrome.exe', 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe', '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser'].find(p => existsSync(p));
if (!CHROME) { console.error('Chrome not found: set CHROME=/path/to/chrome'); process.exit(1); }

const TYPES = { '.html': 'text/html', '.js': 'text/javascript', '.mjs': 'text/javascript', '.css': 'text/css', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.svg': 'image/svg+xml',
  '.ttf': 'font/ttf', '.otf': 'font/otf', '.woff2': 'font/woff2', '.json': 'application/json', '.mp4': 'video/mp4', '.wav': 'audio/wav', '.glb': 'model/gltf-binary', '.gltf': 'model/gltf+json' };
const server = createServer((req, res) => {   // a tiny static server, so fonts / images / modules load like on a real site
  const p = join(ROOT, decodeURIComponent(req.url.split('?')[0]));
  if (!p.startsWith(ROOT) || !existsSync(p) || statSync(p).isDirectory()) { res.writeHead(404); return res.end(); }
  res.writeHead(200, { 'Content-Type': TYPES[extname(p).toLowerCase()] || 'application/octet-stream' }); res.end(readFileSync(p));
});
await new Promise(r => server.listen(0, '127.0.0.1', r)); const HTTP = `http://127.0.0.1:${server.address().port}`;

const port = 9300 + (process.pid % 600), prof = join(tmpdir(), `smad-chrome-${port}`);
const chrome = spawn(CHROME, ['--headless=new', ...(GPU ? ['--enable-gpu', ...(process.platform === 'darwin' ? ['--use-angle=metal'] : [])] : ['--disable-gpu']), '--hide-scrollbars', '--no-sandbox',
  `--remote-debugging-port=${port}`, `--user-data-dir=${prof}`, '--window-size=1920,1080', 'about:blank'], { stdio: 'ignore' });
let tg; for (let i = 0; i < 160 && !tg; i++) { try { tg = (await (await fetch(`http://127.0.0.1:${port}/json`)).json()).find(t => t.type === 'page'); } catch { await wait(250); } }
if (!tg) { console.error('Chrome did not start'); process.exit(1); }
const ws = new WebSocket(tg.webSocketDebuggerUrl); await new Promise(r => ws.onopen = r); let mid = 0; const pend = new Map();
ws.onmessage = e => { const m = JSON.parse(e.data); if (pend.has(m.id)) { pend.get(m.id)(m); pend.delete(m.id); } };
const send = (method, params = {}) => new Promise(r => { const i = ++mid; pend.set(i, r); ws.send(JSON.stringify({ id: i, method, params })); });
const ev = async x => { const m = await send('Runtime.evaluate', { expression: x, awaitPromise: true, returnByValue: true }); if (m.result?.exceptionDetails) throw new Error(JSON.stringify(m.result.exceptionDetails).slice(0, 500)); return m.result.result.value; };
const done = code => { try { ws.close(); } catch {} chrome.kill(); server.close(); process.exit(code); };

try {
  const sc = mode === 'stills' ? 1 : SCALE;
  await send('Page.navigate', { url: `${HTTP}/${rel}?t=0&scale=${sc}` });
  for (let i = 0; i < 80; i++) { await wait(400); if (await ev('typeof window.renderAt === "function" && typeof window.ready !== "undefined"')) break; }
  await ev('Promise.resolve(window.ready).then(() => true)');
  if (mode === 'events') { const evs = await ev('JSON.stringify(window.EVENTS || [])'); writeFileSync(out, evs); console.log(`${JSON.parse(evs).length} events -> ${out}`); done(0); }
  if (mode === 'stills') {
    mkdirSync(out, { recursive: true });
    for (const t of rest.map(Number)) { const b = await ev(`(async()=>{ await renderAt(${t}); return document.getElementById('c').toDataURL('image/jpeg', 0.88).split(',')[1]; })()`); writeFileSync(join(out, `${t.toFixed(2)}.jpg`), Buffer.from(b, 'base64')); }
    console.log(`stills -> ${out}`); done(0);
  }
  const total = await ev('window.TOTAL'), n = Math.round(total * FPS), t0 = Date.now();
  const venc = ALPHA ? ['-c:v', 'prores_ks', '-profile:v', '4444', '-pix_fmt', 'yuva444p10le', '-vendor', 'apl0'] : ['-c:v', 'libx264', '-preset', 'medium', '-crf', '16', '-pix_fmt', 'yuv420p', '-movflags', '+faststart'];
  const aud = AUDIO ? ['-i', AUDIO, '-map', '0:v', '-map', '1:a', ...(ALPHA ? ['-c:a', 'pcm_s16le'] : ['-c:a', 'aac', '-b:a', '320k'])] : [];
  mkdirSync(dirname(resolve(out)), { recursive: true });
  const ff = spawn('ffmpeg', ['-y', '-loglevel', 'error', '-f', 'image2pipe', '-framerate', String(FPS), '-c:v', ALPHA ? 'png' : 'mjpeg', '-i', '-', ...aud, ...venc, '-t', String(n / FPS), resolve(out)], { stdio: ['pipe', 'ignore', 'pipe'] });
  let err = ''; ff.stderr.on('data', d => err += d); const fin = new Promise((ok, no) => ff.on('close', c => c === 0 ? ok() : no(new Error(err || 'ffmpeg failed'))));
  const type = ALPHA ? "'image/png'" : "'image/jpeg', 0.95";
  for (let f = 0; f < n; f++) {
    const len = await ev(`(async () => { await renderAt(${f / FPS}); window.__f = document.getElementById('c').toDataURL(${type}).split(',')[1]; return window.__f.length; })()`);
    let b64 = ''; for (let o = 0; o < len; o += 4e6) b64 += await ev(`window.__f.slice(${o}, ${o + 4e6})`);
    if (!ff.stdin.write(Buffer.from(b64, 'base64'))) await new Promise(r => ff.stdin.once('drain', r));
    if (f % (FPS * 2) === 0) process.stdout.write(`\r${f}/${n} frames`);
  }
  ff.stdin.end(); await fin; console.log(`\nSAVED ${out} (${n} frames at ${FPS} fps, ${((Date.now() - t0) / 60000).toFixed(1)} min)`); done(0);
} catch (e) { console.error('FAILED:', e.message); done(1); }
scripts/mix.pyMixes voice, sound cues and ducked music to the right loudness.
# Voice + sound cues + ducked music -> final.wav  (about -15 LUFS, true peak under -1.5 dBTP)
#
#   python3 mix.py voice.wav cues.json music.mp3 TOTAL_SECONDS final.wav [sfx_dir]
#
# cues.json: [{"at": 1.23, "file": "whoosh.wav", "db": -28, "align": "peak"|"start", "pitch": 1.0}, ...]
#   align "peak" puts the loudest point of the cue on `at` (hits, pops); "start" starts it there (swipes, stings).
import json, sys, os, subprocess, wave, numpy as np
SR = 48000
voice_p, cues_p, music_p, total, out = sys.argv[1], sys.argv[2], sys.argv[3], float(sys.argv[4]), sys.argv[5]
sfx_dir = sys.argv[6] if len(sys.argv) > 6 else os.path.dirname(os.path.abspath(cues_p))

def load(path, pitch=1.0):
    af = f"aresample={SR}" + (f",asetrate={int(SR * pitch)},aresample={SR}" if pitch != 1 else "")
    return np.frombuffer(subprocess.check_output(['ffmpeg', '-v', 'error', '-i', path, '-af', af, '-ac', '1', '-f', 'f32le', '-']), np.float32).copy()

N = int(total * SR)
v = np.zeros(N, np.float32); x = load(voice_p); v[:min(N, len(x))] = x[:N]
sfx = np.zeros(N, np.float32)
for c in json.load(open(cues_p)):
    x = load(os.path.join(sfx_dir, c['file']), c.get('pitch', 1.0)); x = x / (np.abs(x).max() + 1e-9) * 10 ** (c['db'] / 20)
    off = int(np.argmax(np.abs(x))) if c.get('align', 'peak') == 'peak' else 0
    s = int(c['at'] * SR) - off; a, b = max(0, s), min(N, s + len(x))
    if b > a: sfx[a:b] += x[a - s:b - s]
m = load(music_p); m = np.tile(m, int(np.ceil(N / len(m))))[:N]; m = m / (np.sqrt(np.mean(m ** 2)) + 1e-9) * 10 ** (-30 / 20)
env = np.convolve(np.abs(v), np.ones(int(.08 * SR)) / int(.08 * SR), 'same')
m *= 1 - 0.6 * np.clip(env / 0.05, 0, 1)                      # duck under the voice
fl = int(1.2 * SR); m[-fl:] *= np.linspace(1, 0, fl)            # fade out
pre = out + '.pre.wav'
with wave.open(pre, 'wb') as w:
    w.setnchannels(1); w.setsampwidth(2); w.setframerate(SR); w.writeframes((np.clip(v + sfx + m, -1, 1) * 32767).astype(np.int16).tobytes())
subprocess.check_call(['ffmpeg', '-v', 'error', '-y', '-i', pre, '-af', 'alimiter=limit=0.6:level=false,loudnorm=I=-15:TP=-1.5:LRA=11', '-ar', '48000', out])
os.remove(pre); print('mixed ->', out)
worlds/worlds.jsReady-made worlds: pixel game, papyrus, blueprint, hologram.
// World painters for the reel-director skill. Each painter draws a full 1080x1920 background
// (and its own key text) for a moment in time. Pure canvas 2D, no libraries.
//   WORLDS.pixel(ctx, lt, opts)   lt = seconds since this world started
// opts.words: [{text, at}] key words to show (max 3 words each); opts.seed for variety.
(function () {
  const W = 1080, H = 1920;
  const ease = x => 1 - Math.pow(1 - Math.min(1, Math.max(0, x)), 3);
  const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x));
  const rnd = s => { let x = Math.sin(s * 127.1) * 43758.5453; return x - Math.floor(x); };
  const off = (w, h) => { const c = document.createElement('canvas'); c.width = w; c.height = h; return c; };
  const activeWord = (words, lt) => { let w = null; for (const x of words || []) if (lt >= x.at) w = x; return w; };

  // ---------- PIXEL LEVEL ----------
  const PX = 4, pw = W / PX, ph = H / PX, pbuf = off(pw, ph), pc = pbuf.getContext('2d');
  function block(c, x, y, s, fill, dark, light) {
    c.fillStyle = dark; c.fillRect(x, y, s, s); c.fillStyle = fill; c.fillRect(x, y, s - 1, s - 1);
    c.fillStyle = light; c.fillRect(x, y, s - 1, 1); c.fillRect(x, y, 1, s - 1);
  }
  function cloud(c, x, y, s) {
    c.fillStyle = '#FCFCFC';
    [[0, 4, 14, 6], [3, 1, 6, 4], [7, 0, 6, 5], [11, 2, 5, 4]].forEach(([a, b, w, h]) => c.fillRect(x + a * s, y + b * s, w * s, h * s));
    c.fillStyle = '#A4E4FC'; c.fillRect(x, y + 9 * s, 14 * s, s);
  }
  function hill(c, cx, base, r, col, dark) {
    for (let yy = -r; yy <= 0; yy++) { const hw = Math.round(Math.sqrt(r * r - yy * yy)); c.fillStyle = dark; c.fillRect(cx - hw - 1, base + yy, hw * 2 + 2, 1); c.fillStyle = col; c.fillRect(cx - hw, base + yy, hw * 2, 1); }
    c.fillStyle = dark; [[-r * .4, -r * .5], [r * .2, -r * .7], [r * .35, -r * .3]].forEach(([a, b]) => { c.fillRect(cx + a, base + b, 2, 4); });
  }
  function qblock(c, x, y, lt, hitAt) {
    const bump = hitAt != null && lt > hitAt && lt < hitAt + .2 ? -Math.round(Math.sin((lt - hitAt) / .2 * Math.PI) * 4) : 0;
    const used = hitAt != null && lt > hitAt;
    block(c, x, y + bump, 16, used ? '#C84C0C' : '#F8B800', '#000', used ? '#F0A070' : '#FCE0A8');
    if (!used) { c.fillStyle = '#C84C0C'; [[6, 3, 4, 2], [9, 5, 2, 3], [7, 8, 2, 2], [7, 11, 2, 2]].forEach(([a, b, w, h]) => c.fillRect(x + a, y + b + bump, w, h)); }
  }
  function pixelText(c, s, cx, y, size, col, lt0) {
    c.font = `${size}px Head`; c.textAlign = 'center'; c.textBaseline = 'alphabetic';
    // drop in, snapping in 4 steps (no easing: pixel worlds move in frames)
    const step = Math.min(4, Math.floor(lt0 / .045)), dy = (4 - step) * -14;
    c.fillStyle = '#000'; c.fillText(s, cx + 2, y + dy + 2); c.fillStyle = col; c.fillText(s, cx, y + dy);
  }
  function pixel(ctx, lt, o = {}) {
    const c = pc; c.imageSmoothingEnabled = false;
    c.fillStyle = '#5C94FC'; c.fillRect(0, 0, pw, ph);
    const scroll = Math.floor(lt * 22);
    for (let i = 0; i < 3; i++) cloud(c, ((i * 110 + 20 - Math.floor(lt * 6)) % 330 + 330) % 330 - 40, 70 + i * 22 + (i % 2) * 10, 2);
    hill(c, ((60 - scroll * .5) % 360 + 360) % 360 - 40, ph - 64, 46, '#00A800', '#005800');
    hill(c, ((230 - scroll * .5) % 360 + 360) % 360 - 40, ph - 64, 30, '#00A800', '#005800');
    for (let x = -16; x < pw + 16; x += 16) for (let r = 0; r < 4; r++) block(c, x - (scroll % 16), ph - 64 + r * 16, 16, '#C84C0C', '#000', '#FCBCB0');
    // question blocks row
    const hit = o.coinAt;
    for (let i = 0; i < 5; i++) { const x = 47 + i * 36; if (i % 2) block(c, x, 150, 16, '#C84C0C', '#000', '#FCBCB0'); else qblock(c, x, 150, lt, hit != null ? hit + i * .06 : null); }
    if (hit != null && lt > hit) for (let i = 0; i < 3; i++) { const k = lt - hit - i * .06; if (k > 0 && k < .55) { const y = 140 - Math.sin(k / .55 * Math.PI) * 46, x = 55 + i * 72; c.fillStyle = '#000'; c.fillRect(x - 1, y - 1, 8, 12); c.fillStyle = '#F8B800'; c.fillRect(x, y, 6, 10); c.fillStyle = '#FCFCFC'; c.fillRect(x + 2, y + 2, 2, 6); } }
    const w = activeWord(o.words, lt); if (w) pixelText(c, w.text, pw / 2, 112, w.size || 34, '#FCFCFC', lt - w.at);
    // HUD
    c.font = '9px Mono'; c.textAlign = 'left'; c.fillStyle = '#FCFCFC'; c.fillText('MB', 34, 64); c.fillText('WORLD 1-1', pw - 110, 64);
    c.fillText(String(Math.floor(lt * 37)).padStart(6, '0'), 34, 74);
    ctx.imageSmoothingEnabled = false; ctx.drawImage(pbuf, 0, 0, W, H); ctx.imageSmoothingEnabled = true;
  }

  // ---------- PAPYRUS ----------
  let papTex = null;
  function papyrusTexture() {
    const t = off(W + 400, H), c = t.getContext('2d');
    c.fillStyle = '#E6CF9A'; c.fillRect(0, 0, t.width, H);
    for (let i = 0; i < 2600; i++) { c.fillStyle = `rgba(${120 + rnd(i) * 60},${90 + rnd(i + 1) * 40},40,${.03 + rnd(i + 2) * .05})`; c.fillRect(rnd(i + 3) * t.width, rnd(i + 4) * H, 2 + rnd(i + 5) * 260, 1 + rnd(i + 6) * 2); }
    for (let i = 0; i < 900; i++) { c.fillStyle = `rgba(90,60,20,${.04 + rnd(i + 9) * .05})`; c.fillRect(rnd(i + 7) * t.width, rnd(i + 8) * H, 1 + rnd(i) * 2, 6 + rnd(i + 1) * 120); }
    const band = (y) => { for (let x = 0; x < t.width; x += 48) { c.fillStyle = ['#1F4E8C', '#D4A437', '#B5452B', '#D4A437'][(x / 48) % 4]; c.fillRect(x + 3, y, 42, 26); c.fillStyle = '#2B1D0E'; c.fillRect(x, y, 3, 26); } c.fillStyle = '#2B1D0E'; c.fillRect(0, y - 4, t.width, 4); c.fillRect(0, y + 26, t.width, 4); };
    band(150); band(1720);
    c.strokeStyle = '#2B1D0E'; c.fillStyle = '#2B1D0E'; c.lineWidth = 7; c.lineCap = 'round'; c.lineJoin = 'round';
    const glyphs = [
      (x, y) => { c.beginPath(); c.ellipse(x, y + 18, 34, 18, 0, 0, 7); c.stroke(); c.beginPath(); c.arc(x, y + 18, 9, 0, 7); c.fill(); c.beginPath(); c.moveTo(x - 6, y + 36); c.lineTo(x - 14, y + 70); c.moveTo(x + 6, y + 36); c.quadraticCurveTo(x + 10, y + 70, x + 30, y + 64); c.stroke(); },
      (x, y) => { c.beginPath(); c.ellipse(x, y + 16, 16, 20, 0, 0, 7); c.stroke(); c.beginPath(); c.moveTo(x, y + 36); c.lineTo(x, y + 90); c.moveTo(x - 26, y + 50); c.lineTo(x + 26, y + 50); c.stroke(); },
      (x, y) => { for (let k = 0; k < 3; k++) { c.beginPath(); for (let i = 0; i <= 6; i++) c.lineTo(x - 36 + i * 12, y + 20 + k * 22 + (i % 2 ? -8 : 0)); c.stroke(); } },
      (x, y) => { c.beginPath(); c.moveTo(x - 30, y + 80); c.quadraticCurveTo(x - 20, y + 20, x + 4, y + 16); c.quadraticCurveTo(x + 22, y + 4, x + 30, y + 18); c.lineTo(x + 14, y + 24); c.quadraticCurveTo(x + 18, y + 60, x - 4, y + 80); c.closePath(); c.fill(); c.beginPath(); c.moveTo(x - 10, y + 80); c.lineTo(x - 14, y + 96); c.moveTo(x + 2, y + 80); c.lineTo(x + 6, y + 96); c.stroke(); },
      (x, y) => { c.beginPath(); c.arc(x, y + 40, 26, 0, 7); c.stroke(); c.beginPath(); c.arc(x, y + 40, 7, 0, 7); c.fill(); },
      (x, y) => { c.fillRect(x - 34, y + 30, 68, 14); c.fillRect(x - 6, y + 4, 12, 70); },
    ];
    for (let col = 0; col < 10; col++) { const x = 60 + col * 150; c.fillStyle = 'rgba(43,29,14,.85)'; c.fillRect(x + 48, 210, 3, 1490); c.fillStyle = '#2B1D0E'; for (let r = 0; r < 11; r++) glyphs[(col * 3 + r * 5) % glyphs.length](x, 230 + r * 132); }
    // soften glyphs into the paper
    c.globalCompositeOperation = 'multiply'; c.fillStyle = 'rgba(233,211,160,.62)'; c.fillRect(0, 0, t.width, H); c.globalCompositeOperation = 'source-over';
    return t;
  }
  function papyrus(ctx, lt, o = {}) {
    if (!papTex) papTex = papyrusTexture();
    const pan = Math.min(400, lt * 60);
    ctx.drawImage(papTex, -pan, 0);
    // sun disk behind the presenter's head
    const g = ctx.createRadialGradient(540, 900, 40, 540, 900, 460); g.addColorStop(0, 'rgba(240,190,70,.95)'); g.addColorStop(.55, 'rgba(212,164,55,.75)'); g.addColorStop(1, 'rgba(212,164,55,0)');
    ctx.fillStyle = g; ctx.beginPath(); ctx.arc(540, 900, 460, 0, 7); ctx.fill();
    ctx.save(); ctx.translate(540, 900); ctx.rotate(lt * .08); ctx.strokeStyle = 'rgba(181,69,43,.55)'; ctx.lineWidth = 6;
    for (let i = 0; i < 24; i++) { ctx.rotate(Math.PI / 12); ctx.beginPath(); ctx.moveTo(300, 0); ctx.lineTo(380, 0); ctx.stroke(); } ctx.restore();
    // vignette
    const v = ctx.createRadialGradient(540, 960, 500, 540, 960, 1250); v.addColorStop(0, 'rgba(60,30,5,0)'); v.addColorStop(1, 'rgba(60,30,5,.55)'); ctx.fillStyle = v; ctx.fillRect(0, 0, W, H);
    const w = activeWord(o.words, lt);
    if (w) {
      const k = clamp((lt - w.at) / .32);
      ctx.save(); ctx.font = `${w.size || 210}px Serif`; ctx.textAlign = 'center'; const tw = ctx.measureText(w.text).width;
      const ck = ease(clamp((lt - w.at + .15) / .3)); ctx.fillStyle = 'rgba(240,222,176,.96)'; ctx.strokeStyle = '#D4A437'; ctx.lineWidth = 10;
      ctx.beginPath(); ctx.roundRect(540 - (tw / 2 + 60) * ck, 270, (tw + 120) * ck, 230, 115); ctx.fill(); ctx.stroke();
      ctx.strokeStyle = '#2B1D0E'; ctx.lineWidth = 4; ctx.beginPath(); ctx.roundRect(540 - (tw / 2 + 44) * ck, 286, (tw + 88) * ck, 198, 99); ctx.stroke();
      ctx.beginPath(); ctx.rect(540 - tw / 2 - 20, 0, (tw + 40) * ease(k), H); ctx.clip();
      ctx.fillStyle = 'rgba(43,29,14,.25)'; ctx.fillText(w.text, 546, 446); ctx.fillStyle = w.color || '#1F4E8C'; ctx.fillText(w.text, 540, 440); ctx.restore();
    }
    for (const s of o.stamps || []) if (lt >= s.at) {
      const k = clamp((lt - s.at) / .22), sc = 1.6 - .6 * ease(k);
      ctx.save(); ctx.translate(s.x || 860, s.y || 600); ctx.rotate(-.18); ctx.scale(sc, sc); ctx.globalAlpha = clamp(k * 2);
      ctx.strokeStyle = '#B5452B'; ctx.lineWidth = 9; ctx.beginPath(); ctx.ellipse(0, 0, 150, 70, 0, 0, 7); ctx.stroke();
      ctx.fillStyle = '#B5452B'; ctx.font = '84px Head'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.fillText(s.text, 0, 4); ctx.restore();
    }
  }

  // ---------- BLUEPRINT ----------
  function blueprint(ctx, lt, o = {}) {
    ctx.save(); ctx.translate(540, 960); ctx.rotate(Math.sin(lt * .6) * .006); ctx.translate(-540, -960);
    ctx.fillStyle = '#0E3A6B'; ctx.fillRect(-60, -60, W + 120, H + 120);
    for (let x = -60; x < W + 60; x += 30) { ctx.fillStyle = x % 150 === 0 ? 'rgba(120,170,230,.32)' : 'rgba(120,170,230,.13)'; ctx.fillRect(x, -60, 2, H + 120); }
    for (let y = -60; y < H + 60; y += 30) { ctx.fillStyle = y % 150 === 0 ? 'rgba(120,170,230,.32)' : 'rgba(120,170,230,.13)'; ctx.fillRect(-60, y, W + 120, 2); }
    if (o.diagram === false) { ctx.restore(); return; }
    // drawn diagram: a plug travels into a socket labelled with the target
    ctx.translate(0, -20);
    const draw = clamp((lt - (o.drawAt || 0)) / .9), plugIn = ease(clamp((lt - (o.plugAt || .6)) / .45));
    ctx.strokeStyle = '#EAF2FF'; ctx.lineWidth = 6; ctx.lineCap = 'round'; ctx.lineJoin = 'round';
    const dash = (len, f) => { ctx.setLineDash([len * f, len]); };
    // socket box (right)
    dash(1400, draw); ctx.strokeRect(640, 300, 330, 260); ctx.setLineDash([]);
    ctx.font = '30px Mono'; ctx.fillStyle = `rgba(234,242,255,${draw})`; ctx.textAlign = 'left'; ctx.fillText(o.socket || 'CLAUDE', 668, 350);
    ctx.fillText('INPUT', 668, 532);
    for (let i = 0; i < 2; i++) { ctx.fillStyle = `rgba(234,242,255,${draw})`; ctx.fillRect(640 - 4, 400 + i * 60, 10, 30); }
    // plug (left), slides right
    const px = 120 + plugIn * 190;
    dash(900, draw); ctx.strokeRect(px, 370, 210, 150); ctx.setLineDash([]);
    for (let i = 0; i < 2; i++) { ctx.beginPath(); ctx.moveTo(px + 210, 410 + i * 60); ctx.lineTo(px + 300, 410 + i * 60); ctx.stroke(); }
    ctx.beginPath(); ctx.moveTo(px, 445); ctx.bezierCurveTo(px - 120, 445, 20, 600, -40, 640); ctx.stroke();
    ctx.fillStyle = `rgba(234,242,255,${draw})`; ctx.fillText(o.plug || 'ASTRYX', px + 24, 455);
    // dimension line + label
    ctx.strokeStyle = '#FFD24A'; ctx.lineWidth = 4; dash(700, clamp(draw * 1.2 - .2)); ctx.beginPath(); ctx.moveTo(120, 620); ctx.lineTo(970, 620); ctx.stroke(); ctx.setLineDash([]);
    if (plugIn >= 1) { ctx.fillStyle = '#FFD24A'; ctx.beginPath(); ctx.arc(640, 445, 16 + Math.sin(lt * 12) * 3, 0, 7); ctx.fill(); }
    ctx.restore();
    const w = activeWord(o.words, lt);
    if (w) { const k = ease(clamp((lt - w.at) / .28)); ctx.save(); ctx.globalAlpha = k; ctx.font = `${w.size || 120}px Head`; ctx.textAlign = 'center'; ctx.fillStyle = '#FFD24A'; ctx.fillText(w.text, 540, 760 - (1 - k) * 30); ctx.restore(); }
  }

  // ---------- HOLOGRAM ----------
  function hologram(ctx, lt, o = {}) {
    ctx.fillStyle = '#02070D'; ctx.fillRect(0, 0, W, H);
    const g = ctx.createRadialGradient(540, 1500, 50, 540, 1500, 900); g.addColorStop(0, 'rgba(15,163,177,.45)'); g.addColorStop(1, 'rgba(15,163,177,0)'); ctx.fillStyle = g; ctx.fillRect(0, 0, W, H);
    // perspective floor grid
    ctx.strokeStyle = 'rgba(59,232,255,.35)'; ctx.lineWidth = 2;
    for (let i = -12; i <= 12; i++) { ctx.beginPath(); ctx.moveTo(540 + i * 30, 1180); ctx.lineTo(540 + i * 260, H); ctx.stroke(); }
    for (let k = 0; k < 14; k++) { const z = ((k + lt * 1.5) % 14) / 14, y = 1180 + Math.pow(z, 2.2) * 760; ctx.globalAlpha = z; ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(W, y); ctx.stroke(); } ctx.globalAlpha = 1;
    // rings
    for (let i = 0; i < 4; i++) { ctx.strokeStyle = `rgba(59,232,255,${.55 - i * .1})`; ctx.lineWidth = 4 - i * .6; ctx.beginPath(); ctx.ellipse(540, 1560, 300 + i * 90, 60 + i * 20, 0, lt * (i % 2 ? 1 : -1) * .8, lt * (i % 2 ? 1 : -1) * .8 + Math.PI * 1.6); ctx.stroke(); }
    // HUD labels
    ctx.font = '26px Mono'; ctx.fillStyle = 'rgba(232,253,255,.75)'; ctx.textAlign = 'left';
    ctx.fillText('SIGNAL  ' + (98 + Math.floor(Math.sin(lt * 5) * 1.5)) + '%', 60, 300); ctx.fillText('MODE    DIRECTOR', 60, 340);
    ctx.textAlign = 'right'; ctx.fillText('REC ' + lt.toFixed(2), 1020, 300);
    if (Math.floor(lt * 2) % 2 === 0) { ctx.fillStyle = '#FF3D5A'; ctx.beginPath(); ctx.arc(860, 291, 9, 0, 7); ctx.fill(); }
    const w = activeWord(o.words, lt);
    if (w) {
      const k = lt - w.at, jit = k < .1 ? (rnd(Math.floor(k * 60)) - .5) * 40 : 0;
      ctx.save(); ctx.font = `${w.size || 150}px Head`; ctx.textAlign = 'center'; ctx.letterSpacing = '12px';
      ctx.shadowColor = '#3BE8FF'; ctx.shadowBlur = 40; ctx.fillStyle = '#E8FDFF'; ctx.globalAlpha = clamp(k / .1);
      ctx.fillText(w.text, 540 + jit, 470); ctx.restore(); ctx.letterSpacing = '0px';
    }
  }
  // turns a presenter cut-out into a hologram (draw this instead of the normal presenter)
  const hbuf = off(W, H), hc = hbuf.getContext('2d');
  function holoPresenter(ctx, img, x, y, w, h, lt) {
    hc.clearRect(0, 0, W, H); hc.filter = 'grayscale(1) brightness(1.25) contrast(1.15)'; hc.drawImage(img, x, y, w, h); hc.filter = 'none';
    hc.globalCompositeOperation = 'source-atop'; hc.fillStyle = 'rgba(40,220,255,.55)'; hc.globalCompositeOperation = 'multiply'; hc.fillRect(0, 0, W, H);
    hc.globalCompositeOperation = 'destination-in'; hc.filter = 'none'; hc.drawImage(img, x, y, w, h);
    hc.globalCompositeOperation = 'destination-out'; for (let yy = 0; yy < H; yy += 6) { hc.fillStyle = 'rgba(0,0,0,.38)'; hc.fillRect(0, yy, W, 2); }
    const band = ((lt * 520) % (H + 300)) - 150; hc.globalCompositeOperation = 'source-atop'; hc.fillStyle = 'rgba(200,255,255,.35)'; hc.fillRect(0, band, W, 40);
    hc.globalCompositeOperation = 'source-over';
    ctx.save(); ctx.globalAlpha = .55; ctx.filter = 'blur(18px)'; ctx.globalCompositeOperation = 'lighter'; ctx.drawImage(hbuf, 0, 0); ctx.restore();
    ctx.save(); ctx.globalAlpha = .92 + Math.sin(lt * 31) * .04; const jit = rnd(Math.floor(lt * 12)) > .93 ? 10 : 0; ctx.drawImage(hbuf, jit, 0); ctx.restore();
  }

  // pixel dissolve between two finished frames (a, b are canvases), f = 0..1
  function dissolve(ctx, a, b, f, cell = 36) {
    ctx.drawImage(a, 0, 0);
    for (let y = 0, i = 0; y < H; y += cell) for (let x = 0; x < W; x += cell, i++) if (rnd(i + .5) < f) ctx.drawImage(b, x, y, cell, cell, x, y, cell, cell);
  }

  window.WORLDS = { pixel, papyrus, blueprint, hologram, holoPresenter, dissolve };
})();
PART OF WICK ACADEMY - FROM THE @AI.WITHMB SERIES
© 2026 THE WICK FIRM - PRIVACY · TERMS @AI.WITHMB · GUIDES · ACADEMY