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.

gate step 5, 3D CHECKS: grips, contact, paths on sampled frames (red fixture fixtureRigBrokenGrip, green threeRigDemo); still --grips crop boards; Nib faces camera at f96

Alex Greenshpun18faf063478e
diff --git a/skills/anidoodle/engine/src/canvas-core/fixtureRigBrokenGrip.ts b/skills/anidoodle/engine/src/canvas-core/fixtureRigBrokenGrip.ts
new file mode 100644
index 0000000..e891a84
--- /dev/null
+++ b/skills/anidoodle/engine/src/canvas-core/fixtureRigBrokenGrip.ts
@@ -0,0 +1,3 @@
+// TEST FIXTURE, not a film: threeRigDemo with the lantern pushed through Nib's jaws. tools/gate.mjs
+// (5. 3D CHECKS) must FAIL it; it proves the gate step can go red. Built in threeRigDemo.ts.
+export { fixtureRigBrokenGrip } from "./threeRigDemo";
diff --git a/skills/anidoodle/engine/src/canvas-core/threeRigDemo.ts b/skills/anidoodle/engine/src/canvas-core/threeRigDemo.ts
index 7fefa37..e55abb0 100644
--- a/skills/anidoodle/engine/src/canvas-core/threeRigDemo.ts
+++ b/skills/anidoodle/engine/src/canvas-core/threeRigDemo.ts
@@ -230,17 +230,23 @@ export const rigDemoFrame = (env: Env, f: number, variant: Variant = "clean") =>
return { ...B, hand };
};
// the camera keeps Nib a little left of centre while walking, then settles on the reach and pushes in
-const camTarget = (f: number) => v3(lerp(rootAt(f, "clean").x + 0.3, 0.2, tween(f, 64, 118)), lerp(0.72, 0.8, tween(f, 90, 160)), lerp(0.05, -0.02, tween(f, 64, 118)));
-const cameraAt = (f: number, _b?: Built) => { const t = camTarget(f), k = ease.inOutCubic(seg(f, 30, 170)); return t.add(v3(lerp(1.45, 1.35, k), lerp(0.5, 0.4, k), lerp(3.3, 3.0, k))); };
+const camTarget = (f: number) => v3(lerp(rootAt(f, "clean").x + 0.3, 0.2, tween(f, 64, 118)), lerp(0.72, 0.68, tween(f, 70, 110)) + 0.04 * tween(f, 120, 170), lerp(0.05, -0.02, tween(f, 64, 118)));
+// a side-on three-quarter for the walk, an arc round toward Nib's front for the reach (so its face reads
+// while it looks at the lantern on its far side), then a push in for the look and the wave
+const CAM_A = v3(1.45, 0.5, 3.3), CAM_B = v3(3.1, 0.6, 2.3), CAM_C = v3(2.85, 0.5, 2.45);
+const cameraAt = (f: number, _b?: Built) => { const t = camTarget(f), a = ease.inOutSine(seg(f, 46, 134)), b = ease.inOutCubic(seg(f, 128, 176)); return t.add(CAM_A.clone().lerp(CAM_B, a).lerp(CAM_C, b)); };
// ---------------------------------------------------------------- the film
-const shot = (ctx: Ctx, f: number, env: Env) => {
- const s = rigDemoFrame(env, f);
+const shotFor = (variant: Variant) => (ctx: Ctx, f: number, env: Env) => {
+ const s = rigDemoFrame(env, f, variant);
if (checking()) runChecks(f, s.cam, env); else resetChecks();
draw3d(ctx, env, s.scene, s.cam, { clear: "#e9e1d4", shadows: true });
};
-export const threeRigDemo: Film = {
- meta: { title: "three rig demo", W, H, fps: FPS, bpm: 120, durationFrames: N, kind: "story", poster: 150 },
+const filmOf = (title: string, variant: Variant): Film => ({
+ meta: { title, W, H, fps: FPS, bpm: 120, durationFrames: N, kind: "story", poster: 150 },
assets: { images: {} },
- shots: [{ id: "nib", start: 0, end: N, draw: shot }],
-};
+ shots: [{ id: "nib", start: 0, end: N, draw: shotFor(variant) }],
+});
+export const threeRigDemo = filmOf("three rig demo", "clean");
+/** TEST FIXTURE, not a film: the demo with the lantern shifted through Nib's jaws. The gate's 3D CHECKS must FAIL it. */
+export const fixtureRigBrokenGrip = filmOf("fixture: broken grip", "offset");
diff --git a/skills/anidoodle/engine/src/hosts/page-fixtureRigBrokenGrip.ts b/skills/anidoodle/engine/src/hosts/page-fixtureRigBrokenGrip.ts
new file mode 100644
index 0000000..a4747bf
--- /dev/null
+++ b/skills/anidoodle/engine/src/hosts/page-fixtureRigBrokenGrip.ts
@@ -0,0 +1,5 @@
+// TEST FIXTURE for tools/gate.mjs (3D CHECKS): the rig demo with its lantern pushed through the jaws.
+import { fixtureRigBrokenGrip } from "../canvas-core/fixtureRigBrokenGrip";
+import { mountFilm } from "./page";
+
+mountFilm(fixtureRigBrokenGrip);
diff --git a/skills/anidoodle/engine/src/hosts/page.ts b/skills/anidoodle/engine/src/hosts/page.ts
index 3d3a6b0..abf30a9 100644
--- a/skills/anidoodle/engine/src/hosts/page.ts
+++ b/skills/anidoodle/engine/src/hosts/page.ts
@@ -156,6 +156,16 @@ export const mountFilm = (film: Film) => {
} finally { protos.forEach((p, i) => (p.fillText = orig[i] as never)); delete g.__ANIDOODLE_PROBE__; }
return out;
};
+ // 3D CHECKS (tools/gate.mjs, still.mjs --grips). Turns three-core/checks3d.ts on, draws each frame asked
+ // and returns what every frame's runChecks found, plus where its grips sit on screen (logical px).
+ // A frame whose film never calls runChecks returns no record. Off by default: no hook, no cost.
+ type Check3D = { frame: number; findings: { frame: number; kind: string; where: string; detail: string }[]; grips: { name: string; x: number; y: number }[] };
+ const checks3d = (frames: number[]) => {
+ const out: Check3D[] = [], g = globalThis as { __ANIDOODLE_CHECK3D__?: (frame: number, findings: Check3D["findings"], info?: { grips: Check3D["grips"] }) => void };
+ g.__ANIDOODLE_CHECK3D__ = (frame, findings, info) => { out.push({ frame, findings, grips: info?.grips ?? [] }); };
+ try { for (const f of frames) seek(f); } finally { delete g.__ANIDOODLE_CHECK3D__; }
+ return out;
+ };
const audio = (sr: number) => { if (!filmSound) return null; const [L, R] = filmSound(sr); if (L.length !== R.length) throw new Error("audio channels have different lengths"); const pcm = new Float32Array(L.length * 2); for (let i = 0; i < L.length; i++) { pcm[i * 2] = L[i]; pcm[i * 2 + 1] = R[i]; } return { sampleRate: sr, frames: L.length, float32: b64(new Uint8Array(pcm.buffer)) }; };
const warm = () => film.shots.forEach((s) => { seek(s.start); seek(s.start + ((s.end - s.start) >> 1)); }); // first + middle frame of every shot: builds tiles, pre-allocates the layer pool
// POSTER. Platforms show frame 0 as the thumbnail, so a delivery may open on a chosen frame (the
@@ -177,7 +187,7 @@ export const mountFilm = (film: Film) => {
if (u > 0 && posterOf) { ctx.save(); ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.globalAlpha = Math.min(1, u); ctx.globalCompositeOperation = "source-over"; if (u >= 1) ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.drawImage(posterOf.img, 0, 0); ctx.restore(); }
current = n; return r;
};
- window.FILM = { probe, meta: { ...film.meta, hasAudio: typeof film.audio === "function", shots: film.shots.map(({ id, start, end }) => ({ id, start, end })) }, ready, mount, seek, hash, audio, warm, blur, poster, bakes: { load: bakes.load, take: bakes.take, hashes: bakes.hashes, stats: () => bakes.stats }, png: () => canvas.toDataURL("image/png").slice(22), frame: () => current };
+ window.FILM = { probe, checks3d, meta: { ...film.meta, hasAudio: typeof film.audio === "function", shots: film.shots.map(({ id, start, end }) => ({ id, start, end })) }, ready, mount, seek, hash, audio, warm, blur, poster, bakes: { load: bakes.load, take: bakes.take, hashes: bakes.hashes, stats: () => bakes.stats }, png: () => canvas.toDataURL("image/png").slice(22), frame: () => current };
// ---- the player: click or space to play, arrows to step, ?frame=N to open on a frame
ready.then(() => {
diff --git a/skills/anidoodle/engine/src/three-core/checks3d.ts b/skills/anidoodle/engine/src/three-core/checks3d.ts
index 63d29d2..896f179 100644
--- a/skills/anidoodle/engine/src/three-core/checks3d.ts
+++ b/skills/anidoodle/engine/src/three-core/checks3d.ts
@@ -315,7 +315,9 @@ export const screenSizeOk = (object: Obj, camera: THREE.Camera, env: { W: number
// at the start of every draw (resetChecks) and at the end of every run, so no frame sees another's.
type Reg = { rigs: { name: string; obj: Obj; rig?: Rig }[]; grips: { holder: Rig | Obj; hand: Limb | Obj; prop: Obj; o: GripOpts }[]; labels: Label[]; sizes: { obj: Obj; minPx: number }[]; paths: { path: PathSpec; props: PropBox[] }[] };
let REG: Reg = { rigs: [], grips: [], labels: [], sizes: [], paths: [] };
-const G = globalThis as { __ANIDOODLE_CHECK3D__?: (frame: number, findings: Finding[]) => void };
+/** What a host learns besides the findings: each registered grip's point on screen (logical px), for crop boards and for sampling contact windows. */
+export type CheckInfo = { grips: { name: string; x: number; y: number }[] };
+const G = globalThis as { __ANIDOODLE_CHECK3D__?: (frame: number, findings: Finding[], info: CheckInfo) => void };
/** True while a host or a test is collecting 3D findings. Draws skip the checks otherwise: no cost. */
export const checking = () => typeof G.__ANIDOODLE_CHECK3D__ === "function";
export const resetChecks = () => { REG = { rigs: [], grips: [], labels: [], sizes: [], paths: [] }; };
@@ -346,8 +348,9 @@ export const runChecks = (frame: number, camera: THREE.Camera, env: { W: number;
for (const l of REG.labels) F.push(...labelVisible(l, camera, REG.rigs.map((r) => r.obj), frame).findings);
for (const s of REG.sizes) F.push(...screenSizeOk(s.obj, camera, env, s.minPx, frame).findings);
for (const p of REG.paths) F.push(...pathClear({ ...p.path, from: frame, to: frame }, p.props).findings.map((x) => ({ ...x, frame })));
+ const info: CheckInfo = { grips: REG.grips.map((g) => { const q = gripFrame(g.hand).point.project(camera); return { name: `${objOf(g.holder).name || "holder"}/${g.prop.name || "prop"}`, x: ((q.x + 1) / 2) * env.W, y: ((1 - q.y) / 2) * env.H }; }) };
resetChecks();
- if (checking()) G.__ANIDOODLE_CHECK3D__!(frame, F);
+ if (checking()) G.__ANIDOODLE_CHECK3D__!(frame, F, info);
return result(F);
};
/** Collect the findings of everything `run` draws (a test, a host's check pass). */
diff --git a/skills/anidoodle/engine/test/threeChecks.test.ts b/skills/anidoodle/engine/test/threeChecks.test.ts
index 9443b88..57e00c3 100644
--- a/skills/anidoodle/engine/test/threeChecks.test.ts
+++ b/skills/anidoodle/engine/test/threeChecks.test.ts
@@ -3,7 +3,7 @@
// (lesson 44). Then the demo film: all 192 frames clean, and two broken variants that must fail.
// node tools/test.mjs threeChecks
import * as THREE from "three";
-import { grip, handle, limb, makeRig, part, pose, type Rig } from "../src/three-core/rig";
+import { grip, gripFrame, handle, limb, makeRig, part, pose, type Rig } from "../src/three-core/rig";
import { checkGrip, checking, collectChecks, labelVisible, pathClear, placeLabel, faceCamera, proximity, registerGrip, registerRig, runChecks, screenSizeOk, selfClear, type Finding } from "../src/three-core/checks3d";
import { rigDemoFrame } from "../src/canvas-core/threeRigDemo";
@@ -173,6 +173,13 @@ export const run = (ok: (cond: boolean, label: string) => void) => {
const got = collectChecks(() => { registerRig("h", h); registerRig("lantern", p); registerGrip(h, h.limbs["arms.right"], p); runChecks(42, cam, ENV); });
ok(got.length > 0 && got.every((x) => x.frame === 42) && got.some((x) => x.kind === "grip-gap"), `collectChecks receives the frame's findings (${got.length}, all on frame 42)`);
ok(!checking() && runChecks(43, cam, ENV).ok, "the registry is cleared after a run: the next frame starts empty");
+ // what a host gets besides findings: each grip's point on screen (the gate samples contact windows with it, still --grips crops it)
+ holding(h, p, v3(-0.45, 1.35, 0.45));
+ const G = globalThis as { __ANIDOODLE_CHECK3D__?: unknown }; let info: { grips: { name: string; x: number; y: number }[] } | undefined;
+ G.__ANIDOODLE_CHECK3D__ = (_f: number, _fs: Finding[], i: typeof info) => { info = i; };
+ try { registerGrip(h, h.limbs["arms.right"], p); runChecks(44, cam, ENV); } finally { delete G.__ANIDOODLE_CHECK3D__; }
+ const want = gripFrame(h.limbs["arms.right"]).point.project(cam), g0 = info?.grips[0];
+ ok(!!g0 && g0.name === "h/lantern" && Math.abs(g0.x - ((want.x + 1) / 2) * ENV.W) < 1e-6 && Math.abs(g0.y - ((1 - want.y) / 2) * ENV.H) < 1e-6 && g0.x > 0 && g0.x < ENV.W, `the collector also gets each grip's point on screen (${g0?.name} at ${g0?.x.toFixed(0)}, ${g0?.y.toFixed(0)})`);
}
// ---- the demo film: every frame clean; two broken variants that must fail
diff --git a/skills/anidoodle/engine/tools/gate.mjs b/skills/anidoodle/engine/tools/gate.mjs
index 29e0c9b..3898a1c 100644
--- a/skills/anidoodle/engine/tools/gate.mjs
+++ b/skills/anidoodle/engine/tools/gate.mjs
@@ -7,6 +7,8 @@
// different orders. Byte-identical, or PSNR above 45 dB.
// 2 CONTRACT a static scan of every module the film draws through.
// 3 DEAD AIR no identical consecutive frames, no half-second window under 0.5 % changed per 1/30 s.
+// 5 3D CHECKS 3D films only: three-core/checks3d.ts on sampled frames plus every frame of a
+// grip's contact window. Any finding (a prop through a hand, rigs clipping) fails.
//
// The gate NEVER writes to out/. It renders into .tmp/gate/ and it only ever READS the MP4 it is
// pointed at, so running it can never damage a finished film.
@@ -17,6 +19,9 @@ import { resolve } from "node:path";
import { readdirSync } from "node:fs";
import { defaultOutput, requireFilm } from "./names.mjs";
import { changedArea } from "./motion.mjs";
+import { pathToFileURL } from "node:url";
+import { glArgs } from "./adapters/playwright.mjs";
+import { detect } from "./detect.mjs";
const VAL = new Set(["adapter", "mp4", "samples", "scale", "workers"]);
const pos = [], opt = {};
@@ -94,6 +99,36 @@ const deadAir = async (mp4, meta) => {
console.log(` ${n} frames measured; median ${((mvt[mvt.length >> 1] ?? 0) * 100).toFixed(2)}% min ${((mvt[0] ?? 0) * 100).toFixed(2)}%`);
};
+// ---------------------------------------------------------------- 5. 3D checks, inside the page
+// The film's own draws run three-core/checks3d.ts (runChecks) when a collector listens; the page
+// returns every finding (hosts/page.ts FILM.checks3d). The pass mounts at a quarter scale: the checks
+// read geometry and the camera, never pixels, so the frame size changes nothing they see and the
+// WebGL draw costs a sixteenth. Lessons 37 and 48: a green gate with a prop through a hand is a failed gate.
+const CHECK_SCALE = 0.25, CHECK_SAMPLES = 48;
+const checks3d = async (pagePath, meta) => {
+ head(5, "3D CHECKS grips held, nothing through anything (three-core/checks3d)");
+ if (!readFileSync(pagePath, "utf8").includes("__ANIDOODLE_WEBGL__")) { note("a 2D film", "3D checks not applicable"); return; }
+ const env = detect(), N = meta.durationFrames;
+ const browser = await env.pw.lib.chromium.launch({ executablePath: env.browser.executablePath, args: ["--disable-background-timer-throttling", ...glArgs(pagePath)] });
+ try {
+ const page = await (await browser.newContext({ viewport: { width: 640, height: 640 } })).newPage(), errors = [];
+ page.on("pageerror", (e) => errors.push(e.message));
+ await page.goto(pathToFileURL(pagePath).href + "?adapter=gate-3d");
+ await page.evaluate(async (s) => { await window.FILM.ready; window.FILM.mount(s); }, CHECK_SCALE);
+ const ask = async (frames) => { const out = []; for (let i = 0; i < frames.length; i += 24) out.push(...(await page.evaluate((fs) => window.FILM.checks3d(fs), frames.slice(i, i + 24)))); return out; };
+ // pass 1: every Nth frame. pass 2: every frame between two samples where either one holds a grip
+ // (a contact window), because a hand can pass through a handle for three frames between samples
+ const step = Math.max(1, Math.ceil(N / CHECK_SAMPLES)), sampled = [...new Set([...Array.from({ length: Math.ceil(N / step) }, (_, i) => i * step), N - 1])];
+ const recs = await ask(sampled), byFrame = new Map(recs.map((r) => [r.frame, r]));
+ const fill = []; for (let i = 0; i + 1 < sampled.length; i++) { const a = byFrame.get(sampled[i]), b = byFrame.get(sampled[i + 1]); if (a?.grips.length || b?.grips.length) for (let f = sampled[i] + 1; f < sampled[i + 1]; f++) fill.push(f); }
+ recs.push(...(await ask(fill)));
+ if (errors.length) { say(false, "the 3D check pass drew without errors", errors.slice(0, 3).join("; ")); return; }
+ const findings = recs.flatMap((r) => r.findings), withGrip = recs.filter((r) => r.grips.length).length;
+ if (!recs.length) { note(`no frame registers anything to check (${sampled.length} sampled)`, "a 3D film with characters or held props should register them: three-core/checks3d.ts"); return; }
+ say(findings.length === 0, `${recs.length} frames checked (${sampled.length} sampled + ${fill.length} in grip windows), ${withGrip} with a grip`, findings.length ? `${findings.length} finding(s): ` + findings.slice(0, 6).map((x) => `${x.frame} ${x.kind} ${x.where}: ${x.detail}`).join(" | ") : "no finding");
+ } finally { await browser.close(); }
+};
+
// ---------------------------------------------------------------- 1. determinism, two ways round
const psnr = (a, b) => {
const r = spawnSync("ffmpeg", ["-v", "error", "-i", a, "-i", b, "-lavfi", "psnr=stats_file=-", "-f", "null", "-"], { encoding: "utf8" });
@@ -176,6 +211,7 @@ const run = async () => {
console.log(` ${art.path} (${(art.bytes / 1024).toFixed(0)} KB, ${art.kind})`);
art.checks.forEach((c) => say(c.ok, c.label, c.detail));
}
+ await checks3d(resolve(`dist/${film}.html`), meta);
console.log(`\n${"=".repeat(58)}`);
console.log(fails ? `GATE: FAIL ${fails} of ${checks} checks failed` : `GATE: PASS ${checks}/${checks} checks, ${nFiles} modules scanned`);
diff --git a/skills/anidoodle/engine/tools/still.mjs b/skills/anidoodle/engine/tools/still.mjs
index 6b4e67a..f86ec84 100644
--- a/skills/anidoodle/engine/tools/still.mjs
+++ b/skills/anidoodle/engine/tools/still.mjs
@@ -9,10 +9,14 @@
// plates baked once): the cheap way to review a cut. Ranges work: 0-300:50.
// --sheet file also lay the frames out as one contact sheet at --sheet-scale (default 0.4)
// --no-bake-cache draw every finished plate cold instead of reading .cache/bakes
+// --grips 3D films: a 2x crop of every grip the film registers (three-core/checks3d) on each
+// frame, plus one board of them all, each labelled PASS or with its findings. A green
+// check with a prop through a hand is still a failure: look at the crops (lesson 37).
// With no --frame/--frames, one still per shot, at the shot's first frame.
import { createHash } from "node:crypto";
import { spawnSync } from "node:child_process";
-import { mkdirSync, rmSync, writeFileSync } from "node:fs";
+import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { pathToFileURL } from "node:url";
import { dirname, join, resolve } from "node:path";
import { buildPage } from "./build-page.mjs";
import { requireFilm } from "./names.mjs";
@@ -90,3 +94,42 @@ if (opt.sheet) {
if (r.status !== 0) die(`contact sheet failed: ${r.stderr.trim()}`);
console.log(` contact sheet ${cols}x${rows} at ${k}x -> ${out}`);
}
+
+// GRIP CROP BOARD. A page of its own at 2x with the 3D checks listening (hosts/page.ts FILM.checks3d):
+// each frame is drawn once, its registered grips come back as points on screen, and a crop around
+// each one is cut from that same 2x frame. Never touches the stills above.
+if (opt.grips) {
+ if (!readFileSync(page.out, "utf8").includes("__ANIDOODLE_WEBGL__")) die("--grips is for 3D films (this page draws no WebGL, so nothing registers a grip)");
+ const K = 2, CW = 240, CH = 170, dir = resolve(String(opt.out ?? "out/").endsWith("/") ? opt.out ?? "out/" : dirname(resolve(opt.out)), "grips");
+ mkdirSync(dir, { recursive: true });
+ const browser = await env.pw.lib.chromium.launch({ executablePath: env.browser.executablePath, args: ["--disable-background-timer-throttling", ...playwright.glArgs(page.out)] });
+ const crops = [];
+ try {
+ const gp = await (await browser.newContext({ viewport: { width: 640, height: 640 } })).newPage();
+ await gp.goto(pathToFileURL(page.out).href + "?adapter=still-grips");
+ await gp.evaluate(async (k) => { await window.FILM.ready; window.FILM.mount(k); }, K);
+ for (const [n] of jobs) {
+ const r = await gp.evaluate((f) => { const rec = window.FILM.checks3d([f]); return { rec, png: window.FILM.png() }; }, n);
+ const rec = r.rec[0]; if (!rec?.grips.length) { console.log(` grips frame ${String(n).padEnd(5)} none registered`); continue; }
+ const full = resolve(dir, `.frame-${n}.png`); writeFileSync(full, Buffer.from(r.png, "base64"));
+ rec.grips.forEach((g, i) => {
+ const w = CW * K, h = CH * K, x = Math.max(0, Math.min(meta.W * K - w, Math.round(g.x * K - w / 2))), y = Math.max(0, Math.min(meta.H * K - h, Math.round(g.y * K - h / 2)));
+ const out = resolve(dir, `${film}-${n}-grip${i}.png`), bad = rec.findings.filter((x) => x.kind.startsWith("grip") || x.kind === "proximity");
+ const cr = spawnSync("ffmpeg", ["-v", "error", "-y", "-i", full, "-vf", `crop=${w}:${h}:${x}:${y}`, out], { encoding: "utf8" });
+ if (cr.status !== 0) die(`grip crop failed: ${cr.stderr.trim()}`);
+ crops.push(out);
+ console.log(` grips frame ${String(n).padEnd(5)} ${g.name} ${bad.length ? "FINDINGS: " + bad.map((x) => x.kind).join(", ") : "PASS"} -> ${out}`);
+ });
+ rmSync(full, { force: true });
+ }
+ } finally { await browser.close(); }
+ if (crops.length > 1) {
+ const cols = Math.ceil(Math.sqrt(crops.length)), rows = Math.ceil(crops.length / cols), w = CW * K, h = CH * K, args = ["-v", "error", "-y"];
+ crops.forEach((f) => args.push("-i", f));
+ const pads = Array.from({ length: cols * rows - crops.length }, (_, i) => `color=c=white:s=${w}x${h}:d=1[p${i}]`), ids = [...crops.map((_, i) => `[${i}:v]`), ...pads.map((_, i) => `[p${i}]`)];
+ const layout = ids.map((_, i) => `${(i % cols) * w}_${Math.floor(i / cols) * h}`).join("|"), board = resolve(dir, `${film}-grips.png`);
+ const r = spawnSync("ffmpeg", [...args, "-filter_complex", [...pads, `${ids.join("")}xstack=inputs=${ids.length}:layout=${layout}:fill=white`].join(";"), "-frames:v", "1", board], { encoding: "utf8" });
+ if (r.status !== 0) die(`grip board failed: ${r.stderr.trim()}`);
+ console.log(` grip board ${cols}x${rows} -> ${board}`);
+ }
+}