Skip to content

A Claude Code skill that reverse-engineers any animation frame by frame, then proves the copy moves the same.

Cut the demo video to 47 seconds, without sound

NiazMorshed2007f5f2143d9968
diff --git a/.github/assets/demo.webp b/.github/assets/demo.webp
index 35bf682..6de9ac8 100644
Binary files a/.github/assets/demo.webp and b/.github/assets/demo.webp differ
diff --git a/README.md b/README.md
index ff52c9e..4ea266e 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
<p align="center">
<a href="https://reanimate.niazmorshed.dev/demo.mp4"><img src=".github/assets/demo.webp" width="760" alt="Moments from the demo video: /reanimate slides in; three browsers record widgets on stripe.com, resend.com and clerk.com; the copies are measured against them until the difference is gone; the 18 examples turn on a helix; the install command types itself in."></a>
</p>
-<p align="center"><sub>A one-minute demo. <a href="https://reanimate.niazmorshed.dev/demo.mp4">Watch it with sound</a>.</sub></p>
+<p align="center"><sub>A short demo. <a href="https://reanimate.niazmorshed.dev/demo.mp4">Watch the full video</a>.</sub></p>
A lot of good ideas start on someone else's site. Ask an agent to rebuild one from a link or a screenshot and it makes one pass, calls it done, and misses. It can't see the motion or tell how far off it is.
diff --git a/site/.gitignore b/site/.gitignore
index e8a6827..840f446 100644
--- a/site/.gitignore
+++ b/site/.gitignore
@@ -50,5 +50,3 @@ next-env.d.ts
# demo video: recorded clips and renders (video/scripts/clips.ts, render.ts)
/video/clips/
/video/out/
-# the soundtrack isn't passed on as a file (Mixkit's licence); video/README.md has the command to make it
-/video/assets/soundtrack.mp3
diff --git a/site/README.md b/site/README.md
index b87db8e..c5c55d0 100644
--- a/site/README.md
+++ b/site/README.md
@@ -58,7 +58,7 @@ Then either:
| `public/media/` | Comparisons and posters, one folder per example. `stripe-bento/` is the entrance at the top of the page. |
| `scripts/record-media.ts` | Records the examples' media and the README animations. |
| `marketing/launch.md` | Launch post drafts. |
-| `video/` | The 64-second demo video, as a page drawn frame by frame from the time and rendered to mp4 ([`video/README.md`](video/README.md)). The site serves it at `/demo.mp4` (`public/demo.mp4`). |
+| `video/` | The 47-second demo video, as a page drawn frame by frame from the time and rendered to mp4 ([`video/README.md`](video/README.md)). The site serves it at `/demo.mp4` (`public/demo.mp4`). |
## About the examples
diff --git a/site/public/demo.mp4 b/site/public/demo.mp4
index 53cd2be..afa96b6 100644
Binary files a/site/public/demo.mp4 and b/site/public/demo.mp4 differ
diff --git a/site/video/README.md b/site/video/README.md
index 02f6154..8152dc7 100644
--- a/site/video/README.md
+++ b/site/video/README.md
@@ -1,26 +1,15 @@
# Demo video
-A 64-second demo of reanimate, cut to `assets/soundtrack.mp3` (90 bpm). It's a web page: every frame is drawn from the time alone, then screenshotted and encoded, so the render is frame-exact and the cuts land on the beat. Commands run from `site/`.
+A 47-second demo of reanimate, without sound, its cuts on a 90 bpm grid. It's a web page: every frame is drawn from the time alone, then screenshotted and encoded, so the render is frame-exact. Commands run from `site/`.
| Time | Bars | What |
|---|---|---|
-| 0–4.8 s | intro | `/reanimate` slides in with onion-skin frames behind it |
-| 4.8–12.8 s | 1–4 | a picker wheel of things to ask for, one every two beats |
-| 12.8–28.8 s | 4–10 | how it works, on three clones at once (stripe.com's Agentic commerce card, the resend.com cube, clerk.com's Session management card): record, spec, build, verify, repeat (the copies' pixel difference shrinking each round) |
-| 28.8–47.5 s | 10–17 | the clones: Stripe and WorkOS on a track, Liveblocks' app window, the Clerk cards, then the Resend cube and React Bits' fading stars |
-| 47.5–56.8 s | 17–20.5 | all 18 as a mosaic, which unravels into a turning helix of their frames |
-| 56.8 s–end | 20.5–23.25 | the install command; `/reanimate`, gray all video, turns to ink |
-
-## Soundtrack
-
-"My Little Prince" by Michael Ramir C., from [Mixkit](https://mixkit.co/free-stock-music/tag/calm/) under the [Mixkit Stock Music Free License](https://mixkit.co/license/#musicFree) (free for commercial and personal projects, no attribution required). It's 90 bpm with its first downbeat at 2.597 s, so 0.431 s is cut from the start to put that downbeat on the video's at 2.166 s, then it's turned down to about -18 LUFS and faded out over the last 2.5 s. The track isn't in the repository (Mixkit's licence is for using it in your own work, not for passing the file on); make it before rendering:
-
-```sh
-curl -L https://assets.mixkit.co/music/815/815.mp3 -o /tmp/815.mp3
-ffmpeg -ss 0.431 -i /tmp/815.mp3 -t 64.166 -af "volume=-6.4dB,afade=t=out:st=61.666:d=2.5" -c:a libmp3lame -b:a 320k video/assets/soundtrack.mp3
-```
-
-Another track only needs the same treatment: 90 bpm (or time-stretched to it with `atempo`), a downbeat at 2.166 s, cut to `DURATION` in `src/lib.js`.
+| 0–2 s | intro | `/reanimate` slides in with onion-skin frames behind it |
+| 2–6.2 s | 0–1.5 | a picker wheel of things to ask for, one a beat; the last is entered |
+| 6.2–15.5 s | 1.5–5 | the clones, big, one every two beats: React Bits' fading stars, Stripe, Liveblocks, WorkOS, Clerk |
+| 15.5–23.5 s | 5–8 | the Resend cube up close; the camera pulls back to all 18 in a mosaic, which winds into a turning helix |
+| 23.5–39.5 s | 8–14 | how it works, on three clones at once (stripe.com's Agentic commerce card, the resend.com cube, clerk.com's Session management card): record, spec, build, verify, repeat (the copies' pixel difference shrinking each round) |
+| 39.5 s–end | 14–17 | the install command; `/reanimate`, gray all video, turns to ink |
## Make it
@@ -40,4 +29,4 @@ bun video/scripts/publish.ts # public/demo.mp4 for the site, and the README's
bun video/scripts/serve.ts # http://localhost:4700/video/
```
-A player with the soundtrack: space plays and pauses, ←/→ step a frame (shift: a second), `?t=12.5` starts there. Each scene is a module in `src/` with `from`, `to`, `init(root)` and `render(t)`; `src/lib.js` has the beat grid (`bar(n)`, `beat(n)`), easing and the blur-and-fade helper the transitions share.
+A player: space plays and pauses, ←/→ step a frame (shift: a second), `?t=12.5` starts there. Each scene is a module in `src/` with `from`, `to`, `init(root)` and `render(t)`, and optionally `shift` to keep its own clock (`how.js` is timed as if it began at 12.86 s and plays 4 bars later); `src/lib.js` has the beat grid (`bar(n)`, `beat(n)`), easing and the blur-and-fade helper the transitions share.
diff --git a/site/video/index.html b/site/video/index.html
index 67286a4..403fd2b 100644
--- a/site/video/index.html
+++ b/site/video/index.html
@@ -8,7 +8,7 @@
<link rel="preload" href="assets/fonts/Inter-opsz.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="assets/fonts/JetBrainsMono.woff2" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="src/demo.css">
- <!-- ?render: the bare 1920x1080 stage for scripts/render.ts. Otherwise a player with the soundtrack:
+ <!-- ?render: the bare 1920x1080 stage for scripts/render.ts. Otherwise a player:
space plays and pauses, ←/→ step a frame (shift: a second), ?t=12.5 starts there. -->
<script>if (new URLSearchParams(location.search).has("render")) document.documentElement.dataset.render = "";</script>
<script type="module" src="src/main.js"></script>
@@ -18,8 +18,7 @@
<div id="player">
<button type="button" id="play" aria-label="Play">Play</button>
<span id="time">0.00</span>
- <input id="scrub" type="range" min="0" max="64.166" step="0.001" value="0" aria-label="Time">
- <audio id="audio" src="assets/soundtrack.mp3" preload="auto"></audio>
+ <input id="scrub" type="range" min="0" max="47.5" step="0.001" value="0" aria-label="Time">
</div>
</body>
</html>
diff --git a/site/video/scripts/publish.ts b/site/video/scripts/publish.ts
index f381140..ef5655c 100644
--- a/site/video/scripts/publish.ts
+++ b/site/video/scripts/publish.ts
@@ -14,9 +14,9 @@ const SRC = join(SITE, "video", "out", "reanimate-demo.mp4");
const WEB = join(SITE, "public", "demo.mp4");
const README = join(SITE, "..", ".github", "assets", "demo.webp");
-// [from, to] in seconds of the video: the title, recording the three originals, verifying the copies,
-// Liveblocks, the mosaic turning into the helix, and the install card turning to ink
-const MOMENTS = [[0.3, 4.4], [13.3, 17.1], [22.0, 24.7], [33.4, 35.9], [47.4, 51.9], [57.6, 61.8]];
+// [from, to] in seconds of the video: the title and the prompts, the first clones, the camera pulling back
+// from the cube into the helix, recording the three originals, and the install card turning to ink
+const MOMENTS = [[0.3, 5.9], [6.1, 9.6], [15.4, 21.0], [24.0, 26.4], [41.0, 45.0]];
const FADE = 0.3;
const WIDTH = 760; // as wide as the README shows it
const FPS = 15;
@@ -32,7 +32,7 @@ run("ffmpeg", [
"-v", "error", "-y", "-i", SRC,
"-c:v", "libx264", "-preset", "slow", "-crf", "24", "-tune", "animation", "-pix_fmt", "yuv420p",
"-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709", "-color_range", "tv",
- "-c:a", "aac", "-b:a", "160k", "-movflags", "+faststart", WEB,
+ "-an", "-movflags", "+faststart", WEB,
]);
console.log(`wrote ${WEB} (${mb(WEB)})`);
diff --git a/site/video/scripts/render.ts b/site/video/scripts/render.ts
index fe73d8d..9eb5abc 100644
--- a/site/video/scripts/render.ts
+++ b/site/video/scripts/render.ts
@@ -1,10 +1,11 @@
// Renders the demo video: every frame of video/index.html?render is drawn from its time alone, screenshotted
-// in headless Chromium and piped to ffmpeg, in parallel slices, then joined and laid over the soundtrack.
+// in headless Chromium and piped to ffmpeg, in parallel slices, then joined. There's no sound.
//
// bun video/scripts/render.ts # video/out/reanimate-demo.mp4, 1920x1080, 60 fps
// bun video/scripts/render.ts --scale 2 # drawn at 3840x2160 (sharper), written at --size
// bun video/scripts/render.ts --stills 1.5,12.9 # just those moments, as PNGs in video/out/stills/
// bun video/scripts/render.ts --from 12 --to 20 # a section, without the full-length join
+// bun video/scripts/render.ts --page vercel.html # another video page: video/out/vercel.mp4
//
// Needs the clips (bun video/scripts/clips.ts), ffmpeg on PATH and Playwright's Chromium.
import { chromium, type Browser, type CDPSession, type Page } from "playwright";
@@ -28,6 +29,7 @@ const { values: args } = parseArgs({
out: { type: "string" },
crf: { type: "string", default: "14" },
port: { type: "string", default: "4702" },
+ page: { type: "string", default: "index.html" },
},
});
@@ -38,7 +40,8 @@ mkdirSync(OUT, { recursive: true });
const PORT = Number(args.port);
const server = await serve(PORT);
-const url = `http://localhost:${PORT}/video/?render`;
+const url = `http://localhost:${PORT}/video/${args.page}?render`;
+const NAME = args.page === "index.html" ? "reanimate-demo" : args.page!.replace(/\.html$/, "");
const stop = () => (server.closeAllConnections(), server.close());
async function open(browser: Browser): Promise<{ page: Page; cdp: CDPSession; info: { duration: number; fps: number } }> {
@@ -129,14 +132,9 @@ stop();
const list = join(parts, "list.txt");
writeFileSync(list, files.filter(Boolean).map((f) => `file '${f}'`).join("\n"));
-const name = args.out ?? (first === 0 && last === total ? "reanimate-demo.mp4" : `section-${(first / info.fps).toFixed(1)}-${(last / info.fps).toFixed(1)}.mp4`);
+const name = args.out ?? (first === 0 && last === total ? `${NAME}.mp4` : `${args.page === "index.html" ? "" : `${NAME}-`}section-${(first / info.fps).toFixed(1)}-${(last / info.fps).toFixed(1)}.mp4`);
const dest = join(OUT, name);
-const audio = join(SITE, "video", "assets", "soundtrack.mp3");
-const r = spawnSync("ffmpeg", [
- "-v", "error", "-y", "-f", "concat", "-safe", "0", "-i", list,
- "-ss", String(first / info.fps), "-t", String((last - first) / info.fps), "-i", audio,
- "-map", "0:v", "-map", "1:a", "-c:v", "copy", "-c:a", "aac", "-b:a", "256k", "-movflags", "+faststart", "-shortest", dest,
-], { stdio: "inherit" });
+const r = spawnSync("ffmpeg", ["-v", "error", "-y", "-f", "concat", "-safe", "0", "-i", list, "-c", "copy", "-movflags", "+faststart", dest], { stdio: "inherit" });
if (r.status !== 0) throw new Error("ffmpeg join failed");
rmSync(parts, { recursive: true, force: true });
console.log(`wrote ${dest} in ${((Date.now() - started) / 1000).toFixed(0)} s`);
diff --git a/site/video/src/demo.css b/site/video/src/demo.css
index b24a8e8..e5e2221 100644
--- a/site/video/src/demo.css
+++ b/site/video/src/demo.css
@@ -145,13 +145,11 @@ html[data-render] #player { display: none; }
.chart-bar i { display: block; width: 100%; border-radius: 10px 10px 4px 4px; }
.chart-bar span { position: absolute; left: 50%; bottom: -34px; transform: translateX(-50%); white-space: nowrap; font: 500 14px/1 var(--mono); color: #9a9aa2; }
-/* ---------- examples ---------- */
+/* ---------- showcase ---------- */
-.ex-label { width: 1920px; text-align: center; font-size: 23px; letter-spacing: -0.005em; color: var(--muted); }
.ex-card { position: absolute; left: 0; top: 0; }
.ex-card .fill { z-index: 1; }
.ex-shadow { position: absolute; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.05), 0 2px 6px rgb(0 0 0 / 0.04), 0 36px 80px -30px rgb(20 20 40 / 0.4); }
-.ex-group { position: absolute; }
/* ---------- helix ---------- */
diff --git a/site/video/src/examples.js b/site/video/src/examples.js
deleted file mode 100644
index 358a03b..0000000
--- a/site/video/src/examples.js
+++ /dev/null
@@ -1,135 +0,0 @@
-// The clones, quickly. The Stripe and WorkOS ones ride a track, a step every two beats, the one in focus
-// sharp and its neighbours blurred; then Liveblocks' app window gets a bar to itself, the Clerk cards come
-// in a bar at a time, in groups, and the Resend cube and React Bits' fading stars after them. Each clip
-// plays from the moment it takes focus.
-// The last group gives way to the mosaic in helix.js.
-import { bar, clamp, clipInfo, ease, el, frameUrl, lerp, presence, prog, put, setSrc } from "./lib.js";
-
-export const name = "examples";
-export const from = 28.5;
-export const to = 48.1;
-
-// A clip on a card: its frames, scaled, with a soft shadow under the card inside the frame.
-// inset: the card's margin inside the recording (the Clerk cards were filmed with 24 px around them).
-const LOOK = {
- stripe: { inset: 0, radius: 6, shadow: true },
- clerk: { inset: 24, radius: 16, shadow: true },
- workos: { inset: 0, radius: 0, shadow: false },
- resend: { inset: 0, radius: 16, shadow: true },
- reactbits: { inset: 0, radius: 16, shadow: true },
- liveblocks: { inset: 0, radius: 14, shadow: true },
-};
-function card(parent, slug, scale) {
- const c = clipInfo(slug);
- const look = LOOK[slug.split("-")[0]];
- const w = c.width * scale, h = c.height * scale;
- const g = el("div", "ex-card", parent);
- Object.assign(g.style, { width: `${w}px`, height: `${h}px` });
- if (look.shadow) {
- const sh = el("div", "ex-shadow", g);
- const i = look.inset * scale;
- Object.assign(sh.style, { left: `${i}px`, top: `${i}px`, right: `${i}px`, bottom: `${i}px`, borderRadius: `${look.radius * scale}px` });
- }
- g._img = el("img", "fill", g);
- g._img.style.borderRadius = `${look.radius * scale}px`;
- Object.assign(g, { _slug: slug, _w: w, _h: h });
- return g;
-}
-
-// ---- the track ----
-const TRACK = [
- { slug: "stripe-agentic-commerce", scale: 640 / 676, at: bar(10), from: 0.2, speed: 1.25 },
- { slug: "stripe-issuing", scale: 640 / 676, at: bar(10.5), from: 0.3, speed: 1 },
- { slug: "stripe-crypto", scale: 640 / 676, at: bar(11), from: 0.4, speed: 1 },
- { slug: "workos-atlas", scale: 620 / 536, at: bar(11.5), from: 0, speed: 1.1 },
-];
-const SPACING = 600;
-const TRACK_OUT = bar(12) - 0.25;
-
-function trackPos(t) {
- let p = lerp(-1.7, 0, ease.expo(prog(t, 28.55, 29.35)));
- for (let k = 1; k < TRACK.length; k++) p += ease.expo(prog(t, TRACK[k].at - 0.12, TRACK[k].at + 0.6));
- return p + 1.6 * ease.inOutCubic(prog(t, TRACK_OUT, TRACK_OUT + 0.55));
-}
-
-// ---- the groups: [slug, x, y] in px of the recordings, scaled by `scale` ----
-const GROUPS = [
- { at: bar(12), scale: 1.05, cards: [["liveblocks-comments", 0, 0]] },
- { at: bar(13), scale: 1.18, cards: [["clerk-session-management", 0, 0], ["clerk-fraud", 443, 0], ["clerk-magic-links", 886, 0]] },
- { at: bar(14), scale: 1.1, cards: [["clerk-mfa", 0, 0], ["clerk-otp", 443, 0], ["clerk-social-sign-on", 886, 0], ["clerk-bot-detection", 0, 308], ["clerk-advanced-security", 443, 308], ["clerk-passwords", 886, 308]] },
- { at: bar(15), scale: 1.28, cards: [["clerk-api-keys", 0, 0], ["clerk-cli", 845, 0]] },
- { at: bar(16), scale: 0.95, cards: [["resend-cube", 0, 25], ["reactbits-fading-stars", 688, 0]] },
-];
-const GROUP_END = bar(17);
-const CY = 525; // the cards' centre line
-
-let root, label, track, groups;
-
-export function init(r) {
- root = r;
- label = el("div", "ex-label", root, "Examples, each rebuilt by its own agent with reanimate");
- track = TRACK.map((x) => Object.assign(card(root, x.slug, x.scale), { _x: x }));
- groups = GROUPS.map((g) => {
- const box = el("div", "ex-group", root);
- box._w = Math.max(...g.cards.map(([slug, x]) => x + clipInfo(slug).width)) * g.scale;
- box._h = Math.max(...g.cards.map(([slug, , y]) => y + clipInfo(slug).height)) * g.scale;
- box._cards = g.cards.map(([slug, x, y], i) => {
- const c = card(box, slug, g.scale);
- Object.assign(c, { _cx: x * g.scale, _cy: y * g.scale, _i: i });
- return c;
- });
- box._g = g;
- Object.assign(box.style, { width: `${box._w}px`, height: `${box._h}px` });
- return box;
- });
-}
-
-export function render(t) {
- const lab = presence(t, 28.95, 0.6, GROUP_END - 0.22, 0.4);
- put(label, { o: lab.v, y: 74 + (1 - lab.a) * 12 - lab.b * 10, blur: 10 * Math.max(1 - lab.a, lab.b) });
-
- // ---- track ----
- const pos = trackPos(t);
- const trackOut = ease.inOutCubic(prog(t, TRACK_OUT, TRACK_OUT + 0.5));
- track.forEach((c, k) => {
- const d = k - pos;
- const ad = Math.abs(d);
- if (ad > 2.2 || t > TRACK_OUT + 0.6) return put(c, { o: 0 });
- const x = c._x;
- const focus = clamp(1 - ad);
- const s = lerp(0.8, 1, focus);
- const lt = x.from + x.speed * Math.max(0, t - (x.at - 0.25));
- setSrc(c._img, frameUrl(x.slug, lt));
- put(c, {
- o: clamp(1 - ad * 0.62) * clamp(1.5 - ad * 0.5) * (1 - trackOut) * clamp((t - 28.5) * 3),
- x: 960 + d * SPACING - c._w / 2,
- y: CY - c._h / 2 + (1 - focus) * 14,
- s,
- blur: Math.min(1, ad) * 11 + trackOut * 10,
- });
- });
-
- // ---- Clerk groups ----
- groups.forEach((box, gi) => {
- const g = box._g;
- // the last group shrinks away as the mosaic of all of them flies in: the first step of the zoom out
- const last = gi === GROUPS.length - 1;
- const next = last ? GROUP_END : GROUPS[gi + 1].at;
- const out = ease.inOutCubic(prog(t, next - 0.3, next + 0.2));
- if (t < g.at - 0.4 || out >= 1) return put(box, { o: 0 });
- const top = CY - box._h / 2;
- put(box, { o: 1, x: 960 - box._w / 2, y: top, s: last ? lerp(1, 0.62, out) : 1 });
- box._cards.forEach((c) => {
- const a = ease.expo(prog(t, g.at - 0.28 + c._i * 0.07, g.at + 0.42 + c._i * 0.07));
- const lt = Math.max(0, t - (g.at - 0.1));
- setSrc(c._img, frameUrl(c._slug, lt));
- put(c, {
- o: a * (1 - out),
- x: c._cx + (1 - a) * 140 - (last ? 0 : out * 160),
- y: c._cy + (1 - a) * 10,
- s: lerp(0.94, 1, a) * (last ? 1 : lerp(1, 0.96, out)),
- blur: (1 - a) * 16 + out * 16,
- });
- });
- });
-}
diff --git a/site/video/src/helix.js b/site/video/src/helix.js
index 4694a69..d808976 100644
--- a/site/video/src/helix.js
+++ b/site/video/src/helix.js
@@ -1,19 +1,21 @@
-// Every clone at once: a mosaic of the clips in three staggered rows of six, which unravels into one ribbon
-// of playing frames wound into a helix at bar 18, then the camera pulls back for a few seconds as it turns.
-// The mosaic's tiles become the middle of the ribbon. Tiles turned away are flipped (they are edge-on
-// when it happens) so no frame is ever mirrored.
+// Every clone at once. It opens on the Resend cube filling the screen, the last of the showcase; it is a
+// tile of a mosaic of all 18 clips (three staggered rows of six), and at bar 5.5 the camera pulls back to
+// show the rest. At bar 6.5 the mosaic unravels into one ribbon of playing frames wound into a helix, which
+// turns for a few seconds while the camera pulls back further. The mosaic's tiles become the middle of the
+// ribbon. Tiles turned away are flipped (they are edge-on when it happens) so no frame is ever mirrored.
import { bar, clipInfo, clipLen, ease, el, frameUrl, hash, lerp, prog, put, setSrc, setStyle } from "./lib.js";
+import { CUBE_AT } from "./showcase.js";
export const name = "helix";
-export const from = 47.2;
-export const to = 57.1;
+export const from = CUBE_AT - 0.15;
-// in the mosaic's reading order
+// in the mosaic's reading order; the cube is near the middle, where the camera starts
const EXAMPLES = [
- "stripe-agentic-commerce", "stripe-issuing", "resend-cube", "stripe-crypto", "workos-atlas", "clerk-session-management",
- "clerk-fraud", "clerk-magic-links", "reactbits-fading-stars", "clerk-mfa", "liveblocks-comments", "clerk-otp",
+ "stripe-agentic-commerce", "stripe-issuing", "reactbits-fading-stars", "stripe-crypto", "workos-atlas", "clerk-session-management",
+ "clerk-fraud", "clerk-magic-links", "resend-cube", "clerk-mfa", "liveblocks-comments", "clerk-otp",
"clerk-social-sign-on", "clerk-bot-detection", "clerk-advanced-security", "clerk-passwords", "clerk-api-keys", "clerk-cli",
];
+const CUBE = EXAMPLES.indexOf("resend-cube");
const LIGHT = new Set(["stripe-agentic-commerce", "stripe-issuing", "stripe-crypto", "workos-atlas"]); // on white; the rest are dark
// where to crop each recording into a 4:3 tile: the card's margin in the recording, and the focus point
const CROP = {
@@ -45,14 +47,16 @@ const CELLS = [0, 1, 2].flatMap((r) =>
const D0 = P / 0.8 - P + R;
const D1 = 2150;
-const IN = bar(17) - 0.17; // the mosaic flies in as the last examples leave
-const MORPH = [bar(18) - 0.05, bar(18) + 1.45]; // 50.12 → 51.62
-const PULLED = MORPH[1] + 2.4; // the camera has pulled back
-const FADE = bar(20); // the helix gives way to the install card
+const ZOOM = [bar(5.5) - 0.05, bar(5.5) + 1.3]; // the camera pulls back from the cube to the whole mosaic
+const Z0 = 940 / (TH * MS); // how close it starts: the cube's tile as tall as the showcase's clips
+const MORPH = [bar(6.5) - 0.05, bar(6.5) + 1.45]; // 19.45 → 20.95
+const PULLED = MORPH[1] + 1.4; // the camera has pulled back from the helix
+const FADE = bar(7.75); // the helix gives way to "how it works"
+export const to = FADE + 1.5;
// helix tile for each mosaic cell: the middle of the ribbon, the light ones spread out along it and the
// Resend cube in front when it lands
-const RIBBON = [6, 7, 0, 8, 12, 1, 13, 10, 14, 2, 15, 3, 11, 16, 9, 4, 17, 5]; // EXAMPLES indices, in ribbon order
+const RIBBON = [6, 7, 0, 2, 12, 1, 13, 10, 14, 8, 15, 3, 11, 16, 9, 4, 17, 5]; // EXAMPLES indices, in ribbon order
const HALF = Math.floor(EXAMPLES.length / 2);
const cellTile = (k) => MID - HALF + RIBBON.indexOf(k);
@@ -108,6 +112,7 @@ export function init(r) {
});
tiles.forEach((tile) => (tile._cell = null));
CELLS.forEach((cell, k) => (tiles[cellTile(k)]._cell = cell));
+ tiles[cellTile(CUBE)]._cube = true;
}
export function render(t) {
@@ -123,7 +128,21 @@ export function render(t) {
const fade = ease.inOutCubic(prog(t, FADE - 0.4, FADE + 1.4));
const tq = Math.floor(t * 30) / 30; // tiles play at 30 fps
- put(world, { o: 1 - fade, blur: fade * 14, s: lerp(1, 0.9, fade), rz: lean });
+ // the camera: in on the cube (the cube's cell in the middle of the screen), then back to the whole
+ // mosaic, zooming evenly; the cube cuts in like the showcase's clips
+ const pull = ease.inOut(prog(t, ...ZOOM));
+ const cam = Z0 ** (1 - pull);
+ const cube = CELLS[CUBE];
+ const enter = ease.expo(prog(t, CUBE_AT - 0.06, CUBE_AT + 0.4));
+ const push = 1 + 0.025 * prog(t, CUBE_AT, ZOOM[0]);
+ put(world, {
+ o: enter * (1 - fade),
+ blur: (1 - enter) * 14 + fade * 14,
+ x: -(cube.x - 960) * cam * (1 - pull),
+ y: -(cube.y - 540) * cam * (1 - pull),
+ s: cam * lerp(1.07, 1, enter) * lerp(push, 1, pull) * lerp(1, 0.9, fade),
+ rz: lean,
+ });
for (let i = 0; i < N; i++) {
const tile = tiles[i];
@@ -146,20 +165,17 @@ export function render(t) {
const helixO = 0.05 + 0.95 * front ** 2.2;
const helixBlur = (1 - front) ** 1.5 * 8;
if (tile._cell) {
- // a mosaic cell: flies in, plays, then curls onto the helix
- const { r, x: cx, y: cy } = tile._cell;
- const gx = cx - 960, gy = cy - 540;
- const d = Math.hypot((cx - 960) / (TW * MS + GAP), r - 1);
- const a = ease.expo(prog(t, IN + d * 0.06, IN + 0.75 + d * 0.06));
- const settle = 1 - 0.035 * ease.inOutSine(prog(t, IN + 0.7, MORPH[0]));
- const gz = (1 - a) * 900 - (1 - settle) * 400;
- x = lerp(gx, X, morph);
- y = lerp(gy, Y, morph);
- z = lerp(gz, Z, morph);
+ // a mosaic cell: the cube is there from the start, the others show up as the camera pulls back;
+ // then it curls onto the helix
+ const { x: cx, y: cy } = tile._cell;
+ const a = tile._cube ? 1 : ease.outCubic(prog(t, ZOOM[0] + 0.05, ZOOM[0] + 0.55));
+ x = lerp(cx - 960, X, morph);
+ y = lerp(cy - 540, Y, morph);
+ z = lerp(0, Z, morph);
rx = tilt * morph;
ry = yaw * morph;
o = lerp(a, helixO, morph);
- blur = lerp((1 - a) * 18, helixBlur, morph);
+ blur = helixBlur * morph;
sc = lerp(MS, 1, morph);
} else {
const a = ease.expo(prog(t, MORPH[0] + 0.25 + hash(i) * 0.9, MORPH[0] + 1.1 + hash(i) * 0.9));
@@ -171,7 +187,9 @@ export function render(t) {
put(tile, { o: 0 });
continue;
}
- setSrc(tile._img, frameUrl(tile._slug, tile._off + (tq - IN) * 0.9, { small: true, loop: true }));
+ // the cube is seen up close, so it plays its full-size frames from its own start
+ if (tile._cube) setSrc(tile._img, frameUrl(tile._slug, t - CUBE_AT, { loop: true }));
+ else setSrc(tile._img, frameUrl(tile._slug, tile._off + (tq - CUBE_AT) * 0.9, { small: true, loop: true }));
put(tile, { o, x, y, z, rx, ry, s: sc, blur });
setStyle(tile, "z-index", String(Math.round(z + 20000)));
}
diff --git a/site/video/src/how.js b/site/video/src/how.js
index c362cd3..9aaf0ad 100644
--- a/site/video/src/how.js
+++ b/site/video/src/how.js
@@ -6,10 +6,12 @@
// build code types itself in; the copies appear in a preview
// verify the preview slides next to the originals, all replay, a scan line measures them
// repeat a third panel shows the real pixel difference; each round it shrinks, then a match
-import { ACCENT, INK, MUTED, bar, blurFade, clamp, ease, el, frameUrl, lerp, mix, presence, prog, put, setSrc, setStyle, tw } from "./lib.js";
+import { ACCENT, HOW_SHIFT, INK, MUTED, bar, blurFade, clamp, ease, el, frameUrl, lerp, mix, presence, prog, put, setSrc, setStyle, tw } from "./lib.js";
import { MATCH_AT } from "./intro.js";
+// The times below are this scene's own: it plays HOW_SHIFT later, after the clones (main.js).
export const name = "how";
+export const shift = HOW_SHIFT;
export const from = 12.8;
export const to = 28.85;
diff --git a/site/video/src/install.js b/site/video/src/install.js
index d6a2134..9965885 100644
--- a/site/video/src/install.js
+++ b/site/video/src/install.js
@@ -4,11 +4,11 @@
import { BEAT, DURATION, INK, SUBTLE, T0, bar, clamp, ease, el, lerp, mix, presence, prog, put, setStyle } from "./lib.js";
export const name = "install";
-export const from = 56.3;
+export const from = 39.2;
export const to = DURATION + 1;
-const AT = bar(20.5); // 56.83
-const INK_AT = bar(22); // the word turns from SUBTLE to INK
+const AT = bar(14.25); // 40.17
+const INK_AT = bar(15.75); // the word turns from SUBTLE to INK
const CMD = "npx skills add NiazMorshed2007/reanimate -g";
let root, glow, word, chars, ghosts, pill, typed, caret, copy, copyLabel, hint, links, wordW;
diff --git a/site/video/src/intro.js b/site/video/src/intro.js
index 2250c56..49eff2d 100644
--- a/site/video/src/intro.js
+++ b/site/video/src/intro.js
@@ -1,12 +1,13 @@
// "/reanimate" slides in with onion-skin frames trailing behind it, the way the site's mark moves. Then it
-// becomes the fixed column of a picker wheel whose other column scrolls through things to ask for, one
-// every two beats, like setting an alarm. The last pick is entered and the line rises to become the
-// header of "how it works", with a spinner that turns into a check when the copy matches.
-import { ACCENT, BEAT, FAINT, INK, SUBTLE, T0, W, beat, bezier, blurFade, clamp, ease, el, lerp, measure, mix, presence, prog, put, setStyle } from "./lib.js";
+// becomes the fixed column of a picker wheel whose other column scrolls through things to ask for, one a
+// beat, like setting an alarm. The last pick is entered at 5.8 s and the line dives into the screen as the
+// clones come in; it comes back as the header of "how it works", with a spinner that turns into a check
+// when the copy matches.
+import { ACCENT, BEAT, FAINT, HOW_SHIFT, INK, SUBTLE, T0, W, beat, bezier, blurFade, clamp, ease, el, lerp, measure, mix, presence, prog, put, setStyle } from "./lib.js";
export const name = "intro";
export const from = 0;
-export const to = 28.85;
+export const to = 28.85 + HOW_SHIFT;
const WORD = "/reanimate";
const BIG = 168; // title size, px
@@ -19,7 +20,9 @@ const GAP = 24; // between "/reanimate" and the prompt
const TAIL = 96; // room after the prompt for the caret and the key
const HEADER_Y = 96;
const HEADER_S = 0.44;
-export const MATCH_AT = 27.62; // the spinner in the header turns into a check (how.js: round 4)
+export const MATCH_AT = 27.62; // the spinner in the header turns into a check (how.js: round 4, in its own time)
+const HEADER_IN = 12.86 + HOW_SHIFT - 0.45; // the line is back as the header
+const HEADER_OUT = 28.38 + HOW_SHIFT;
// the sources in [brackets] are tinted when the row is picked; the last one is "how it works"' header
const PROMPTS = [
@@ -37,13 +40,13 @@ const PROMPTS = [
const LAST = PROMPTS.length - 1;
const promptHtml = (p) => p.replace(/\[([^\]]+)\]/g, `<span class="intro-src">$1</span>`);
-// The wheel position (index of the row in the middle) over time: a step every two beats, landing on
-// the beat, then a flick through the rest that settles on the last prompt.
+// The wheel position (index of the row in the middle) over time: a step every beat, landing on the
+// beat, then a flick through the rest that settles on the last prompt.
const SPIN = bezier(0.5, 0, 0.12, 1);
const STEPS = [
- [4.4, 5.12, -2.6, 0, ease.expo],
- ...[6, 8, 10, 12].map((n, i) => [beat(n) - 0.62, beat(n) + 0.04, i, i + 1, ease.soft]),
- [beat(13) + 0.12, beat(15), 4, LAST, SPIN],
+ [1.9, 2.5, -2.6, 0, ease.expo],
+ ...[1, 2, 3].map((n, i) => [beat(n) - 0.36, beat(n) + 0.02, i, i + 1, ease.soft]),
+ [beat(3) + 0.12, beat(5), 3, LAST, SPIN],
];
function wheelAt(t) {
let p = STEPS[0][2];
@@ -104,31 +107,31 @@ export function render(t) {
const v = (wheelAt(t + 0.008) - wheelAt(t - 0.008)) / 0.016; // rows per second
// ---- the word: slides in from the left, onion skins trailing; then shrinks into the wheel's line ----
- const slide = (u) => -230 * (1 - ease.outQuart(prog(u, 0.25, T0 + 0.05)));
- const toWheel = ease.inOut(prog(t, 3.9, 4.6));
+ const slide = (u) => -230 * (1 - ease.outQuart(prog(u, 0.1, 1.3)));
+ const toWheel = ease.inOut(prog(t, 1.85, 2.4));
const xLeft = lerp(W / 2 - wordW / 2, xW, toWheel) + slide(t) * (1 - toWheel);
const yC = lerp(510, MID, toWheel);
const s = lerp(1, sW, toWheel);
put(word, { x: xLeft, y: yC - BIG / 2, s });
chars.forEach((c, i) => {
- const a = ease.expo(prog(t, 0.32 + i * 0.07, 1.25 + i * 0.07));
+ const a = ease.expo(prog(t, 0.12 + i * 0.04, 0.75 + i * 0.04));
put(c, { o: a, y: (1 - a) * 46, blur: (1 - a) * 18 });
});
- const skins = presence(t, 0.35, 0.5, T0 - 0.1, 0.5).v;
+ const skins = presence(t, 0.12, 0.35, 1.15, 0.4).v;
ghosts.forEach((g, k) => {
const lag = (k + 1) * 0.085;
put(g, { o: skins * clamp((slide(t) - slide(t - lag)) / 18), x: xLeft - slide(t) + slide(t - lag), y: yC - BIG / 2, blur: 1 + k * 1.2 });
});
- const g = presence(t, 0.6, 1.8, 12.4, 1.2).v;
- const bloom = Math.exp(-(((t - T0 - 0.25) / 0.7) ** 2));
+ const g = presence(t, 0.2, 1.0, 5.8, 0.45).v;
+ const bloom = Math.exp(-(((t - 1.4) / 0.6) ** 2));
put(glow, { o: g * (0.55 + 0.45 * bloom), s: 0.92 + 0.12 * bloom, y: lerp(0, 30, toWheel) });
- blurFade(tagline, t, { inAt: 2.42, inDur: 0.7, outAt: 3.9, outDur: 0.38, dy: 16, blur: 12 });
+ blurFade(tagline, t, { inAt: 0.75, inDur: 0.5, outAt: 1.85, outDur: 0.3, dy: 16, blur: 12 });
// ---- the wheel ----
- const live = presence(t, 4.4, 0.6, 12.86, 0.45).a;
- const scatter = ease.inOutCubic(prog(t, 12.86, 13.36));
+ const live = presence(t, 1.9, 0.5).a;
+ const scatter = ease.inOutCubic(prog(t, 6.0, 6.3)); // all but the picked row, for good
const spinBlur = Math.min(9, Math.abs(v) * 0.75);
rows.forEach((row, i) => {
const d = i - p;
@@ -152,37 +155,36 @@ export function render(t) {
// the band behind the picked row, as wide as the prompt in it
const i0 = clamp(Math.floor(p), 0, LAST), i1 = clamp(Math.ceil(p), 0, LAST);
const pw = lerp(promptW[i0], promptW[i1], p - Math.floor(p));
- const bandIn = ease.expo(prog(t, 4.46, 5.1));
+ const bandIn = ease.expo(prog(t, 1.95, 2.5));
const bandL = xW - 36, bandR = xP + pw + TAIL;
setStyle(band, "width", `${(bandR - bandL).toFixed(1)}px`);
put(band, { o: bandIn, x: bandL, y: MID - 52, sx: lerp(0.94, 1, bandIn) });
const settled = clamp(1 - Math.abs(v) * 0.7);
const blink = ((t - T0) / BEAT) % 1 < 0.56 ? 1 : 0;
- put(caret, { o: presence(t, 5.1, 0.2, 12.05, 0.15).v * settled * blink, x: xP + pw + 12, y: MID - 32 });
+ put(caret, { o: presence(t, 2.5, 0.2, 5.45, 0.12).v * settled * blink, x: xP + pw + 12, y: MID - 32 });
- const k = presence(t, 12.22, 0.4, 13.0, 0.3, ease.outBack);
- const press = Math.sin(Math.PI * prog(t, 12.66, 12.92));
+ const k = presence(t, 5.4, 0.3, 6.3, 0.25, ease.outBack);
+ const press = Math.sin(Math.PI * prog(t, 5.76, 5.98));
put(key, { o: k.v, x: xP + promptW[LAST] + 16, y: MID - 32 + press * 3, s: lerp(0.6, 1, k.a) * (1 - press * 0.08), blur: (1 - k.a) * 8 + k.b * 8 });
setStyle(key, "background-color", mix("#ffffff", "#ececf0", press));
- const st = presence(t, 13.3, 0.4);
- const done = ease.outBack(prog(t, MATCH_AT, MATCH_AT + 0.4));
+ const matched = MATCH_AT + HOW_SHIFT;
+ const st = presence(t, HEADER_IN + 0.3, 0.4);
+ const done = ease.outBack(prog(t, matched, matched + 0.4));
put(status, { o: st.v, x: xP + promptW[LAST] + 16, y: MID - 32, s: lerp(0.5, 1, st.a) });
- put(spinner, { o: 1 - prog(t, MATCH_AT, MATCH_AT + 0.15), raw: `rotate(${(t * 400) % 360}deg)` });
+ put(spinner, { o: 1 - prog(t, matched, matched + 0.15), raw: `rotate(${(t * 400) % 360}deg)` });
put(check, { o: clamp(done * 1.4), s: lerp(0.4, 1, done) });
- // ---- the whole line rises into the header, and leaves with "how it works" ----
- const up = ease.inOut(prog(t, 12.86, 13.46));
- const out = presence(t, 0, 0, 28.38, 0.42);
- put(line, {
- o: out.v,
- x: (W / 2 - L.lineCx) * up,
- y: (HEADER_Y - MID) * up + out.b * -16,
- s: lerp(1, HEADER_S, up),
- blur: out.b * 10,
- });
+ // ---- the line dives into the screen as the clones come in, and comes back as the header ----
+ if (t < HEADER_IN - 1) {
+ const gone = ease.inOutCubic(prog(t, 6.0, 6.3));
+ put(line, { o: 1 - gone, s: 1 + 0.12 * gone, blur: 14 * gone });
+ } else {
+ const h = presence(t, HEADER_IN, 0.55, HEADER_OUT, 0.42);
+ put(line, { o: h.v, x: W / 2 - L.lineCx, y: HEADER_Y - MID + (1 - h.a) * 14 - h.b * 16, s: HEADER_S, blur: 10 * Math.max(1 - h.a, h.b) });
+ }
setStyle(line, "transform-origin", `${L.lineCx.toFixed(1)}px ${MID}px`);
- blurFade(caption, t, { inAt: 4.7, inDur: 0.6, outAt: 12.86, outDur: 0.35, dy: 14, blur: 10 });
+ blurFade(caption, t, { inAt: 2.2, inDur: 0.5, outAt: 5.85, outDur: 0.3, dy: 14, blur: 10 });
}
diff --git a/site/video/src/lib.js b/site/video/src/lib.js
index e4b24ea..86a9f74 100644
--- a/site/video/src/lib.js
+++ b/site/video/src/lib.js
@@ -5,12 +5,14 @@ export const W = 1920;
export const H = 1080;
export const FPS = 60;
-// The soundtrack (assets/soundtrack.mp3, see the README): 90 bpm, cut so a downbeat lands at 2.166 s.
+// The grid the cuts land on: 90 bpm, bar 0 at 2.166 s (the video was first cut to a track at that tempo).
export const BEAT = 60 / 90;
export const T0 = 2.166;
export const beat = (n) => T0 + n * BEAT;
export const bar = (n) => T0 + n * 4 * BEAT;
-export const DURATION = 64.166; // bar(23.25)
+export const DURATION = 47.5; // bar(17)
+// "how it works" (how.js) is timed as if it started at 12.86 s; it plays this much later, after the clones
+export const HOW_SHIFT = 16 * BEAT;
export const INK = "#141414";
export const MUTED = "#737373";
diff --git a/site/video/src/main.js b/site/video/src/main.js
index 3acfcef..7e64025 100644
--- a/site/video/src/main.js
+++ b/site/video/src/main.js
@@ -1,113 +1,23 @@
// The demo video: a 1920x1080 stage drawn from the time alone. Scenes, in order, with the bars of the
-// soundtrack they sit on (90 bpm, bar n starts at 2.166 + n * 2.667 s):
+// timing grid they sit on (90 bpm, bar n starts at 2.166 + n * 2.667 s):
//
-// intro 0 – 28.8 "/reanimate", the prompts on a picker wheel (bars 0–4), then the header above "how it works"
-// how 12.8 – 28.8 record, spec, build, verify, repeat (bars 4–10)
-// examples 28.5 – 48.1 the clones, a few at a time (bars 10–17)
-// helix 47.2 – 57.1 every clone in a mosaic (bar 17), then their frames on a turning helix (bars 18–20)
-// install 56.3 – end the install command (bars 20.5–23.25)
-import { DURATION, FPS, H, W, setManifest, settleImages, show } from "./lib.js";
+// intro 0 – 6.2 "/reanimate", the prompts on a picker wheel, one a beat (to bar 1.5); later the
+// header above "how it works"
+// showcase 6.2 – 15.5 the clones, big, one every two beats (bars 1.5–5)
+// helix 15.4 – 25 the Resend cube up close, the camera pulls back to all 18 in a mosaic (bar 5.5),
+// which winds into a turning helix (bars 6.5–7.75)
+// how 23.5 – 39.5 record, spec, build, verify, repeat (bars 8–14; how.js keeps its own clock)
+// install 39.2 – end the install command (bars 14.25–17)
+import { DURATION } from "./lib.js";
+import { start } from "./stage.js";
import * as intro from "./intro.js";
-import * as how from "./how.js";
-import * as examples from "./examples.js";
+import * as showcase from "./showcase.js";
import * as helix from "./helix.js";
+import * as how from "./how.js";
import * as install from "./install.js";
-const scenes = [intro, how, examples, helix, install];
-const roots = new Map();
-const stage = document.getElementById("stage");
-const RENDER = document.documentElement.hasAttribute("data-render");
-
-function draw(t) {
- for (const s of scenes) {
- const on = t >= s.from && t < s.to;
- show(roots.get(s), on);
- if (on) s.render(t);
- }
-}
-
-async function boot() {
- await Promise.all(["600 100px Inter", "400 20px Inter", "400 20px 'JetBrains Mono'", "italic 400 20px 'Instrument Serif'"].map((f) => document.fonts.load(f)));
- await document.fonts.ready;
- setManifest(await (await fetch("clips/manifest.json")).json());
- for (const s of scenes) {
- const root = document.createElement("section");
- root.className = `scene scene--${s.name}`;
- stage.append(root);
- roots.set(s, root);
- s.init(root);
- }
- window.__video = {
- duration: DURATION,
- fps: FPS,
- size: [W, H],
- async seek(t) {
- draw(t);
- await settleImages();
- },
- };
- if (!RENDER) player();
- else draw(0);
-}
-
-function player() {
- const audio = document.getElementById("audio");
- const scrub = document.getElementById("scrub");
- const time = document.getElementById("time");
- const play = document.getElementById("play");
- const viewport = document.getElementById("viewport");
- let t = Number(new URLSearchParams(location.search).get("t") || 0);
-
- const fit = () => {
- const k = Math.min(innerWidth / W, (innerHeight - 56) / H);
- stage.style.transform = `scale(${k})`;
- viewport.style.width = `${W * k}px`;
- viewport.style.height = `${H * k}px`;
- };
- fit();
- addEventListener("resize", fit);
-
- const paint = () => {
- draw(t);
- scrub.value = String(t);
- time.textContent = t.toFixed(2);
- };
- const loop = () => {
- if (audio.paused) return;
- t = audio.currentTime;
- if (t >= DURATION) audio.pause();
- paint();
- requestAnimationFrame(loop);
- };
- const toggle = () => {
- if (audio.paused) {
- audio.currentTime = t >= DURATION - 0.05 ? 0 : t;
- audio.play();
- play.textContent = "Pause";
- requestAnimationFrame(loop);
- } else {
- audio.pause();
- t = audio.currentTime;
- play.textContent = "Play";
- paint();
- }
- };
- const seek = (to) => {
- t = Math.min(DURATION, Math.max(0, to));
- audio.currentTime = t;
- paint();
- };
- play.addEventListener("click", toggle);
- scrub.addEventListener("input", () => seek(Number(scrub.value)));
- addEventListener("keydown", (e) => {
- if (e.code === "Space") {
- e.preventDefault();
- toggle();
- }
- if (e.code === "ArrowRight") seek(t + (e.shiftKey ? 1 : 1 / FPS));
- if (e.code === "ArrowLeft") seek(t - (e.shiftKey ? 1 : 1 / FPS));
- });
- paint();
-}
-
-boot();
+start({
+ scenes: [intro, showcase, helix, how, install],
+ duration: DURATION,
+ fonts: ["600 100px Inter", "400 20px Inter", "400 20px 'JetBrains Mono'", "italic 400 20px 'Instrument Serif'"],
+});
diff --git a/site/video/src/showcase.js b/site/video/src/showcase.js
new file mode 100644
index 0000000..15ce6ba
--- /dev/null
+++ b/site/video/src/showcase.js
@@ -0,0 +1,76 @@
+// The clones, big, one every two beats from bar 1.5, right after the prompt is entered. Each comes in with
+// a quick push and blur, drifts a little while it plays from a good moment, and gives way to the next. The
+// last one, the Resend cube, is a tile of the mosaic seen up close (helix.js), and the camera pulls back.
+import { bar, clipInfo, ease, el, frameUrl, lerp, prog, put, setSrc } from "./lib.js";
+
+export const name = "showcase";
+export const from = bar(1.5) - 0.2;
+
+// A clip on a card: its frames, scaled, with a soft shadow under the card inside the frame.
+// inset: the card's margin inside the recording (the Clerk cards were filmed with 24 px around them).
+const LOOK = {
+ stripe: { inset: 0, radius: 6, shadow: true },
+ clerk: { inset: 24, radius: 16, shadow: true },
+ workos: { inset: 0, radius: 0, shadow: false },
+ resend: { inset: 0, radius: 16, shadow: true },
+ reactbits: { inset: 0, radius: 16, shadow: true },
+ liveblocks: { inset: 0, radius: 14, shadow: true },
+};
+function card(parent, slug, scale) {
+ const c = clipInfo(slug);
+ const look = LOOK[slug.split("-")[0]];
+ const w = c.width * scale, h = c.height * scale;
+ const g = el("div", "ex-card", parent);
+ Object.assign(g.style, { width: `${w}px`, height: `${h}px` });
+ if (look.shadow) {
+ const sh = el("div", "ex-shadow", g);
+ const i = look.inset * scale;
+ Object.assign(sh.style, { left: `${i}px`, top: `${i}px`, right: `${i}px`, bottom: `${i}px`, borderRadius: `${look.radius * scale}px` });
+ }
+ g._img = el("img", "fill", g);
+ g._img.style.borderRadius = `${look.radius * scale}px`;
+ Object.assign(g, { _w: w, _h: h });
+ return g;
+}
+
+const BOX = [1680, 940]; // the most of the screen a clip fills, px
+// [clip, where in it to start, speed], light and dark taking turns
+const SLOTS = [
+ ["reactbits-fading-stars", 0.5, 1],
+ ["stripe-agentic-commerce", 0.4, 1.4],
+ ["liveblocks-comments", 0.15, 1],
+ ["workos-atlas", 0.6, 1.2],
+ ["clerk-api-keys", 0.2, 1.2],
+ ["stripe-issuing", 0.5, 1.1],
+ ["clerk-magic-links", 0.3, 1.2],
+].map(([slug, start, speed], k) => ({ slug, start, speed, at: bar(1.5 + k / 2) }));
+export const CUBE_AT = bar(1.5 + SLOTS.length / 2); // bar 5: the Resend cube, in helix.js
+export const to = CUBE_AT + 0.3;
+
+let cards;
+
+export function init(root) {
+ cards = SLOTS.map((s) => {
+ const c = clipInfo(s.slug);
+ return Object.assign(card(root, s.slug, Math.min(BOX[0] / c.width, BOX[1] / c.height)), { _s: s });
+ });
+}
+
+export function render(t) {
+ cards.forEach((c, k) => {
+ const { slug, start, speed, at } = c._s;
+ const next = k + 1 < SLOTS.length ? SLOTS[k + 1].at : CUBE_AT;
+ if (t < at - 0.1 || t > next + 0.25) return put(c, { o: 0 });
+ const a = ease.expo(prog(t, at - 0.06, at + 0.4));
+ const b = ease.inOutCubic(prog(t, next - 0.08, next + 0.16));
+ const drift = prog(t, at, next) - 0.5; // a slow push across the slot, alternating sides
+ setSrc(c._img, frameUrl(slug, start + speed * Math.max(0, t - at)));
+ put(c, {
+ o: a * (1 - b),
+ x: 960 - c._w / 2 + (k % 2 ? 1 : -1) * 22 * drift,
+ y: 540 - c._h / 2,
+ s: lerp(1.07, 1, a) * (1 + 0.025 * (drift + 0.5)) * lerp(1, 0.97, b),
+ blur: (1 - a) * 14 + b * 10,
+ });
+ });
+}
diff --git a/site/video/src/stage.js b/site/video/src/stage.js
new file mode 100644
index 0000000..1de1645
--- /dev/null
+++ b/site/video/src/stage.js
@@ -0,0 +1,106 @@
+// The stage every video page shares: a 1920x1080 frame drawn from the time alone. `start` mounts the
+// scenes and puts `window.__video` on the page for scripts/render.ts; without ?render it adds a player:
+// space plays and pauses, ←/→ step a frame (shift: a second), ?t=12.5 starts there.
+import { FPS, H, W, setManifest, settleImages, show } from "./lib.js";
+
+/**
+ * scenes: modules with `name`, `from`, `to`, `init(root)`, `render(t)` and optionally `shift`, a delay that
+ * lets a scene keep its own clock. fonts: font shorthands to load before anything is measured.
+ */
+export async function start({ scenes, duration, fonts }) {
+ const roots = new Map();
+ const stage = document.getElementById("stage");
+
+ const draw = (t) => {
+ for (const s of scenes) {
+ const lt = t - (s.shift ?? 0);
+ const on = lt >= s.from && lt < s.to;
+ show(roots.get(s), on);
+ if (on) s.render(lt);
+ }
+ };
+
+ await Promise.all(fonts.map((f) => document.fonts.load(f)));
+ await document.fonts.ready;
+ setManifest(await (await fetch("clips/manifest.json")).json());
+ for (const s of scenes) {
+ const root = document.createElement("section");
+ root.className = `scene scene--${s.name}`;
+ stage.append(root);
+ roots.set(s, root);
+ s.init(root);
+ }
+ window.__video = {
+ duration,
+ fps: FPS,
+ size: [W, H],
+ async seek(t) {
+ draw(t);
+ await settleImages();
+ },
+ };
+ if (document.documentElement.hasAttribute("data-render")) draw(0);
+ else player(stage, draw, duration);
+}
+
+function player(stage, draw, duration) {
+ const scrub = document.getElementById("scrub");
+ const time = document.getElementById("time");
+ const play = document.getElementById("play");
+ const viewport = document.getElementById("viewport");
+ let t = Number(new URLSearchParams(location.search).get("t") || 0);
+ scrub.max = String(duration);
+
+ const fit = () => {
+ const k = Math.min(innerWidth / W, (innerHeight - 56) / H);
+ stage.style.transform = `scale(${k})`;
+ viewport.style.width = `${W * k}px`;
+ viewport.style.height = `${H * k}px`;
+ };
+ fit();
+ addEventListener("resize", fit);
+
+ const paint = () => {
+ draw(t);
+ scrub.value = String(t);
+ time.textContent = t.toFixed(2);
+ };
+ // playing: the video time runs with the wall clock from the moment play was pressed (or the last seek)
+ let playing = false, wall0 = 0, t0 = 0;
+ const loop = (now) => {
+ if (!playing) return;
+ t = Math.min(duration, t0 + (now - wall0) / 1000);
+ if (t >= duration) playing = false;
+ play.textContent = playing ? "Pause" : "Play";
+ paint();
+ requestAnimationFrame(loop);
+ };
+ const toggle = () => {
+ playing = !playing;
+ if (playing) {
+ if (t >= duration - 0.05) t = 0;
+ wall0 = performance.now();
+ t0 = t;
+ requestAnimationFrame(loop);
+ }
+ play.textContent = playing ? "Pause" : "Play";
+ paint();
+ };
+ const seek = (to) => {
+ t = Math.min(duration, Math.max(0, to));
+ wall0 = performance.now();
+ t0 = t;
+ paint();
+ };
+ play.addEventListener("click", toggle);
+ scrub.addEventListener("input", () => seek(Number(scrub.value)));
+ addEventListener("keydown", (e) => {
+ if (e.code === "Space") {
+ e.preventDefault();
+ toggle();
+ }
+ if (e.code === "ArrowRight") seek(t + (e.shiftKey ? 1 : 1 / FPS));
+ if (e.code === "ArrowLeft") seek(t - (e.shiftKey ? 1 : 1 / FPS));
+ });
+ paint();
+}