Skip to content

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

Add the demo video and show it in the README

NiazMorshed2007522a353be364
diff --git a/.github/assets/demo.webp b/.github/assets/demo.webp
new file mode 100644
index 0000000..35bf682
Binary files /dev/null and b/.github/assets/demo.webp differ
diff --git a/README.md b/README.md
index 1a821bb..ff52c9e 100644
--- a/README.md
+++ b/README.md
@@ -10,14 +10,19 @@
</p>
<p align="center">
- <img src=".github/assets/entrance.webp" width="760" alt="Two recordings of the same three cards fading in: stripe.com on top, the copy reanimate built below. The chat bubbles, the particle ring, the Visa card and the dotted globe appear at the same moments in both.">
+ <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>Three cards from stripe.com. Top: the original. Bottom: the copy, filmed the same way.</sub></p>
+<p align="center"><sub>A one-minute demo. <a href="https://reanimate.niazmorshed.dev/demo.mp4">Watch it with sound</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.
reanimate records the original, rebuilds it in your code, then records the copy the same way and compares the two. Each round shows what's still off, so the agent keeps going until the numbers match. You end up with a close starting point to make your own.
+<p align="center">
+ <img src=".github/assets/entrance.webp" width="760" alt="Two recordings of the same three cards fading in: stripe.com on top, the copy reanimate built below. The chat bubbles, the particle ring, the Visa card and the dotted globe appear at the same moments in both.">
+</p>
+<p align="center"><sub>Three cards from stripe.com. Top: the original. Bottom: the copy, filmed the same way.</sub></p>
+
## Install
```sh
@@ -58,7 +63,7 @@ By default it matches the motion and leaves the look to you. Ask for more or les
## Examples
-Three cards from the stripe.com homepage, the integrations visual from workos.com/atlas and the feature cards from clerk.com, each cloned by its own agent running this skill, most in 30 to 60 minutes. The [site](site/) shows the Stripe and WorkOS ones next to a recording of the original, and runs the Clerk cards live in the page.
+Three cards from the stripe.com homepage, the integrations visual from workos.com/atlas, the feature cards from clerk.com, the demo under the liveblocks.io/comments hero, the cube in the resend.com hero and React Bits Pro's Fading Stars, each cloned by its own agent running this skill, most in 30 to 80 minutes. The [site](site/) shows each one next to a recording of the original, except the Clerk cards, which run live in the page.
| Clone | Built with | Measured against the original |
|---|---|---|
@@ -67,6 +72,9 @@ Three cards from the stripe.com homepage, the integrations visual from workos.co
| **Stablecoins and crypto**: a dotted globe with flying payments | three.js, Web Workers | globe pose exact; arcs and labels within stripe.com's own spread |
| **Connected to all your tools** (workos.com): a robot reaching out to a dome of app icons | HTML, SVG, WebGPU | 0.05 % of pixels differ; each link within 10 ms |
| **Feature cards** (clerk.com): passcodes, magic links, a radar, a laptop opening and more, each playing on hover | HTML, SVG, canvas, WebGL2 | each card's motion within 40 ms; under 0.6 % of pixels differ |
+| **Comments in any app** (liveblocks.io): an app window switching between five apps, its comment panel gliding to each | HTML, SVG, springs | every change on time (0 ms); panel within 0.7 px; 0.55 % of pixels differ |
+| **Hero cube** (resend.com): a dark Rubik's cube turning, its slices making half-turns | three.js | every rotation exact over 25 s; 0.11 % of pixels differ |
+| **Fading stars** (pro.reactbits.dev): violet stars rising in a fan, surging with the pointer | WebGL2 | 0 px differ at rest; 0.014 % during a click burst |
## Canvas, WebGL and 3D
@@ -106,4 +114,4 @@ Only `skills/reanimate/` is installed by the skills CLI; `site/` is the website
## License
-[MIT](LICENSE). The examples recreate parts of stripe.com, workos.com and clerk.com as a study of the technique; it is not affiliated with or endorsed by Stripe, WorkOS or Clerk. All trademarks belong to their owners.
+[MIT](LICENSE). The examples recreate parts of stripe.com, workos.com, clerk.com, liveblocks.io, resend.com and pro.reactbits.dev as a study of the technique; it is not affiliated with or endorsed by Stripe, WorkOS, Clerk, Liveblocks, Resend or React Bits. All trademarks belong to their owners.
diff --git a/site/.gitignore b/site/.gitignore
index 9fd2713..e8a6827 100644
--- a/site/.gitignore
+++ b/site/.gitignore
@@ -46,3 +46,9 @@ next-env.d.ts
# wrangler
.wrangler/
+
+# 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 1cdc447..b87db8e 100644
--- a/site/README.md
+++ b/site/README.md
@@ -22,7 +22,7 @@ bun run lint
2. Put its media in `public/media/<slug>/`: `poster.webp` (the clone at rest, for the thumbnails) and, for a recorded example, `compare.mp4` (the original and the clone, recorded the same way and side by side in one file).
3. Add an entry to `src/examples.ts`. The home page shows it at the end, under Examples; what it does and its numbers sit behind a "details" tooltip. `show.kind` picks the picture: `"video"` plays `compare.mp4`; `"live"` runs the clone itself in the page, in an iframe (the clerk.com cards do this; `clerk-bento/?card=<slug>&embed` frames one card for it).
-To record the media, add a row to `CLIPS` in `scripts/record-media.ts`: the original's URL, the clone's path and the elements to film, plus `pin` when the animation picks things at random, so both sides pick the same. With the site running on `bun run preview`:
+To record the media, add a row to `CLIPS` in `scripts/record-media.ts`: the original's URL, the clone's path and the elements to film, plus `pin` when the animation picks things at random, so both sides pick the same, and `sync` when each page runs a loop that starts on its own clock rather than on the scroll or hover, so the two takes are lined up by their frames. With the site running on `bun run preview`:
```sh
bun run media # every clip
@@ -54,11 +54,12 @@ Then either:
| `src/app/page.tsx` | The whole page: copy, sections, tables. |
| `src/examples.ts` | The examples, in the order they appear. |
| `src/components/` | `CompareVideo` (plays a `compare.mp4` while it's on screen), `LiveCard` (a clone in an iframe, scaled down on narrow screens), `Nav`, `Sidenote`, `CopyCommand`. |
-| `public/examples/` | The clones as standalone pages. `stripe-bento/?card=agentic-commerce\|issuing\|crypto` shows one card; `workos-atlas/` is the workos.com integrations visual; `clerk-bento/` is clerk.com's grid of feature cards (`?card=<slug>` for one). |
+| `public/examples/` | The clones as standalone pages. `stripe-bento/?card=agentic-commerce\|issuing\|crypto` shows one card; `workos-atlas/` is the workos.com integrations visual; `clerk-bento/` is clerk.com's grid of feature cards (`?card=<slug>` for one); `liveblocks-comments/` is the demo under the liveblocks.io/comments hero; `resend-cube/` is the resend.com hero cube; `reactbits-fading-stars/` is React Bits Pro's Fading Stars. |
| `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`). |
## About the examples
-The live examples recreate parts of stripe.com, workos.com and clerk.com as a study of the technique. The Stripe cards use Inter instead of Stripe's licensed Söhne, but port Stripe's shaders and use Stripe's images; the WorkOS visual uses WorkOS's robot images, app icons and screen shaders; the Clerk cards use Geist and Geist Mono instead of Clerk's licensed fonts, and port Clerk's inline SVG, light-streak canvas and dot-field shader. Not affiliated with or endorsed by Stripe, WorkOS or Clerk.
+The live examples recreate parts of stripe.com, workos.com and clerk.com as a study of the technique. The Stripe cards use Inter instead of Stripe's licensed Söhne, but port Stripe's shaders and use Stripe's images; the WorkOS visual uses WorkOS's robot images, app icons and screen shaders; the Clerk cards use Geist and Geist Mono instead of Clerk's licensed fonts, and port Clerk's inline SVG, light-streak canvas and dot-field shader. The Liveblocks demo uses Inter instead of the licensed Suisse Int'l, and reuses liveblocks.io's avatars, drawings and icons. The Resend cube draws resend.com's own Spline scene (geometry, textures and shaders) with three.js, over resend.com's hero images. Fading Stars ports the shaders and simulation that pro.reactbits.dev runs for its live preview. Not affiliated with or endorsed by Stripe, WorkOS, Clerk, Liveblocks, Resend or React Bits.
diff --git a/site/public/demo.mp4 b/site/public/demo.mp4
new file mode 100644
index 0000000..53cd2be
Binary files /dev/null and b/site/public/demo.mp4 differ
diff --git a/site/video/README.md b/site/video/README.md
new file mode 100644
index 0000000..02f6154
--- /dev/null
+++ b/site/video/README.md
@@ -0,0 +1,43 @@
+# 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/`.
+
+| 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`.
+
+## Make it
+
+```sh
+bun video/scripts/clips.ts # records the 18 clones into video/clips/ (about 3 minutes)
+bun video/scripts/render.ts # video/out/reanimate-demo.mp4, 1920x1080, 60 fps
+bun video/scripts/publish.ts # public/demo.mp4 for the site, and the README's preview, ../.github/assets/demo.webp
+```
+
+`clips.ts` films each clone on the skill's virtual clock (`skills/reanimate/scripts/capture.ts --clock virtual`) at 2x and 60 fps, so a clip comes out the same on every run. For "how it works" it also films clerk.com's Session management card and its copy the same way (`how-clerk-*`), and cuts the originals and copies of the other two out of the site's recordings (`public/media/stripe-bento/compare.mp4` and `resend-cube/compare.mp4`, as `how-stripe-*` and `how-resend-*`; `--only compare` redoes just those). `--only <slug>,…` redoes some.
+
+`render.ts` options: `--scale 2` draws at 3840x2160 and scales down (sharper, about 4x slower); `--size 3840x2160` keeps it; `--from 12 --to 29` renders a section; `--stills 1.5,13.2` writes PNGs of single moments to `video/out/stills/`. It needs Playwright's Chromium and `ffmpeg` on PATH. `publish.ts` makes a smaller copy that the site serves at `/demo.mp4` (the README links to it), and the README's preview: a few moments of the video, cross-faded into a 20-second loop. It needs `ffmpeg`, `cwebp` and `webpmux`.
+
+## Edit it
+
+```sh
+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.
diff --git a/site/video/assets/fonts/InstrumentSerif-Italic.woff2 b/site/video/assets/fonts/InstrumentSerif-Italic.woff2
new file mode 100644
index 0000000..ce3c417
Binary files /dev/null and b/site/video/assets/fonts/InstrumentSerif-Italic.woff2 differ
diff --git a/site/video/assets/fonts/Inter-opsz.woff2 b/site/video/assets/fonts/Inter-opsz.woff2
new file mode 100644
index 0000000..b0d0e2e
Binary files /dev/null and b/site/video/assets/fonts/Inter-opsz.woff2 differ
diff --git a/site/video/assets/fonts/JetBrainsMono.woff2 b/site/video/assets/fonts/JetBrainsMono.woff2
new file mode 100644
index 0000000..c3f0666
Binary files /dev/null and b/site/video/assets/fonts/JetBrainsMono.woff2 differ
diff --git a/site/video/assets/fonts/OFL.txt b/site/video/assets/fonts/OFL.txt
new file mode 100644
index 0000000..5a965fb
--- /dev/null
+++ b/site/video/assets/fonts/OFL.txt
@@ -0,0 +1,92 @@
+The fonts here are licensed under the SIL Open Font License, Version 1.1, copied below.
+
+- Inter-opsz.woff2: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
+- JetBrainsMono.woff2: Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
+- InstrumentSerif-Italic.woff2: Copyright 2022 The Instrument Serif Project Authors (https://github.com/Instrument/instrument-serif)
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/site/video/index.html b/site/video/index.html
new file mode 100644
index 0000000..67286a4
--- /dev/null
+++ b/site/video/index.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>reanimate · demo video</title>
+ <meta name="robots" content="noindex">
+ <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:
+ 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>
+</head>
+<body>
+ <div id="viewport"><div id="stage"></div></div>
+ <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>
+ </div>
+</body>
+</html>
diff --git a/site/video/scripts/clerk-clock.js b/site/video/scripts/clerk-clock.js
new file mode 100644
index 0000000..87f637a
--- /dev/null
+++ b/site/video/scripts/clerk-clock.js
@@ -0,0 +1,21 @@
+// Run on clerk.com and on the copy before "how it works" films them (clips.ts, --pre-js), so both get
+// the same layout and random numbers.
+Math.random = () => 0.37;
+document.body.style.padding = "1800px 0 900px";
+// capture.ts --clock virtual fix: Motion (clerk.com) syncs its WAAPI animations with
+// `animation.startTime = <performance.now() at creation>`. performance.now() is virtual but the native
+// document timeline is not, so the animation would look started long ago and finish at once. Translate the
+// assignment into the equivalent currentTime on the virtual clock. No-op for pages that never set startTime.
+(() => {
+ const desc = Object.getOwnPropertyDescriptor(Animation.prototype, "startTime");
+ if (!desc || !desc.set || !window.__mcClock || !window.__mcClock.virtual) return;
+ Object.defineProperty(Animation.prototype, "startTime", {
+ configurable: true,
+ get() { return desc.get.call(this); },
+ set(v) {
+ if (typeof v === "number" && this.timeline === document.timeline) {
+ this.currentTime = Math.max(0, window.__mcClock.now() - v) * (this.playbackRate || 1);
+ } else desc.set.call(this, v);
+ },
+ });
+})();
diff --git a/site/video/scripts/clips.ts b/site/video/scripts/clips.ts
new file mode 100644
index 0000000..181ac90
--- /dev/null
+++ b/site/video/scripts/clips.ts
@@ -0,0 +1,157 @@
+// Records the examples for the demo video: each clone on the skill's virtual clock (frame k is exactly
+// t = k/60 s, the same on every run), at 2x, cropped to the card. Writes video/clips/<slug>/f/NNNN.jpg
+// (full size), t/NNNN.jpg (small, for the helix) and video/clips/manifest.json.
+//
+// bun video/scripts/clips.ts [--only clerk-mfa,…] [--jobs 4]
+//
+// Also, for the "how it works" scene: films clerk.com's Session management card and its copy the same way,
+// and cuts the stripe.com Agentic commerce card and the resend.com cube, each with its copy, out of their
+// compare.mp4 recordings in public/media/. Needs ffmpeg on PATH and Playwright's Chromium.
+import { spawn, spawnSync } from "node:child_process";
+import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { join } from "node:path";
+import { parseArgs } from "node:util";
+import { SITE, serve } from "./serve";
+
+const { values: args } = parseArgs({ options: { only: { type: "string" }, jobs: { type: "string", default: "4" }, port: { type: "string", default: "4701" } } });
+
+const CAPTURE = join(SITE, "..", "skills", "reanimate", "scripts", "capture.ts");
+const OUT = join(SITE, "video", "clips");
+const FPS = 60;
+const THUMB_W = 480; // px wide, the helix tiles
+
+type Clip = { slug: string; url: string; flags: string[] };
+
+// The Clerk cards sit on white here, as they do in the video; on the dark page their corners would show.
+const WHITE = `document.documentElement.style.background = "#fff"; document.body.style.background = "#fff"; document.querySelector(".clerk-bento").style.background = "#fff";`;
+const clerk = (card: string, w: number, h: number): Clip => ({
+ slug: card.startsWith("clerk-") ? card : `clerk-${card}`,
+ url: `/public/examples/clerk-bento/?card=${card}&embed`,
+ flags: ["--viewport", `${w}x${h}`, "--trigger", "hover", "--selector", `[data-card="${card}"]`, "--hover-at", "0.5,0.5", "--duration", "5400", "--pre-js", WHITE],
+});
+const stripe = (card: string, flags: string[]): Clip => ({
+ slug: `stripe-${card}`,
+ url: `/public/examples/stripe-bento/?card=${card}`,
+ flags: ["--viewport", "1000x720", "--selector", `.modular-solutions-bento__card-${card}`, ...flags],
+});
+
+// "How it works": clerk.com's card and the copy, hovered the same way. The copy page draws the same card.
+// clerk.com keeps requests open, so each frame waits at most 150 ms for the network, not 3 s.
+const CLERK_PRE = join(SITE, "video", "scripts", "clerk-clock.js");
+const SESSION = 'div:has(> div.text-center a[href="/user-authentication"]) > div.mt-16 > div.grid:first-child > div:nth-child(4)';
+const how = (slug: string, url: string, selector: string): Clip => ({
+ slug,
+ url,
+ flags: ["--viewport", "1440x900", "--selector", selector, "--trigger", "hover", "--hover-at", "0.3,0.5", "--wait-before", "1208", "--network-wait", "150", "--duration", "5000", "--pre-js", CLERK_PRE],
+});
+
+const CLIPS: Clip[] = [
+ stripe("agentic-commerce", ["--trigger", "load", "--duration", "6500"]),
+ stripe("issuing", ["--trigger", "move", "--path", "0.2,0.3;0.78,0.32;0.75,0.74;0.25,0.7;0.5,0.45", "--path-ms", "900", "--duration", "4800"]),
+ stripe("crypto", ["--trigger", "hover", "--hover-at", "0.5,0.6", "--duration", "4800"]),
+ { slug: "workos-atlas", url: "/public/examples/workos-atlas/", flags: ["--viewport", "1440x900", "--selector", ".atlas-tools", "--trigger", "load", "--duration", "8000"] },
+ clerk("mfa", 443, 308),
+ clerk("session-management", 443, 576),
+ clerk("otp", 443, 308),
+ clerk("fraud", 443, 576),
+ clerk("magic-links", 443, 576),
+ clerk("social-sign-on", 443, 308),
+ clerk("advanced-security", 443, 308),
+ clerk("bot-detection", 443, 308),
+ clerk("passwords", 443, 308),
+ clerk("api-keys", 845, 328),
+ clerk("clerk-cli", 443, 328),
+ how("how-clerk-reference", "https://clerk.com/", SESSION),
+ how("how-clerk-copy", "/public/examples/clerk-bento/?card=session-management", ".clerk-card--session-management"),
+ // frame 0 is 5.6 s after load, 0.4 s before the window switches from the text editor to the media player
+ { slug: "liveblocks-comments", url: "/public/examples/liveblocks-comments/", flags: ["--viewport", "1440x900", "--selector", ".liveblocks-slideshow", "--trigger", "none", "--wait-before", "5300", "--duration", "5600"] },
+ // filming starts at 1.5 s, once the cube has faded in; it turns on its own, no pointer
+ { slug: "resend-cube", url: "/public/examples/resend-cube/", flags: ["--viewport", "1440x900", "--selector", ".resend-cube", "--trigger", "none", "--duration", "5600"] },
+ // --wait-before 1208, not 1200: on a whole number of 60 fps ticks the stars' rAF loop gains or drops a
+ // tick at random from run to run
+ { slug: "reactbits-fading-stars", url: "/public/examples/reactbits-fading-stars/", flags: ["--viewport", "1200x720", "--selector", ".fading-stars", "--trigger", "drag", "--path", "0.5,0.8;0.25,0.5;0.75,0.4;0.6,0.75", "--path-ms", "600", "--pre-roll", "800", "--wait-before", "1208", "--duration", "4700"] },
+];
+
+const only = args.only?.split(",");
+const todo = CLIPS.filter((c) => !only || only.includes(c.slug));
+
+function run(cmd: string, argv: string[]) {
+ const r = spawnSync(cmd, argv, { maxBuffer: 1 << 30 });
+ if (r.status !== 0) throw new Error(`${cmd} ${argv.join(" ")} failed: ${r.stderr?.toString().slice(-1500)}`);
+ return r.stdout.toString();
+}
+
+function capture(origin: string, clip: Clip): Promise<void> {
+ const dir = join(OUT, clip.slug);
+ rmSync(dir, { recursive: true, force: true });
+ mkdirSync(dir, { recursive: true });
+ const argv = [CAPTURE, "--url", clip.url.startsWith("http") ? clip.url : origin + clip.url, "--out", join(dir, "capture"), "--scale", "2", "--fps", String(FPS), "--clock", "virtual", "--gpu", "hardware", "--pre-roll", "0", "--wait-before", "1200", ...clip.flags];
+ return new Promise((resolve, reject) => {
+ const p = spawn("bun", argv, { stdio: ["ignore", "ignore", "pipe"] });
+ let err = "";
+ p.stderr.on("data", (d) => (err += d));
+ p.on("exit", (code) => (code === 0 ? resolve() : reject(new Error(`${clip.slug}: capture failed\n${err.slice(-1500)}`))));
+ });
+}
+
+// PNG frames → f/ (JPEG, full size) and t/ (JPEG, THUMB_W wide); the capture folder is dropped.
+function finish(slug: string) {
+ const dir = join(OUT, slug);
+ const cap = join(dir, "capture");
+ const info = JSON.parse(readFileSync(join(cap, "frames.json"), "utf8"));
+ mkdirSync(join(dir, "f"));
+ mkdirSync(join(dir, "t"));
+ const src = join(cap, "frames", "%04d.png");
+ run("ffmpeg", ["-v", "error", "-y", "-i", src, "-vf", "pad=ceil(iw/2)*2:ceil(ih/2)*2:color=white", "-q:v", "2", join(dir, "f", "%04d.jpg")]);
+ run("ffmpeg", ["-v", "error", "-y", "-i", src, "-vf", `scale=${THUMB_W}:-2:flags=lanczos`, "-q:v", "3", join(dir, "t", "%04d.jpg")]);
+ rmSync(cap, { recursive: true, force: true });
+ const count = readdirSync(join(dir, "f")).length;
+ return { slug, fps: FPS, frames: count, width: Math.round(info.clip.width), height: Math.round(info.clip.height) };
+}
+
+// Cuts the original and the copy out of a site recording (public/media/<media>/compare.mp4: the two takes
+// stacked with a 24 px gap), each cropped to `box` = [x, y, w, h] in the take's px, as <slug>-reference and
+// <slug>-copy. Sizes in the manifest are in CSS px, half the frames'.
+function cutCompare(media: string, slug: string, box?: number[]) {
+ const file = join(SITE, "public", "media", media, "compare.mp4");
+ const [w, h] = run("ffprobe", ["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height", "-of", "csv=p=0", file]).trim().split(",").map(Number);
+ const half = Math.floor(h / 2) - 12;
+ const [bx, by, bw, bh] = box ?? [0, 0, w, half];
+ const out: Record<string, object> = {};
+ for (const [side, y] of [["reference", 0], ["copy", h - half]] as const) {
+ const dir = join(OUT, `${slug}-${side}`);
+ rmSync(dir, { recursive: true, force: true });
+ mkdirSync(join(dir, "f"), { recursive: true });
+ run("ffmpeg", ["-v", "error", "-y", "-i", file, "-vf", `crop=${bw}:${bh}:${bx}:${y + by}`, "-q:v", "2", join(dir, "f", "%04d.jpg")]);
+ out[`${slug}-${side}`] = { slug: `${slug}-${side}`, fps: FPS, frames: readdirSync(join(dir, "f")).length, width: bw / 2, height: bh / 2 };
+ }
+ return out;
+}
+const cutCompares = () => ({
+ ...cutCompare("stripe-bento", "how-stripe", [4, 4, 368, 614]), // the Agentic commerce card
+ ...cutCompare("resend-cube", "how-resend"),
+});
+
+const server = await serve(Number(args.port));
+const origin = `http://localhost:${args.port}`;
+const manifestFile = join(OUT, "manifest.json");
+mkdirSync(OUT, { recursive: true });
+const manifest: Record<string, object> = existsSync(manifestFile) ? JSON.parse(readFileSync(manifestFile, "utf8")) : {};
+
+const queue = [...todo];
+const jobs = Number(args.jobs);
+await Promise.all(
+ Array.from({ length: jobs }, async () => {
+ for (let clip = queue.shift(); clip; clip = queue.shift()) {
+ const t0 = Date.now();
+ await capture(origin, clip);
+ manifest[clip.slug] = finish(clip.slug);
+ console.log(`${clip.slug}: ${(manifest[clip.slug] as { frames: number }).frames} frames in ${((Date.now() - t0) / 1000).toFixed(0)} s`);
+ }
+ }),
+);
+if (!only || only.some((s) => s.startsWith("compare"))) Object.assign(manifest, cutCompares());
+writeFileSync(manifestFile, JSON.stringify(manifest, null, 2) + "\n");
+server.closeAllConnections();
+server.close();
+console.log(`wrote ${manifestFile}`);
diff --git a/site/video/scripts/publish.ts b/site/video/scripts/publish.ts
new file mode 100644
index 0000000..f381140
--- /dev/null
+++ b/site/video/scripts/publish.ts
@@ -0,0 +1,57 @@
+// After render.ts: the web copy of the video for the site (public/demo.mp4, served at /demo.mp4) and the
+// README's preview (../.github/assets/demo.webp), a few moments of the video cross-faded into a loop.
+//
+// bun video/scripts/publish.ts
+//
+// Needs ffmpeg, cwebp and webpmux on PATH.
+import { spawnSync } from "node:child_process";
+import { mkdtempSync, readdirSync, rmSync, statSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { SITE } from "./serve";
+
+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]];
+const FADE = 0.3;
+const WIDTH = 760; // as wide as the README shows it
+const FPS = 15;
+
+function run(cmd: string, argv: string[]) {
+ const r = spawnSync(cmd, argv, { maxBuffer: 1 << 30 });
+ if (r.status !== 0) throw new Error(`${cmd} failed: ${r.stderr?.toString().slice(-2000)}`);
+}
+const mb = (file: string) => `${(statSync(file).size / 1e6).toFixed(1)} MB`;
+
+// the site's copy: smaller, starts playing before it has all downloaded (Workers serve files up to 25 MiB)
+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,
+]);
+console.log(`wrote ${WEB} (${mb(WEB)})`);
+
+// the preview: each moment cross-fades into the next, then frames are encoded one by one and muxed (the
+// way scripts/record-media.ts makes the README's other animations)
+const dir = mkdtempSync(join(tmpdir(), "publish-"));
+const argv = ["-v", "error", "-y"];
+for (const [a, b] of MOMENTS) argv.push("-ss", String(a), "-t", String(b - a), "-i", SRC);
+const graph = MOMENTS.map((_, i) => `[${i}:v]fps=${FPS},scale=${WIDTH}:-2:flags=lanczos,settb=AVTB[v${i}]`);
+let last = "v0";
+let length = MOMENTS[0][1] - MOMENTS[0][0];
+for (let i = 1; i < MOMENTS.length; i++) {
+ graph.push(`[${last}][v${i}]xfade=transition=fade:duration=${FADE}:offset=${(length - FADE).toFixed(3)}[x${i}]`);
+ last = `x${i}`;
+ length += MOMENTS[i][1] - MOMENTS[i][0] - FADE;
+}
+run("ffmpeg", [...argv, "-filter_complex", graph.join(";"), "-map", `[${last}]`, join(dir, "%04d.png")]);
+const pngs = readdirSync(dir).sort().map((f) => join(dir, f));
+run("sh", ["-c", `ls "${dir}"/*.png | xargs -P 8 -I{} cwebp -quiet -q 70 -m 6 -sharp_yuv {} -o {}.webp`]);
+run("webpmux", [...pngs.flatMap((f) => ["-frame", `${f}.webp`, `+${Math.round(1000 / FPS)}+0+0+0-b`]), "-loop", "0", "-o", README]);
+rmSync(dir, { recursive: true });
+console.log(`wrote ${README} (${mb(README)}, ${length.toFixed(1)} s)`);
diff --git a/site/video/scripts/render.ts b/site/video/scripts/render.ts
new file mode 100644
index 0000000..fe73d8d
--- /dev/null
+++ b/site/video/scripts/render.ts
@@ -0,0 +1,142 @@
+// 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.
+//
+// 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
+//
+// 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";
+import { spawn, spawnSync } from "node:child_process";
+import { mkdirSync, rmSync, writeFileSync } from "node:fs";
+import { join } from "node:path";
+import { parseArgs } from "node:util";
+import { SITE, serve } from "./serve";
+
+// what video/src/main.js puts on the page
+type Video = { duration: number; fps: number; seek(t: number): Promise<void> };
+
+const { values: args } = parseArgs({
+ options: {
+ scale: { type: "string", default: "1" },
+ size: { type: "string", default: "1920x1080" },
+ jobs: { type: "string", default: "6" },
+ from: { type: "string" },
+ to: { type: "string" },
+ stills: { type: "string" },
+ out: { type: "string" },
+ crf: { type: "string", default: "14" },
+ port: { type: "string", default: "4702" },
+ },
+});
+
+const OUT = join(SITE, "video", "out");
+const SCALE = Number(args.scale);
+const [OW, OH] = args.size!.split("x").map(Number);
+mkdirSync(OUT, { recursive: true });
+
+const PORT = Number(args.port);
+const server = await serve(PORT);
+const url = `http://localhost:${PORT}/video/?render`;
+const stop = () => (server.closeAllConnections(), server.close());
+
+async function open(browser: Browser): Promise<{ page: Page; cdp: CDPSession; info: { duration: number; fps: number } }> {
+ const page = await browser.newPage({ viewport: { width: 1920, height: 1080 }, deviceScaleFactor: SCALE });
+ page.on("pageerror", (e) => console.error("page error:", e.message));
+ await page.goto(url, { waitUntil: "load" });
+ await page.waitForFunction(() => (window as unknown as { __video?: Video }).__video, null, { timeout: 60_000 });
+ const info = await page.evaluate(() => {
+ const v = (window as unknown as { __video: Video }).__video;
+ return { duration: v.duration, fps: v.fps };
+ });
+ return { page, cdp: await page.context().newCDPSession(page), info };
+}
+
+async function shoot(page: Page, cdp: CDPSession, t: number): Promise<Buffer> {
+ await page.evaluate((t) => (window as unknown as { __video: Video }).__video.seek(t), t);
+ // CDP screenshots come out in CSS px unless the clip asks for the device scale
+ const { data } = await cdp.send("Page.captureScreenshot", { format: "png", optimizeForSpeed: true, fromSurface: true, clip: { x: 0, y: 0, width: 1920, height: 1080, scale: SCALE } });
+ return Buffer.from(data, "base64");
+}
+
+const launch = () => chromium.launch({ args: ["--enable-gpu", "--ignore-gpu-blocklist", "--use-angle=metal", "--disable-renderer-backgrounding", "--disable-background-timer-throttling", "--font-render-hinting=none"] });
+
+if (args.stills) {
+ const browser = await launch();
+ const { page, cdp } = await open(browser);
+ const dir = join(OUT, "stills");
+ mkdirSync(dir, { recursive: true });
+ for (const s of args.stills.split(",")) {
+ const t = Number(s);
+ writeFileSync(join(dir, `${t.toFixed(2).padStart(6, "0")}.png`), await shoot(page, cdp, t));
+ }
+ console.log(`stills in ${dir}`);
+ await browser.close();
+ stop();
+ process.exit(0);
+}
+
+const probe = await launch();
+const { info } = await open(probe);
+await probe.close();
+const total = Math.round(info.duration * info.fps);
+const first = args.from ? Math.round(Number(args.from) * info.fps) : 0;
+const last = args.to ? Math.min(total, Math.round(Number(args.to) * info.fps)) : total;
+const jobs = Math.max(1, Number(args.jobs));
+const per = Math.ceil((last - first) / jobs);
+const parts = join(OUT, "parts");
+rmSync(parts, { recursive: true, force: true });
+mkdirSync(parts, { recursive: true });
+
+// RGB → BT.709 YUV, tagged as such, so whites stay white and colours don't shift in players.
+const encode = (file: string) => [
+ "-v", "error", "-y", "-f", "image2pipe", "-framerate", String(info.fps), "-i", "-",
+ "-vf", `scale=${OW}:${OH}:flags=lanczos:out_color_matrix=bt709:out_range=tv,format=yuv420p`,
+ "-c:v", "libx264", "-preset", "slow", "-crf", args.crf!, "-tune", "animation",
+ "-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709", "-color_range", "tv",
+ file,
+];
+
+const started = Date.now();
+let done = 0;
+const files: string[] = [];
+await Promise.all(
+ Array.from({ length: jobs }, async (_, j) => {
+ const a = first + j * per;
+ const b = Math.min(last, a + per);
+ if (a >= b) return;
+ const file = join(parts, `${String(j).padStart(2, "0")}.mp4`);
+ files[j] = file;
+ const browser = await launch();
+ const { page, cdp } = await open(browser);
+ const ff = spawn("ffmpeg", encode(file), { stdio: ["pipe", "inherit", "inherit"] });
+ const closed = new Promise<void>((res, rej) => ff.on("exit", (c) => (c === 0 ? res() : rej(new Error(`ffmpeg exited ${c}`)))));
+ for (let k = a; k < b; k++) {
+ const png = await shoot(page, cdp, k / info.fps);
+ if (!ff.stdin.write(png)) await new Promise((r) => ff.stdin.once("drain", r));
+ if (++done % 120 === 0) {
+ const s = (Date.now() - started) / 1000;
+ console.log(`${done}/${last - first} frames, ${s.toFixed(0)} s, ~${((s / done) * (last - first - done)).toFixed(0)} s left`);
+ }
+ }
+ ff.stdin.end();
+ await closed;
+ await browser.close();
+ }),
+);
+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 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" });
+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/scripts/serve.ts b/site/video/scripts/serve.ts
new file mode 100644
index 0000000..1454cbf
--- /dev/null
+++ b/site/video/scripts/serve.ts
@@ -0,0 +1,50 @@
+// A static file server for site/, so the video page, its clips and the example pages share one origin.
+// bun video/scripts/serve.ts [--port 4700]
+// The video is at /video/, the examples at /public/examples/<name>/.
+import { createReadStream, existsSync, statSync } from "node:fs";
+import { createServer, type Server } from "node:http";
+import { extname, join, normalize } from "node:path";
+import { fileURLToPath } from "node:url";
+
+export const SITE = join(import.meta.dirname, "..", "..");
+
+const TYPES: Record<string, string> = {
+ ".html": "text/html; charset=utf-8",
+ ".js": "text/javascript; charset=utf-8",
+ ".mjs": "text/javascript; charset=utf-8",
+ ".css": "text/css; charset=utf-8",
+ ".json": "application/json",
+ ".svg": "image/svg+xml",
+ ".png": "image/png",
+ ".jpg": "image/jpeg",
+ ".webp": "image/webp",
+ ".avif": "image/avif",
+ ".woff2": "font/woff2",
+ ".mp3": "audio/mpeg",
+ ".mp4": "video/mp4",
+ ".glb": "model/gltf-binary",
+ ".wasm": "application/wasm",
+};
+
+/** Serves site/ on `port`; resolves once it is listening. */
+export function serve(port: number): Promise<Server> {
+ const server = createServer((req, res) => {
+ let path = decodeURIComponent(new URL(req.url ?? "/", "http://localhost").pathname);
+ if (path.endsWith("/")) path += "index.html";
+ const file = normalize(join(SITE, path));
+ if (!file.startsWith(SITE) || !existsSync(file) || !statSync(file).isFile()) {
+ res.writeHead(404).end("not found");
+ return;
+ }
+ res.writeHead(200, { "content-type": TYPES[extname(file)] ?? "application/octet-stream", "cache-control": "max-age=3600" });
+ createReadStream(file).pipe(res);
+ });
+ return new Promise((resolve) => server.listen(port, () => resolve(server)));
+}
+
+if (process.argv[1] === fileURLToPath(import.meta.url)) {
+ const i = process.argv.indexOf("--port");
+ const port = i > 0 ? Number(process.argv[i + 1]) : 4700;
+ await serve(port);
+ console.log(`http://localhost:${port}/video/`);
+}
diff --git a/site/video/src/demo.css b/site/video/src/demo.css
new file mode 100644
index 0000000..b24a8e8
--- /dev/null
+++ b/site/video/src/demo.css
@@ -0,0 +1,177 @@
+@font-face { font-family: "Inter"; src: url("../assets/fonts/Inter-opsz.woff2") format("woff2"); font-weight: 100 900; font-display: block; }
+@font-face { font-family: "JetBrains Mono"; src: url("../assets/fonts/JetBrainsMono.woff2") format("woff2"); font-weight: 100 800; font-display: block; }
+@font-face { font-family: "Instrument Serif"; src: url("../assets/fonts/InstrumentSerif-Italic.woff2") format("woff2"); font-style: italic; font-weight: 400; font-display: block; }
+
+:root {
+ --ink: #141414;
+ --muted: #737373;
+ --faint: #b4b4b4;
+ --rule: #ebebeb;
+ --accent: #533afd;
+ --sans: "Inter", system-ui, sans-serif;
+ --mono: "JetBrains Mono", ui-monospace, monospace;
+ --serif: "Instrument Serif", Georgia, serif;
+}
+
+* { box-sizing: border-box; }
+html, body { margin: 0; background: #0b0b0c; color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss03"; }
+body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
+
+#viewport { position: relative; overflow: hidden; }
+#stage { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; overflow: hidden; background: #fff; transform-origin: 0 0; }
+.scene { position: absolute; inset: 0; }
+.scene > * { position: absolute; left: 0; top: 0; margin: 0; }
+img { display: block; user-select: none; }
+
+#player { display: flex; align-items: center; gap: 12px; width: min(100vw - 32px, 1200px); color: #e5e5e5; font: 13px/1 var(--mono); }
+#player button { font: inherit; color: inherit; background: #222; border: 1px solid #333; border-radius: 6px; padding: 7px 12px; cursor: pointer; }
+#player input { flex: 1; accent-color: var(--accent); }
+#time { width: 48px; text-align: right; }
+
+html[data-render] body { display: block; background: #fff; }
+html[data-render] #viewport { width: 1920px; height: 1080px; }
+html[data-render] #player { display: none; }
+
+/* ---------- intro ---------- */
+
+.intro-glow { width: 1500px; height: 700px; left: 210px !important; top: 170px !important; background:
+ radial-gradient(closest-side at 38% 52%, rgb(110 84 255 / 0.13), transparent),
+ radial-gradient(closest-side at 64% 46%, rgb(236 120 190 / 0.10), transparent); }
+.intro-tagline { width: 1920px; top: 628px !important; text-align: center; font-size: 34px; letter-spacing: -0.01em; color: var(--muted); }
+.intro-caption { width: 1920px; top: 214px !important; text-align: center; font-size: 27px; letter-spacing: -0.005em; color: var(--muted); }
+.intro-line { position: absolute; inset: 0; }
+.intro-line > * { position: absolute; left: 0; top: 0; }
+.intro-word { font-size: 168px; line-height: 1; font-weight: 620; letter-spacing: -0.045em; white-space: nowrap; transform-origin: 0 50%; font-variation-settings: "opsz" 32; }
+.intro-char { display: inline-block; }
+.intro-band { height: 104px; border-radius: 28px; background: #f4f4f6; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.035); transform-origin: 0 50%; }
+.intro-wheel { position: absolute; inset: 0; perspective: 1000px; }
+.intro-row { position: absolute; top: 500px; height: 80px; line-height: 80px; font-size: 56px; font-weight: 500; letter-spacing: -0.03em; white-space: nowrap; transform-origin: 0 50%; backface-visibility: hidden; }
+.intro-caret { width: 4px; height: 64px; border-radius: 2px; background: var(--accent); }
+.intro-key { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; color: #3f3f46; background: #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08), 0 2px 0 rgb(0 0 0 / 0.06), 0 8px 18px -8px rgb(0 0 0 / 0.18); }
+.intro-status { width: 64px; height: 64px; }
+.intro-status > * { position: absolute; inset: 0; }
+
+/* ---------- how it works ---------- */
+
+.scene--how .how-text { left: 140px; top: 352px; width: 500px; }
+.how-num { font-family: var(--serif); font-style: italic; font-size: 46px; line-height: 1; color: #b9b9be; }
+.how-title { margin-top: 10px; font-size: 84px; line-height: 1; font-weight: 640; letter-spacing: -0.045em; font-variation-settings: "opsz" 32; }
+.how-desc { margin: 22px 0 0; font-size: 28px; line-height: 1.38; letter-spacing: -0.012em; color: var(--muted); }
+.scene--how .how-rail { left: 140px; top: 700px; display: flex; gap: 8px; }
+.how-rail i { display: block; height: 5px; width: 28px; border-radius: 3px; background: #e6e6e9; }
+
+.win { border-radius: 16px; background: #fff; overflow: hidden; transform-origin: 0 0;
+ box-shadow: 0 0 0 1px rgb(0 0 0 / 0.07), 0 2px 4px rgb(0 0 0 / 0.03), 0 24px 60px -18px rgb(20 20 40 / 0.22); }
+.win-bar { position: relative; display: flex; align-items: center; gap: 7px; padding: 0 16px; background: #fafafa; border-bottom: 1px solid #efefef; }
+.win-bar > i { width: 11px; height: 11px; border-radius: 50%; background: #e2e2e5; }
+.win-url { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 7px; padding: 5px 16px; border-radius: 8px; background: #f0f0f2; color: #5f5f66; font-size: 15px; letter-spacing: -0.005em; }
+.win--small .win-url { font-size: 14px; padding: 4px 14px; }
+.win-body { position: relative; overflow: hidden; background: #fff; }
+.fill { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
+.win-flash { position: absolute; inset: 0; background: #fff; opacity: 0; }
+.win--rec .win-bar { gap: 9px; padding: 0 14px; }
+.rec-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #e5484d; box-shadow: 0 0 0 4px rgb(229 72 77 / 0.15); }
+.rec-url { flex: 1; display: flex; align-items: center; gap: 6px; color: #5f5f66; font-size: 14px; letter-spacing: -0.005em; white-space: nowrap; }
+.rec-time { font: 500 13px/1 var(--mono); color: #3f3f46; }
+.trio { position: absolute; }
+.pane { position: absolute; top: 0; overflow: hidden; border-radius: 8px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.06); }
+.win--trio .win-body { background: #f4f4f6; }
+.track-box { position: absolute; }
+.track-box b { position: absolute; width: 22px; height: 22px; border: 0 solid var(--accent); }
+.track-box b:nth-child(1) { left: 0; top: 0; border-left-width: 3px; border-top-width: 3px; border-top-left-radius: 8px; }
+.track-box b:nth-child(2) { right: 0; top: 0; border-right-width: 3px; border-top-width: 3px; border-top-right-radius: 8px; }
+.track-box b:nth-child(3) { left: 0; bottom: 0; border-left-width: 3px; border-bottom-width: 3px; border-bottom-left-radius: 8px; }
+.track-box b:nth-child(4) { right: 0; bottom: 0; border-right-width: 3px; border-bottom-width: 3px; border-bottom-right-radius: 8px; }
+.track-box span { position: absolute; left: 12px; bottom: 12px; padding: 5px 9px; border-radius: 7px; background: var(--accent); color: #fff; font: 500 14px/1 var(--mono); }
+
+.strip { width: 564px; height: 140px; }
+.thumb { position: absolute; left: 0; top: 0; width: 84px; height: 112px; border-radius: 7px; overflow: visible; transform-origin: 0 0; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08), 0 8px 18px -10px rgb(0 0 0 / 0.3); background: #fff; }
+.thumb img { border-radius: 7px; }
+.thumb-label { position: absolute; left: 0; top: 121px; font: 500 12px/1 var(--mono); color: #9a9aa2; white-space: nowrap; }
+
+.spec { width: 1060px; border-radius: 18px; background: #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.07), 0 24px 60px -24px rgb(20 20 40 / 0.2); padding: 0 0 12px; }
+.spec-bar { display: flex; justify-content: space-between; align-items: center; height: 54px; padding: 0 28px; border-bottom: 1px solid #f0f0f0; font: 500 16px/1 var(--mono); color: #8a8a92; }
+.spec-count { color: var(--accent); }
+.spec-row { display: grid; grid-template-columns: 104px 200px 112px 112px 112px 180px 1fr; align-items: center; height: 53px; padding: 0 28px; border-bottom: 1px solid #f4f4f5; font: 400 19px/1 var(--mono); color: #27272a; }
+.spec-row:last-child { border-bottom: 0; }
+.spec-row--head { height: 42px; font: 500 15px/1 var(--sans); color: #9a9aa2; letter-spacing: 0.01em; }
+.spec-row > span:first-child { color: #9a9aa2; }
+.spec-row > span:nth-child(2) { color: var(--accent); }
+.spec-row--head > span:nth-child(2) { color: inherit; }
+.spec-cell { position: relative; height: 24px; }
+.spec-cell > * { position: absolute; left: 0; top: 2px; font-style: normal; font-weight: 400; white-space: nowrap; }
+.spec-q { color: #c4c4cc; }
+.curve { width: 300px; padding: 20px 22px 18px; border-radius: 18px; background: #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.07), 0 30px 60px -20px rgb(20 20 40 / 0.28); }
+.curve-label { margin-bottom: 14px; font: 500 13px/1.35 var(--mono); color: #8a8a92; }
+.curve-label span { color: var(--ink); }
+.curve svg { overflow: visible; }
+
+.editor { width: 640px; height: 506px; border-radius: 18px; background: #fcfcfc; overflow: hidden; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.07), 0 24px 60px -24px rgb(20 20 40 / 0.2); }
+.editor-tabs { display: flex; height: 48px; border-bottom: 1px solid #eee; background: #f7f7f8; font: 500 15px/48px var(--mono); color: #9a9aa2; }
+.editor-tabs span { padding: 0 22px; border-right: 1px solid #eee; }
+.editor-tabs .on { background: #fcfcfc; color: var(--ink); box-shadow: inset 0 2px 0 var(--accent); }
+.editor-code { padding: 20px 0; }
+.code-line { display: flex; height: 35px; align-items: center; font: 400 18px/1 var(--mono); color: #3f3f46; white-space: pre; }
+.code-line em { width: 56px; padding-right: 18px; text-align: right; font-style: normal; color: #c4c4cc; flex: none; }
+.code-line c { color: #a1a1aa; }
+.code-line k { color: var(--accent); }
+.code-line s { color: #0f7b5f; text-decoration: none; }
+.code-line f { color: #b4236b; }
+.code-line n { color: #c2410c; }
+.chip { padding: 9px 16px; border-radius: 999px; border: 1px solid #e6e6e6; background: #fff; font-size: 19px; font-weight: 500; letter-spacing: -0.01em; color: var(--muted); white-space: nowrap; }
+
+.skeleton { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 6px; }
+.skeleton i { border-radius: 8px; background: linear-gradient(180deg, #f3f3f5, #ececef); }
+.scan { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--accent); box-shadow: 0 0 18px 4px rgb(83 58 253 / 0.35), -60px 0 60px -20px rgb(83 58 253 / 0.18); }
+.metrics { width: 1068px; padding: 10px 32px; border-radius: 18px; background: #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.07), 0 24px 60px -24px rgb(20 20 40 / 0.2); }
+.metric { display: flex; align-items: center; height: 80px; gap: 20px; border-bottom: 1px solid #f2f2f3; }
+.metric:last-child { border-bottom: 0; }
+.metric b { width: 120px; font-size: 25px; font-weight: 600; letter-spacing: -0.02em; }
+.metric span { flex: 1; font-size: 22px; color: var(--muted); letter-spacing: -0.01em; }
+.metric-val { font: 500 27px/1 var(--mono); color: var(--ink); }
+.pass { padding: 7px 12px; border-radius: 999px; background: #efebff; color: var(--accent); font: 600 15px/1 var(--sans); font-style: normal; letter-spacing: 0.02em; text-transform: uppercase; }
+
+.diff-mix { position: absolute; inset: 0; isolation: isolate; background: #fff; filter: grayscale(1) brightness(6) contrast(3) invert(1); }
+.diff-top { position: absolute; inset: 0; background: #fff; mix-blend-mode: difference; }
+.diff-tint { position: absolute; inset: 0; background: #ff2d87; mix-blend-mode: screen; }
+.chart { width: 1060px; height: 400px; border-radius: 18px; background: #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.07), 0 24px 60px -24px rgb(20 20 40 / 0.2); }
+.chart > * { position: absolute; }
+.chart-round { left: 44px; top: 48px; font-size: 24px; font-weight: 500; color: var(--muted); }
+.chart-value { left: 40px; top: 96px; font-size: 128px; line-height: 1; font-weight: 640; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; font-variation-settings: "opsz" 32; }
+.chart-sub { left: 44px; top: 250px; font-size: 24px; color: var(--muted); }
+.match { left: 44px; top: 312px; display: flex; align-items: center; gap: 8px; padding: 11px 20px 11px 14px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 22px; font-weight: 600; box-shadow: 0 10px 30px -8px rgb(83 58 253 / 0.6); transform-origin: 20% 50%; }
+.chart-bars { right: 56px; bottom: 54px; display: flex; align-items: flex-end; gap: 46px; height: 260px; }
+.chart-bar { position: relative; width: 74px; height: 100%; display: flex; align-items: flex-end; }
+.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 ---------- */
+
+.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 ---------- */
+
+.helix-world { width: 1920px; height: 1080px; perspective: 1700px; perspective-origin: 960px 540px; transform-origin: 960px 540px; }
+.tile { position: absolute; left: 790px; top: 412.5px; width: 340px; height: 255px; border-radius: 16px; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06); }
+.tile img { position: absolute; max-width: none; }
+.tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.07); }
+
+/* ---------- install ---------- */
+
+.end-glow { top: 0 !important; }
+.end-word { font-size: 124px; line-height: 1; font-weight: 620; letter-spacing: -0.045em; white-space: nowrap; font-variation-settings: "opsz" 32; }
+.end-pill { display: flex; align-items: center; gap: 18px; height: 100px; padding: 0 22px 0 40px; border-radius: 24px; background: #0c0c0e; color: #f4f4f5; font: 400 34px/1 var(--mono); white-space: nowrap;
+ box-shadow: 0 0 0 1px rgb(255 255 255 / 0.06) inset, 0 30px 70px -24px rgb(20 10 60 / 0.55), 0 0 0 8px rgb(83 58 253 / 0.06); }
+.end-dollar { color: #6f6f78; }
+.end-typed { display: inline-block; min-width: 0; }
+.end-caret { display: block; width: 3px; height: 40px; margin-left: -14px; border-radius: 2px; background: #a99bff; }
+.end-copy { position: relative; margin-left: auto; display: grid; place-items: center; min-width: 132px; height: 56px; padding: 0 18px; border-radius: 14px; background: #1d1d22; color: #a1a1aa; font: 500 21px/1 var(--sans); }
+.end-copy > * { grid-area: 1 / 1; display: flex; align-items: center; gap: 6px; }
+.end-hint { width: 1920px; text-align: center; font-size: 30px; letter-spacing: -0.01em; color: var(--muted); }
+.end-hint code { font: 400 0.86em var(--mono); color: var(--ink); background: #f2f2f4; padding: 4px 10px; border-radius: 8px; }
+.end-links { width: 1920px; text-align: center; font-size: 23px; color: #9a9aa2; letter-spacing: -0.005em; }
+.end-links i { font-style: normal; margin: 0 16px; color: #d4d4d8; }
diff --git a/site/video/src/examples.js b/site/video/src/examples.js
new file mode 100644
index 0000000..358a03b
--- /dev/null
+++ b/site/video/src/examples.js
@@ -0,0 +1,135 @@
+// 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
new file mode 100644
index 0000000..4694a69
--- /dev/null
+++ b/site/video/src/helix.js
@@ -0,0 +1,178 @@
+// 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.
+import { bar, clipInfo, clipLen, ease, el, frameUrl, hash, lerp, prog, put, setSrc, setStyle } from "./lib.js";
+
+export const name = "helix";
+export const from = 47.2;
+export const to = 57.1;
+
+// in the mosaic's reading order
+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",
+ "clerk-social-sign-on", "clerk-bot-detection", "clerk-advanced-security", "clerk-passwords", "clerk-api-keys", "clerk-cli",
+];
+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 = {
+ "stripe-agentic-commerce": [0, 0.5, 0.52], "stripe-issuing": [0, 0.5, 0.42], "stripe-crypto": [0, 0.5, 0.62],
+ "workos-atlas": [0, 0.5, 0.42], "clerk-session-management": [24, 0.5, 0.62], "clerk-fraud": [24, 0.5, 0.62],
+ "clerk-magic-links": [24, 0.5, 0.58], "clerk-api-keys": [24, 0.42, 0.5],
+};
+
+const TW = 340, TH = 255; // tile, px
+const R = 1050; // helix radius
+const PER_TURN = 18; // frames almost edge to edge, like a film strip
+const STEP = 360 / PER_TURN;
+const PITCH = 23; // rise per tile: a turn rises a tile and a gap
+const N = 54; // three turns
+const MID = 27; // the middle of the ribbon, and of the mosaic
+const P = 1700; // perspective
+const MS = 0.76; // tile scale in the mosaic
+const GAP = 20;
+// the mosaic's cells, in reading order: three rows of six, the middle one set across by half a tile
+const CELLS = [0, 1, 2].flatMap((r) =>
+ Array.from({ length: 6 }, (_, c) => ({
+ r,
+ x: 960 + (c - 2.5 + (r === 1 ? 0.25 : -0.25)) * (TW * MS + GAP),
+ y: 500 + (r - 1) * (TH * MS + GAP),
+ })),
+);
+// camera distance from the helix axis when the morph lands (the front tiles a little smaller than in the
+// mosaic), and once it has pulled back
+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
+
+// 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 HALF = Math.floor(EXAMPLES.length / 2);
+const cellTile = (k) => MID - HALF + RIBBON.indexOf(k);
+
+let root, world, tiles;
+
+// rotation: still during the morph, then speeding up to SPEED deg/s, easing off at the end
+const SPEED = 24;
+function spin(t) {
+ const a = MORPH[1] - 0.6;
+ const ramp = 1.6;
+ const u = t - a;
+ if (u <= 0) return 0;
+ const x = Math.min(u, ramp) / ramp;
+ let d = SPEED * ramp * (x ** 3 - x ** 4 / 2); // ∫ smoothstep
+ if (u > ramp) d += SPEED * (u - ramp);
+ return d;
+}
+
+export function init(r) {
+ root = r;
+ world = el("div", "helix-world", root);
+ // which example each helix tile shows: the mosaic's cells get theirs; the rest alternate light (Stripe,
+ // WorkOS) and dark (the others) so neither clumps
+ const show = new Array(N).fill(-1);
+ CELLS.forEach((_, k) => (show[cellTile(k)] = k));
+ const all = EXAMPLES.map((_, i) => i);
+ const pools = [all.filter((i) => LIGHT.has(EXAMPLES[i])), all.filter((i) => !LIGHT.has(EXAMPLES[i]))];
+ const next = [0, 0];
+ for (let i = 0; i < N; i++) {
+ if (show[i] >= 0) continue;
+ const pool = pools[i % 2];
+ let e;
+ do e = pool[next[i % 2]++ % pool.length];
+ while (e === show[i - 1] || e === show[i + 1] || e === show[i - PER_TURN] || e === show[i + PER_TURN]);
+ show[i] = e;
+ }
+ tiles = Array.from({ length: N }, (_, i) => {
+ const tile = el("div", "tile", world);
+ const slug = EXAMPLES[show[i]];
+ const info = clipInfo(slug);
+ const [inset, fx, fy] = (CROP[slug] ?? [0, 0.5, 0.5]).map((v, j) => (j === 0 && slug.startsWith("clerk") ? 8 : v)); // Clerk: keep a white margin round the card
+ const iw = info.width - 2 * inset, ih = info.height - 2 * inset;
+ const k = Math.max(TW / iw, TH / ih);
+ const img = el("img", "", tile);
+ Object.assign(img.style, {
+ width: `${info.width * k}px`,
+ height: `${info.height * k}px`,
+ left: `${-(inset + (iw - TW / k) * fx) * k}px`,
+ top: `${-(inset + (ih - TH / k) * fy) * k}px`,
+ });
+ Object.assign(tile, { _img: img, _slug: slug, _off: hash(i * 7 + 3) * clipLen(slug), _theta: i * STEP, _y: (i - MID) * PITCH });
+ return tile;
+ });
+ tiles.forEach((tile) => (tile._cell = null));
+ CELLS.forEach((cell, k) => (tiles[cellTile(k)]._cell = cell));
+}
+
+export function render(t) {
+ const morph = ease.inOutCubic(prog(t, ...MORPH));
+ const phi = -tiles[MID]._theta - spin(t) + spin(MORPH[1]); // the middle tile faces front when the morph lands
+ const zoom = ease.inOutCubic(prog(t, MORPH[1] - 0.5, PULLED));
+ const D = lerp(D0, D1, zoom) + 160 * ease.inOutSine(prog(t, PULLED, to));
+ const tilt = -21 * ease.inOutCubic(prog(t, MORPH[0] + 0.3, PULLED + 0.4)) + 6 * ease.inOutSine(prog(t, PULLED + 0.4, to));
+ const lean = -7 * ease.inOutCubic(prog(t, MORPH[1] - 0.4, PULLED + 0.6)) + 3 * ease.inOutSine(prog(t, PULLED + 0.6, to));
+ const lift = -40 - tiles[MID]._y - 70 * ease.inOutCubic(prog(t, MORPH[0] + 0.3, PULLED + 0.4)); // the near ring sits lower; lift it to centre the coil
+ const tau = (tilt * Math.PI) / 180;
+ const ct = Math.cos(tau), st = Math.sin(tau);
+ 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 });
+
+ for (let i = 0; i < N; i++) {
+ const tile = tiles[i];
+ // on the helix
+ const psi = tile._theta + phi;
+ const pr = (psi * Math.PI) / 180;
+ const X = R * Math.sin(pr);
+ const Y0 = tile._y + lift;
+ const Z0 = R * Math.cos(pr);
+ const Y = Y0 * ct - Z0 * st;
+ const Z = Y0 * st + Z0 * ct - D;
+ // turned away from the camera? (normal · direction to the camera)
+ const nx = Math.sin(pr), ny = -Math.cos(pr) * st, nz = Math.cos(pr) * ct;
+ const back = nx * -X + ny * -Y + nz * (P - Z) < 0;
+ let yaw = psi + (back ? 180 : 0);
+ yaw = ((((yaw + 180) % 360) + 360) % 360) - 180;
+ const front = (Math.cos(pr) + 1) / 2;
+
+ let x = X, y = Y, z = Z, rx = tilt, ry = yaw, o, blur, sc = 1;
+ 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);
+ rx = tilt * morph;
+ ry = yaw * morph;
+ o = lerp(a, helixO, morph);
+ blur = lerp((1 - a) * 18, 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));
+ o = helixO * a;
+ blur = helixBlur + (1 - a) * 12;
+ z -= (1 - a) * 500;
+ }
+ if (o <= 0.003) {
+ put(tile, { o: 0 });
+ continue;
+ }
+ setSrc(tile._img, frameUrl(tile._slug, tile._off + (tq - IN) * 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
new file mode 100644
index 0000000..c362cd3
--- /dev/null
+++ b/site/video/src/how.js
@@ -0,0 +1,440 @@
+// How it works, one bar per step and two for the last, each handing its result to the next. It follows
+// three clones at once: the Agentic commerce card from stripe.com, the cube from resend.com and the
+// Session management card from clerk.com, each filmed with its copy the same way (scripts/clips.ts).
+// record three browsers film the originals; frames peel off into a strip
+// spec the strip rises and a table of moving parts fills in, unknowns resolving to numbers
+// 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 { MATCH_AT } from "./intro.js";
+
+export const name = "how";
+export const from = 12.8;
+export const to = 28.85;
+
+const S = [12.86, bar(5), bar(6), bar(7), bar(8)]; // record, spec, build, verify, repeat
+const CX = 1250; // centre of the visual on the right
+
+const STEPS = [
+ ["Record", "Films the original in a real browser, frame by frame, at a fixed size and frame rate."],
+ ["Spec", "Writes down every moving part: when it starts, how long it takes, how far it goes, on which curve."],
+ ["Build", "Rebuilds it in your code, with what your project already uses."],
+ ["Verify", "Films the copy the same way, and compares timing, easing and pixels."],
+ ["Repeat", "Fixes the biggest difference and films again, until the numbers match."],
+];
+
+// the three clones: clips how-<name>-reference and how-<name>-copy, each shown in a pane `aspect` times
+// as wide as it is tall (cropped to fit), with the element the recorder tracks
+const SITES = [
+ { name: "stripe", url: "stripe.com", aspect: 0.6, track: ".chat" },
+ { name: "resend", url: "resend.com", aspect: 0.9, track: ".cube" },
+ { name: "clerk", url: "clerk.com", aspect: 0.75, track: ".session" },
+];
+const clipOf = (site, side) => `how-${site.name}-${side}`;
+
+const WIN_W = 560; // the small windows' own size; they're scaled into place
+const PAD = 14; // around the panes in a small window
+const GAP = 10; // between them
+const TRIO_H = Math.floor((WIN_W - 2 * PAD - 2 * GAP) / SITES.reduce((a, s) => a + s.aspect, 0));
+const BODY_H = TRIO_H + 2 * PAD;
+const CHROME = 40;
+// the recording windows: one per site, side by side, as tall as REC_H
+const REC_H = 420;
+const REC_GAP = 28;
+const REC_Y = 222;
+const REC_W = SITES.map((s) => Math.round(s.aspect * REC_H));
+const REC_X = REC_W.map((_, i) => CX - (REC_W.reduce((a, w) => a + w, 0) + 2 * REC_GAP) / 2 + REC_W.slice(0, i).reduce((a, w) => a + w + REC_GAP, 0));
+const TW = 84; // the strip's thumbnails, 84 x 112 (demo.css)
+
+let root, texts, dashes;
+let recWins, strip, thumbs;
+let table, tableCount, rows, curve, curvePath, curveDot;
+let editor, codeLines, chips;
+let refWin, copyWin, copyFlash, scanRef, scanCopy, metrics, diffWin, diffRef, diffCopy;
+let chart, roundLabel, bigValue, bars, matchPill;
+
+// The three clips side by side, `h` tall, inside a small window's body: an <img> per pane.
+function trio(parent, h = TRIO_H) {
+ const box = el("div", "trio", parent);
+ let x = 0;
+ box._imgs = SITES.map((s) => {
+ const pane = el("div", "pane", box);
+ const w = Math.round(s.aspect * h);
+ Object.assign(pane.style, { left: `${x}px`, width: `${w}px`, height: `${h}px` });
+ x += w + GAP;
+ return el("img", "fill", pane);
+ });
+ const w = x - GAP;
+ Object.assign(box.style, { left: `${(WIN_W - w) / 2}px`, top: `${PAD}px`, width: `${w}px`, height: `${h}px` });
+ return box;
+}
+// shows each pane's clip (`side`: reference or copy) at lt seconds into it
+const play = (box, side, lt) => box._imgs.forEach((img, i) => setSrc(img, frameUrl(clipOf(SITES[i], side), Math.max(0, lt))));
+
+function makeWindow(parent, url, w, h, chrome, cls = "") {
+ const win = el("div", `win ${cls}`, parent);
+ win.style.width = `${w}px`;
+ const top = el("div", "win-bar", win, `<i></i><i></i><i></i><span class="win-url">${url}</span>`);
+ top.style.height = `${chrome}px`;
+ const body = el("div", "win-body", win);
+ body.style.height = `${h}px`;
+ return { win, top, body };
+}
+
+export function init(r) {
+ root = r;
+
+ // ---- the step names on the left ----
+ texts = STEPS.map(([title, desc], i) => {
+ const g = el("div", "how-text", root);
+ el("div", "how-num", g, String(i + 1).padStart(2, "0"));
+ el("div", "how-title", g, title);
+ el("p", "how-desc", g, desc);
+ return g;
+ });
+ const rail = el("div", "how-rail", root);
+ dashes = STEPS.map(() => el("i", "", rail));
+ root._rail = rail;
+
+ // ---- record: a browser per original ----
+ const lock = `<svg width="10" height="11" viewBox="0 0 11 12"><path d="M2 5V3.5a3.5 3.5 0 0 1 7 0V5" fill="none" stroke="currentColor" stroke-width="1.5"/><rect x="0.5" y="5" width="10" height="7" rx="1.5" fill="currentColor"/></svg>`;
+ recWins = SITES.map((s, i) => {
+ const win = el("div", "win win--rec", root);
+ win.style.width = `${REC_W[i]}px`;
+ const top = el("div", "win-bar", win, `<span class="rec-dot"></span><span class="rec-url">${lock} ${s.url}</span>`);
+ top.style.height = `${CHROME}px`;
+ win._time = el("span", "rec-time", top, "00:00.00");
+ const body = el("div", "win-body", win);
+ body.style.height = `${REC_H}px`;
+ win._img = el("img", "fill", body);
+ win._box = el("div", "track-box", body, `<b></b><b></b><b></b><b></b><span>${s.track}</span>`);
+ Object.assign(win._box.style, { left: "8px", top: "8px", right: "8px", bottom: "8px" });
+ win._flash = el("div", "win-flash", body);
+ return win;
+ });
+ strip = el("div", "strip", root);
+ thumbs = Array.from({ length: 6 }, (_, j) => {
+ const th = el("div", "thumb", strip);
+ th._site = j % 3;
+ th._img = el("img", "fill", th);
+ th._label = el("span", "thumb-label", th);
+ return th;
+ });
+
+ // ---- spec ----
+ table = el("div", "spec", root);
+ const head = el("div", "spec-bar", table, `<span>spec.md</span>`);
+ tableCount = el("span", "spec-count", head);
+ el("div", "spec-row spec-row--head", table, ["site", "element", "property", "start", "duration", "from → to", "easing"].map((c) => `<span>${c}</span>`).join(""));
+ const ROWS = [
+ ["stripe", ".chat-bubble", "opacity", "420 ms", "300 ms", "0 → 1", "linear"],
+ ["stripe", ".particle-ring", "radius", "1440 ms", "900 ms", "1.4 → 1.0", "in-out"],
+ ["resend", ".cube", "rotateY", "0 ms", "10 s", "0 → −359°", "linear"],
+ ["resend", ".slice-left", "rotateX", "1500 ms", "2000 ms", "0 → −180°", "in-out"],
+ ["clerk", ".laptop-lid", "rotateX", "hover", "1000 ms", "−75° → 20°", "expo-in-out"],
+ ["clerk", ".device-value", "blur", "+200 ms", "600 ms", "8px → 0", "ease-out"],
+ ];
+ rows = ROWS.map((cells) => {
+ const row = el("div", "spec-row", table);
+ row._cells = cells.map((c, j) => {
+ const cell = el("span", "", row);
+ if (j < 3) {
+ cell.textContent = c;
+ return null;
+ }
+ cell.className = "spec-cell";
+ const q = el("i", "spec-q", cell, "?");
+ const v = el("b", "spec-v", cell, c);
+ return { q, v };
+ });
+ return row;
+ });
+ curve = el("div", "curve", root, `
+ <div class="curve-label">.slice-left · <span>cubic-bezier(0.42, 0, 0.58, 1)</span></div>
+ <svg width="236" height="150" viewBox="-8 -8 236 150">
+ <path d="M0 134H220M0 134V0" stroke="#e7e7e7" stroke-width="1.5" fill="none"/>
+ <path d="M0 0H220" stroke="#efefef" stroke-width="1.5" stroke-dasharray="4 5" fill="none"/>
+ <path class="curve-path" d="M0 134C92.4 134 127.6 0 220 0" stroke="${ACCENT}" stroke-width="3.5" fill="none" stroke-linecap="round"/>
+ <circle class="curve-dot" r="7" fill="#fff" stroke="${ACCENT}" stroke-width="3.5"/>
+ </svg>`);
+ curvePath = curve.querySelector(".curve-path");
+ curveDot = curve.querySelector(".curve-dot");
+
+ // ---- build ----
+ editor = el("div", "editor", root, `<div class="editor-tabs"><span class="on">Clones.tsx</span><span>spec.md</span></div>`);
+ const code = el("div", "editor-code", editor);
+ const CODE = [
+ `<c>// stripe.com, in CSS and three.js</c>`,
+ `bubble.<f>animate</f>(fadeIn, { delay: <n>420</n> });`,
+ `ring.<f>tighten</f>({ at: <n>1440</n>, radius: [<n>1.4</n>, <n>1</n>] });`,
+ ``,
+ `<c>// resend.com, in three.js</c>`,
+ `cube.rotation.y = -(t / <n>10000</n>) * <k>TAU</k>;`,
+ `slice.<f>turn</f>(<k>PI</k>, { at: <n>1500</n>, every: <n>5000</n> });`,
+ ``,
+ `<c>// clerk.com, in Framer Motion</c>`,
+ `lid.<f>animate</f>({ rotateX: [<n>-75</n>, <n>20</n>] });`,
+ `rows.<f>forEach</f>((r, i) => r.<f>unblur</f>(i * <n>50</n>));`,
+ ];
+ codeLines = CODE.map((html, i) => {
+ const ln = el("div", "code-line", code, `<em>${i + 1}</em><span>${html || "&nbsp;"}</span>`);
+ ln._text = ln.querySelector("span");
+ return ln;
+ });
+ chips = ["CSS", "Framer Motion", "GSAP", "three.js"].map((c) => el("span", "chip", root, c));
+
+ // ---- verify and repeat ----
+ ({ win: refWin } = makeWindow(root, "stripe.com · resend.com · clerk.com", WIN_W, BODY_H, CHROME, "win--small win--trio"));
+ refWin._trio = trio(refWin.querySelector(".win-body"));
+ ({ win: copyWin } = makeWindow(root, "localhost:3000", WIN_W, BODY_H, CHROME, "win--small win--trio"));
+ const copyBody = copyWin.querySelector(".win-body");
+ copyWin._skeleton = el("div", "skeleton", copyBody, "<i></i><i></i><i></i>");
+ copyWin._trio = trio(copyBody);
+ copyFlash = el("div", "win-flash", copyBody);
+ scanRef = el("div", "scan", refWin.querySelector(".win-body"));
+ scanCopy = el("div", "scan", copyBody);
+ metrics = el("div", "metrics", root);
+ metrics._rows = [
+ ["Timing", "every step of all three", 380, 43, (v) => `≤ ${Math.round(v)} ms`],
+ ["Rotation", "the cube and the laptop lid, every frame", 9.6, 0, (v) => `${v.toFixed(2)}°`],
+ ["Pixels", "that differ, once they settle", 6.4, 0.11, (v) => `≤ ${v.toFixed(2)} %`],
+ ].map(([k, d, a, b, fmt]) => {
+ const row = el("div", "metric", metrics, `<b>${k}</b><span>${d}</span>`);
+ row._val = el("code", "metric-val", row);
+ row._pass = el("i", "pass", row, "pass");
+ Object.assign(row, { _a: a, _b: b, _fmt: fmt });
+ return row;
+ });
+ ({ win: diffWin } = makeWindow(root, "difference", WIN_W, BODY_H, CHROME, "win--small win--diff win--trio"));
+ const mixer = el("div", "diff-mix", diffWin.querySelector(".win-body"));
+ diffRef = trio(mixer);
+ diffCopy = trio(el("div", "diff-top", mixer));
+ el("div", "diff-tint", diffWin.querySelector(".win-body"));
+
+ chart = el("div", "chart", root);
+ roundLabel = el("div", "chart-round", chart);
+ bigValue = el("div", "chart-value", chart);
+ el("div", "chart-sub", chart, "of pixels differ from the originals");
+ matchPill = el("div", "match", chart, `<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>Match`);
+ const barBox = el("div", "chart-bars", chart);
+ bars = [0, 1, 2, 3].map((i) => {
+ const b = el("div", "chart-bar", barBox);
+ b._fill = el("i", "", b);
+ b._label = el("span", "", b, `round ${i + 1}`);
+ return b;
+ });
+}
+
+// ---------- rounds of the repeat step ----------
+const ROUNDS = [S[4], bar(8.5), bar(9), bar(9.5)];
+const MISS = [ // how far off the copy still is in each round: px, px, scale, s late
+ [22, 14, 0.965, 0.42],
+ [8, 5, 0.988, 0.15],
+ [2.5, 1.5, 0.997, 0.05],
+ [0, 0, 1, 0],
+];
+const VALUES = [12.4, 3.1, 0.6, 0.11];
+
+function roundAt(t) {
+ let k = 0;
+ for (let i = 0; i < ROUNDS.length; i++) if (t >= ROUNDS[i]) k = i;
+ return k;
+}
+
+// Where the two small windows sit: [x, y, scale] in build (copy only), verify and repeat.
+const PLACES = {
+ build: [1282, 372, 1],
+ verifyRef: [716, 228, 520 / WIN_W],
+ verifyCopy: [1264, 228, 520 / WIN_W],
+ repeatRef: [715, 206, 340 / WIN_W],
+ repeatCopy: [1075, 206, 340 / WIN_W],
+ repeatDiff: [1435, 206, 340 / WIN_W],
+};
+const between = (a, b, p) => [lerp(a[0], b[0], p), lerp(a[1], b[1], p), lerp(a[2], b[2], p)];
+
+export function render(t) {
+ // ---- left column ----
+ texts.forEach((g, i) => {
+ const inAt = i === 0 ? 13.36 : S[i] - 0.14;
+ const outAt = i === 4 ? 28.3 : S[i + 1] - 0.34;
+ blurFade(g, t, { inAt, inDur: 0.62, outAt, outDur: 0.32, dy: 26, dyOut: -18, blur: 14 });
+ });
+ const railIn = presence(t, 13.45, 0.6, 28.3, 0.4);
+ put(root._rail, { o: railIn.v, y: (1 - railIn.a) * 14, blur: railIn.b * 8 });
+ dashes.forEach((d, i) => {
+ const on = clamp(tw(t, S[i] - 0.1, 0.4) - (i < 4 ? tw(t, S[i + 1] - 0.1, 0.4) : 0));
+ const done = i < 4 ? tw(t, S[i + 1] - 0.1, 0.4) : t > MATCH_AT ? 1 : 0;
+ setStyle(d, "width", `${lerp(28, 72, on).toFixed(1)}px`);
+ setStyle(d, "background-color", mix("#e6e6e9", done ? "#1a1a1a" : ACCENT, Math.max(on, done * 0.9)));
+ });
+
+ // ---- record: the three browsers come in one after another, film, and frames peel off ----
+ const lt = Math.max(0, t - 13.0);
+ const CAPS = thumbs.map((_, j) => 13.62 + j * 0.27);
+ recWins.forEach((win, i) => {
+ const rw = presence(t, 13.32 + i * 0.08, 0.66, 15.42 + i * 0.04, 0.42);
+ put(win, { o: rw.v, x: REC_X[i], y: REC_Y + (1 - rw.a) * 40 - rw.b * 20, s: lerp(0.965, 1, rw.a) * lerp(1, 0.97, rw.b), blur: 16 * Math.max(1 - rw.a, rw.b) });
+ if (rw.v <= 0) return;
+ setSrc(win._img, frameUrl(clipOf(SITES[i], "reference"), lt));
+ win._time.textContent = `00:${lt.toFixed(2).padStart(5, "0")}`;
+ let fl = 0;
+ CAPS.forEach((c, j) => {
+ if (j % 3 === i && t >= c) fl = Math.max(fl, 0.55 * (1 - prog(t, c, c + 0.2)));
+ });
+ put(win._flash, { o: fl });
+ const p = presence(t, 14.05 + i * 0.09, 0.45, 15.2, 0.3);
+ put(win._box, { o: p.v, s: lerp(1.06, 1, p.a), blur: (1 - p.a) * 6 });
+ });
+
+ // strip: below the windows while recording, then it rises above the spec table
+ const rise = ease.inOut(prog(t, 15.5, 16.1));
+ const stripOut = presence(t, 0, 0, S[2] - 0.2, 0.4);
+ const stripX = CX - (6 * TW + 5 * 12) / 2;
+ const stripY = REC_Y + CHROME + REC_H + 44;
+ put(strip, { o: stripOut.v, x: stripX, y: lerp(stripY, 170, rise) - stripOut.b * 16, s: lerp(1, 0.9, rise), blur: stripOut.b * 10 });
+ setStyle(strip, "transform-origin", "50% 0");
+ thumbs.forEach((th, j) => {
+ const c = CAPS[j];
+ if (t < c) return put(th, { o: 0 });
+ const fly = ease.inOut(prog(t, c, c + 0.52));
+ const i = th._site;
+ setSrc(th._img, frameUrl(clipOf(SITES[i], "reference"), c - 13.0));
+ th._label.textContent = `frame ${String(Math.round((c - 13.0) * 60)).padStart(3, "0")}`;
+ // from its window's body (in strip px, before the strip moves) to slot j
+ const fromX = REC_X[i] - stripX, fromY = REC_Y + CHROME - stripY;
+ put(th, { o: clamp(fly * 3), x: lerp(fromX, j * (TW + 12), fly), y: lerp(fromY, 0, fly), s: lerp(REC_W[i] / TW, 1, fly) });
+ put(th._label, { o: prog(fly, 0.75, 1) });
+ });
+
+ // ---- spec ----
+ const sp = presence(t, 15.72, 0.62, S[2] - 0.22, 0.4);
+ put(table, { o: sp.v, x: CX - 530, y: 316 + (1 - sp.a) * 36 - sp.b * 16, s: lerp(0.97, 1, sp.a) * lerp(1, 0.98, sp.b), blur: 14 * Math.max(1 - sp.a, sp.b) });
+ let unknown = 0;
+ rows.forEach((row, k) => {
+ const a = ease.expo(prog(t, 15.9 + k * 0.1, 16.45 + k * 0.1));
+ put(row, { o: a, y: (1 - a) * 14, blur: (1 - a) * 8 });
+ row._cells.forEach((c, j) => {
+ if (!c) return;
+ const at = 16.5 + k * 0.17 + (j - 3) * 0.05;
+ const r = ease.expo(prog(t, at, at + 0.4));
+ if (r < 0.5) unknown++;
+ put(c.q, { o: 1 - r, y: -r * 10, blur: r * 6 });
+ put(c.v, { o: r, y: (1 - r) * 12, blur: (1 - r) * 6 });
+ });
+ });
+ tableCount.textContent = `${rows.length} rows · ${unknown} unknown`;
+ const cv = presence(t, 17.25, 0.6, S[2] - 0.26, 0.38);
+ put(curve, { o: cv.v, x: CX + 250, y: 716 + (1 - cv.a) * 30 - cv.b * 12, blur: 12 * Math.max(1 - cv.a, cv.b) });
+ const draw = ease.inOut(prog(t, 17.35, 17.95));
+ setStyle(curvePath, "stroke-dasharray", "330");
+ setStyle(curvePath, "stroke-dashoffset", (330 * (1 - draw)).toFixed(1));
+ const u = ease.inOutSine(((t - 17.95) % 1.2 + 1.2) % 1.2 / 1.2);
+ const bx = bez1(0.42, 0.58, u), by = bez1(0, 1, u);
+ curveDot.setAttribute("cx", (bx * 220).toFixed(1));
+ curveDot.setAttribute("cy", (134 - by * 134).toFixed(1));
+ curveDot.style.opacity = t > 17.95 ? "1" : "0";
+
+ // ---- build ----
+ const ed = presence(t, S[2] - 0.05, 0.62, S[3] - 0.25, 0.4);
+ put(editor, { o: ed.v, x: 700, y: 222 + (1 - ed.a) * 36, s: lerp(0.97, 1, ed.a), blur: 14 * Math.max(1 - ed.a, ed.b) });
+ codeLines.forEach((ln, i) => {
+ const at = S[2] + 0.18 + i * 0.105;
+ const r = prog(t, at, at + 0.26);
+ put(ln, { o: clamp(r * 2), blur: (1 - ease.outCubic(r)) * 3 });
+ setStyle(ln._text, "clip-path", `inset(0 ${((1 - ease.outCubic(r)) * 100).toFixed(1)}% 0 0)`);
+ });
+ chips.forEach((c, i) => {
+ const p = presence(t, S[2] + 0.4 + i * 0.07, 0.5, S[3] - 0.25, 0.35);
+ put(c, { o: p.v, x: 700 + [0, 82, 262, 372][i], y: 752 + (1 - p.a) * 16, blur: 8 * Math.max(1 - p.a, p.b) });
+ const used = i === 2 ? 0 : tw(t, S[2] + 1.0 + [0, 0.06, 0, 0.12][i], 0.35); // all but GSAP
+ setStyle(c, "background-color", mix("#ffffff", "#efebff", used));
+ setStyle(c, "color", mix(MUTED, ACCENT, used));
+ setStyle(c, "border-color", mix("#e6e6e6", "#cfc6ff", used));
+ });
+
+ // ---- the copy's window: preview in build, then verify, then repeat ----
+ const k = roundAt(t);
+ const toVerify = ease.inOut(prog(t, S[3] - 0.3, S[3] + 0.35));
+ const toRepeat = ease.inOut(prog(t, S[4] - 0.2, S[4] + 0.45));
+ const allOut = presence(t, 0, 0, 28.28, 0.45);
+ const cIn = presence(t, S[2] + 1.15, 0.6);
+ let cp = between(PLACES.build, PLACES.verifyCopy, toVerify);
+ cp = between(cp, PLACES.repeatCopy, toRepeat);
+ put(copyWin, { o: cIn.v * allOut.v, x: cp[0], y: cp[1] + (1 - cIn.a) * 30, s: cp[2] * lerp(0.96, 1, cIn.a), blur: 14 * Math.max(1 - cIn.a, allOut.b) });
+ const real = tw(t, S[2] + 1.55, 0.45);
+ put(copyWin._skeleton, { o: 1 - real });
+ let copyT;
+ if (t < S[3]) copyT = Math.max(0, t - (S[2] + 1.55));
+ else if (t < S[4]) copyT = t - S[3];
+ else copyT = 0.6 + (t - ROUNDS[k]) - MISS[k][3];
+ const miss = MISS[k];
+ const copyTr = t >= S[4] ? `translate(${miss[0]}px, ${miss[1]}px) scale(${miss[2]})` : "none";
+ if (cIn.v > 0) {
+ play(copyWin._trio, "copy", copyT);
+ put(copyWin._trio, { o: real });
+ copyWin._trio._imgs.forEach((img) => setStyle(img, "transform", copyTr));
+ }
+ // a flash each time the copy is filmed again
+ let cf = 0;
+ for (const at of [S[3], ...ROUNDS]) if (t >= at) cf = 0.7 * (1 - prog(t, at, at + 0.28));
+ put(copyFlash, { o: cf });
+
+ const refIn = presence(t, S[3] - 0.05, 0.6);
+ const rp = between(PLACES.verifyRef, PLACES.repeatRef, toRepeat);
+ put(refWin, { o: refIn.v * allOut.v, x: rp[0], y: rp[1] + (1 - refIn.a) * 30, s: rp[2] * lerp(0.96, 1, refIn.a), blur: 14 * Math.max(1 - refIn.a, allOut.b) });
+ const refT = t < S[4] ? Math.max(0, t - S[3]) : 0.6 + (t - ROUNDS[k]);
+ if (refIn.v > 0) play(refWin._trio, "reference", refT);
+
+ // the scan line runs across both while they replay
+ const scan = prog(t, S[3] + 0.35, S[3] + 1.95);
+ const scanO = scan > 0 && scan < 1 ? Math.min(1, Math.sin(Math.PI * scan) * 3) : 0;
+ for (const s of [scanRef, scanCopy]) put(s, { o: scanO, x: ease.inOutSine(scan) * WIN_W });
+
+ const mt = presence(t, S[3] + 0.5, 0.55, S[4] - 0.3, 0.35);
+ put(metrics, { o: mt.v, x: 716, y: 590 + (1 - mt.a) * 30 - mt.b * 16, blur: 12 * Math.max(1 - mt.a, mt.b) });
+ metrics._rows.forEach((row, i) => {
+ const at = S[3] + 0.75 + i * 0.333;
+ const a = ease.expo(prog(t, at, at + 0.5));
+ put(row, { o: a, y: (1 - a) * 12, blur: (1 - a) * 6 });
+ const n = ease.outExpo(prog(t, at + 0.1, at + 0.9));
+ row._val.textContent = row._fmt(lerp(row._a, row._b, n));
+ const ps = ease.outBack(prog(t, at + 0.8, at + 1.15));
+ put(row._pass, { o: clamp(ps * 2), s: lerp(0.6, 1, ps) });
+ });
+
+ // ---- repeat ----
+ const dIn = presence(t, S[4] + 0.05, 0.6);
+ const dp = PLACES.repeatDiff;
+ put(diffWin, { o: dIn.v * allOut.v, x: dp[0], y: dp[1] + (1 - dIn.a) * 30, s: dp[2] * lerp(0.96, 1, dIn.a), blur: 14 * Math.max(1 - dIn.a, allOut.b) });
+ if (dIn.v > 0) {
+ play(diffRef, "reference", refT);
+ play(diffCopy, "copy", copyT);
+ diffCopy._imgs.forEach((img) => setStyle(img, "transform", copyTr));
+ }
+ const ch = presence(t, S[4] + 0.2, 0.6);
+ put(chart, { o: ch.v * allOut.v, x: 715, y: 452 + (1 - ch.a) * 30, blur: 14 * Math.max(1 - ch.a, allOut.b) });
+ if (ch.v > 0) {
+ const prev = k > 0 ? VALUES[k - 1] : 18;
+ const n = ease.outExpo(prog(t, ROUNDS[k] + 0.05, ROUNDS[k] + 0.75));
+ const v = lerp(prev, VALUES[k], n);
+ bigValue.textContent = `${v < 1 ? v.toFixed(2) : v.toFixed(1)} %`;
+ roundLabel.textContent = `Round ${k + 1}`;
+ bars.forEach((b, i) => {
+ const g = ease.expo(prog(t, ROUNDS[i] + 0.05, ROUNDS[i] + 0.6));
+ const h = 230 * Math.sqrt(VALUES[i] / VALUES[0]);
+ setStyle(b._fill, "height", `${Math.max(4, h * g).toFixed(1)}px`);
+ setStyle(b._fill, "background-color", i === k ? ACCENT : "#dcdce0");
+ put(b, { o: clamp(g * 3) });
+ });
+ const m = ease.outBack(prog(t, MATCH_AT, MATCH_AT + 0.45));
+ put(matchPill, { o: clamp(m * 2), s: lerp(0.5, 1, m), blur: (1 - clamp(m)) * 6 });
+ setStyle(bigValue, "color", mix(INK, ACCENT, tw(t, MATCH_AT, 0.4)));
+ }
+}
+
+// one coordinate of a cubic bezier from (0,0) to (1,1) with control values p1, p2
+function bez1(p1, p2, u) {
+ const v = 1 - u;
+ return 3 * v * v * u * p1 + 3 * v * u * u * p2 + u * u * u;
+}
diff --git a/site/video/src/install.js b/site/video/src/install.js
new file mode 100644
index 0000000..d6a2134
--- /dev/null
+++ b/site/video/src/install.js
@@ -0,0 +1,81 @@
+// The end card: "/reanimate" slides in again with its onion skins, the install command types itself into
+// a dark pill, the copy button is pressed, then how to start and where to find it. The word, gray all
+// video, turns to ink a letter at a time. Fades to white at the end.
+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 to = DURATION + 1;
+
+const AT = bar(20.5); // 56.83
+const INK_AT = bar(22); // 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;
+
+export function init(r) {
+ root = r;
+ glow = el("div", "intro-glow end-glow", root);
+ ghosts = [0.2, 0.11, 0.06].map((alpha) => {
+ const g = el("div", "end-word", root, "/reanimate");
+ g.style.color = `rgb(140 140 148 / ${alpha})`;
+ return g;
+ });
+ word = el("div", "end-word", root);
+ chars = [..."/reanimate"].map((c) => el("span", "intro-char", word, c));
+ wordW = word.getBoundingClientRect().width;
+ pill = el("div", "end-pill", root, `<span class="end-dollar">$</span>`);
+ typed = el("span", "end-typed", pill);
+ caret = el("i", "end-caret", pill);
+ copy = el("span", "end-copy", pill);
+ copyLabel = el("span", "", copy, "Copy");
+ copy._check = el("span", "end-copied", copy, `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>Copied`);
+ hint = el("p", "end-hint", root, `Then, in Claude Code, type <code>/reanimate</code> and say what you want.`);
+ links = el("p", "end-links", root, `reanimate.niazmorshed.dev<i>·</i>github.com/NiazMorshed2007/reanimate`);
+ // the pill is as wide as the whole command, so it doesn't grow while typing
+ typed.textContent = CMD;
+ pill._w = pill.getBoundingClientRect().width;
+ pill.style.width = `${pill._w}px`;
+ typed.textContent = "";
+}
+
+export function render(t) {
+ const end = 1 - ease.inOutSine(prog(t, DURATION - 0.45, DURATION - 0.02));
+
+ const g = presence(t, AT - 0.4, 1.6).v;
+ put(glow, { o: g * 0.9 * end, y: -70, s: lerp(0.9, 1, g) });
+
+ // the word, as in the intro: in from the left, onion skins behind, letters de-blurring
+ const slide = (u) => -150 * (1 - ease.outQuart(prog(u, AT - 0.1, AT + 1.0)));
+ const x = 960 - wordW / 2;
+ put(word, { o: end, x: x + slide(t), y: 296 });
+ chars.forEach((c, i) => {
+ const a = ease.expo(prog(t, AT - 0.05 + i * 0.045, AT + 0.6 + i * 0.045));
+ put(c, { o: a, y: (1 - a) * 30, blur: (1 - a) * 14 });
+ setStyle(c, "color", mix(SUBTLE, INK, ease.inOutSine(prog(t, INK_AT - 0.15 + i * 0.06, INK_AT + 0.55 + i * 0.06))));
+ });
+ const skins = presence(t, AT - 0.05, 0.3, AT + 0.6, 0.5).v;
+ ghosts.forEach((gh, k) => {
+ const lag = (k + 1) * 0.08;
+ put(gh, { o: skins * clamp((slide(t) - slide(t - lag)) / 14) * end, x: x + slide(t - lag), y: 296, blur: 1 + k });
+ });
+
+ // the command
+ const pp = presence(t, AT + 0.45, 0.6);
+ put(pill, { o: pp.v * end, x: 960 - pill._w / 2, y: 512 + (1 - pp.a) * 24, s: lerp(0.96, 1, pp.a), blur: (1 - pp.a) * 12 });
+ const n = Math.round(CMD.length * prog(t, AT + 0.75, AT + 0.75 + 4 * BEAT * 0.55));
+ if (typed._n !== n) typed.textContent = CMD.slice(0, (typed._n = n));
+ const typing = n < CMD.length;
+ put(caret, { o: typing || ((t - T0) / BEAT) % 1 < 0.55 ? 1 : 0 });
+ const cp = presence(t, AT + 2.3, 0.5);
+ put(copy, { o: cp.v, x: 0, s: lerp(0.9, 1, cp.a) * (1 - 0.08 * Math.sin(Math.PI * prog(t, AT + 3.3, AT + 3.5))) });
+ const copied = ease.expo(prog(t, AT + 3.42, AT + 3.8));
+ put(copyLabel, { o: 1 - copied, blur: copied * 6 });
+ put(copy._check, { o: copied, blur: (1 - copied) * 6 });
+ setStyle(copy, "color", copied > 0.5 ? "#d9d3ff" : "#a1a1aa");
+
+ const h = presence(t, AT + 2.05, 0.6);
+ put(hint, { o: h.v * end, y: 668 + (1 - h.a) * 16, blur: (1 - h.a) * 10 });
+ const l = presence(t, AT + 2.75, 0.7);
+ put(links, { o: l.v * end, y: 968 + (1 - l.a) * 12, blur: (1 - l.a) * 8 });
+}
diff --git a/site/video/src/intro.js b/site/video/src/intro.js
new file mode 100644
index 0000000..2250c56
--- /dev/null
+++ b/site/video/src/intro.js
@@ -0,0 +1,188 @@
+// "/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";
+
+export const name = "intro";
+export const from = 0;
+export const to = 28.85;
+
+const WORD = "/reanimate";
+const BIG = 168; // title size, px
+const ROW = 56; // wheel size, px
+const STEP = 20; // degrees between rows on the wheel
+const ROW_GAP = 86; // px between the centre row and the next
+const R = ROW_GAP / Math.sin((STEP * Math.PI) / 180);
+const MID = 540; // the wheel's centre line
+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)
+
+// the sources in [brackets] are tinted when the row is picked; the last one is "how it works"' header
+const PROMPTS = [
+ "the hero on [example.com], into Hero.tsx",
+ "this loader, 0:03 to 0:05 of [loader.mov]",
+ "the card hover in [this gif], pixel-perfect",
+ "the logo marquee in [this video], with our logos",
+ "the globe on [stripe.com], in three.js",
+ "[this Lottie file], as CSS keyframes",
+ "the feature cards on [clerk.com]",
+ "the robot on [workos.com], into Hero.tsx",
+ "the page transition in [demo.mp4]",
+ "three widgets from [stripe.com], [resend.com] and [clerk.com]",
+];
+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.
+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],
+];
+function wheelAt(t) {
+ let p = STEPS[0][2];
+ for (const [a, b, p0, p1, e] of STEPS) {
+ if (t < a) break;
+ p = t >= b ? p1 : lerp(p0, p1, e(prog(t, a, b)));
+ }
+ return p;
+}
+
+let root, glow, tagline, caption, line, band, word, chars, ghosts, wheel, rows, caret, key, status, spinner, check;
+let L; // layout, measured once the fonts are in
+
+export function init(r) {
+ root = r;
+ glow = el("div", "intro-glow", root);
+ tagline = el("p", "intro-tagline", root, "Reverse-engineer animations you like. Build your own on top.");
+ caption = el("p", "intro-caption", root, "Say what you want, where it is and where it should go.");
+ line = el("div", "intro-line", root);
+ band = el("div", "intro-band", line);
+ ghosts = [0.2, 0.12, 0.07, 0.04].map((alpha) => {
+ const g = el("div", "intro-word intro-word--ghost", line, WORD);
+ g.style.color = `rgb(140 140 148 / ${alpha})`;
+ return g;
+ });
+ word = el("div", "intro-word", line);
+ chars = [...WORD].map((c) => el("span", "intro-char", word, c));
+ wheel = el("div", "intro-wheel", line);
+ rows = PROMPTS.map((p) => {
+ const row = el("div", "intro-row", wheel, promptHtml(p));
+ row._src = [...row.querySelectorAll(".intro-src")];
+ return row;
+ });
+ caret = el("div", "intro-caret", line);
+ key = el("div", "intro-key", line, `<svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 5v7a3 3 0 0 1-3 3H5"/><path d="m9 19-4-4 4-4"/></svg>`);
+ status = el("div", "intro-status", line);
+ spinner = el("div", "intro-spinner", status, `<svg width="64" height="64" viewBox="0 0 64 64"><circle cx="32" cy="32" r="24" fill="none" stroke="#e4e4e7" stroke-width="6"/><path d="M32 8a24 24 0 0 1 24 24" fill="none" stroke="${ACCENT}" stroke-width="6" stroke-linecap="round"/></svg>`);
+ check = el("div", "intro-check", status, `<svg width="64" height="64" viewBox="0 0 64 64"><circle cx="32" cy="32" r="30" fill="${ACCENT}"/><path d="M20 33l8 8 16-17" fill="none" stroke="#fff" stroke-width="6" stroke-linecap="round" stroke-linejoin="round"/></svg>`);
+
+ // layout
+ const wordW = word.getBoundingClientRect().width;
+ chars.forEach((c) => (c.style.color = SUBTLE));
+ const promptW = PROMPTS.map((p) => measure(promptHtml(p), "intro-row").w);
+ const sW = ROW / BIG;
+ const rowWordW = wordW * sW;
+ const total = rowWordW + GAP + Math.max(...promptW) + TAIL;
+ const xW = (W - total) / 2;
+ const xP = xW + rowWordW + GAP;
+ const lastEnd = xP + promptW[LAST] + TAIL;
+ L = { wordW, sW, promptW, xW, xP, lineCx: (xW - 36 + lastEnd) / 2 };
+ rows.forEach((row) => (row.style.left = `${xP}px`));
+ wheel.style.perspectiveOrigin = `${xP + Math.max(...promptW) / 2}px ${MID}px`;
+}
+
+export function render(t) {
+ const { wordW, sW, promptW, xW, xP } = L;
+ const p = wheelAt(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 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));
+ 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;
+ 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));
+ 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 });
+
+ // ---- 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 spinBlur = Math.min(9, Math.abs(v) * 0.75);
+ rows.forEach((row, i) => {
+ const d = i - p;
+ if (Math.abs(d) > 4.6 || live <= 0) return put(row, { o: 0 });
+ const a = d * STEP;
+ const rad = (a * Math.PI) / 180;
+ const sel = clamp(1 - Math.abs(d));
+ const away = i === LAST ? 0 : scatter;
+ const fade = clamp(1 - Math.abs(d) / 4.4) ** 1.3;
+ put(row, {
+ o: live * fade * (1 - away) * (Math.abs(a) > 88 ? 0 : 1),
+ y: R * Math.sin(rad) + Math.sign(d || 1) * away * 170,
+ z: R * (Math.cos(rad) - 1),
+ rx: -a,
+ blur: Math.max(0, Math.abs(d) - 0.35) * 1.4 + spinBlur * (1 - sel * 0.4) + away * 12,
+ });
+ setStyle(row, "color", mix(FAINT, INK, sel));
+ row._src.forEach((src) => setStyle(src, "color", mix(FAINT, ACCENT, sel)));
+ });
+
+ // 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 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 });
+
+ 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));
+ 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));
+ 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(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,
+ });
+ 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 });
+}
diff --git a/site/video/src/lib.js b/site/video/src/lib.js
new file mode 100644
index 0000000..e4b24ea
--- /dev/null
+++ b/site/video/src/lib.js
@@ -0,0 +1,217 @@
+// Shared helpers for the demo video. Everything on screen is a pure function of the time t (seconds), so
+// any frame can be drawn on its own: the renderer seeks to k / FPS and screenshots.
+
+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.
+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 INK = "#141414";
+export const MUTED = "#737373";
+export const FAINT = "#b4b4b4";
+export const SUBTLE = "#a6a6ad"; // "/reanimate", until the end card turns it to INK
+export const ACCENT = "#533afd";
+
+// ---------- maths ----------
+
+export const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x));
+export const lerp = (a, b, p) => a + (b - a) * p;
+export const prog = (t, a, b) => clamp((t - a) / (b - a));
+
+export function bezier(x1, y1, x2, y2) {
+ const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx;
+ const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
+ const sx = (u) => ((ax * u + bx) * u + cx) * u;
+ const sy = (u) => ((ay * u + by) * u + cy) * u;
+ const dx = (u) => (3 * ax * u + 2 * bx) * u + cx;
+ return (x) => {
+ if (x <= 0) return 0;
+ if (x >= 1) return 1;
+ let u = x;
+ for (let i = 0; i < 8; i++) {
+ const e = sx(u) - x;
+ if (Math.abs(e) < 1e-6) break;
+ const d = dx(u);
+ if (Math.abs(d) < 1e-6) break;
+ u -= e / d;
+ }
+ return sy(clamp(u));
+ };
+}
+
+export const ease = {
+ linear: (x) => x,
+ inCubic: (x) => x * x * x,
+ outCubic: (x) => 1 - (1 - x) ** 3,
+ inOutCubic: (x) => (x < 0.5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2),
+ outQuart: (x) => 1 - (1 - x) ** 4,
+ outQuint: (x) => 1 - (1 - x) ** 5,
+ inOutQuart: (x) => (x < 0.5 ? 8 * x ** 4 : 1 - (-2 * x + 2) ** 4 / 2),
+ outExpo: (x) => (x >= 1 ? 1 : 1 - 2 ** (-10 * x)),
+ inOutSine: (x) => -(Math.cos(Math.PI * x) - 1) / 2,
+ outBack: (x) => 1 + 2.4 * (x - 1) ** 3 + 1.4 * (x - 1) ** 2,
+ // the curves the site and the Clerk cards use
+ expo: bezier(0.16, 1, 0.3, 1),
+ soft: bezier(0.45, 0, 0.2, 1),
+ inOut: bezier(0.65, 0, 0.35, 1),
+};
+
+/** Eased progress of a tween that starts at `a` and lasts `d` seconds. */
+export const tw = (t, a, d, e = ease.outCubic) => e(prog(t, a, a + d));
+
+/** Deterministic noise in [0, 1) for an integer seed. */
+export function hash(n) {
+ let x = Math.imul((n | 0) ^ 0x9e3779b9, 0x85ebca6b);
+ x = Math.imul(x ^ (x >>> 13), 0xc2b2ae35);
+ return ((x ^ (x >>> 16)) >>> 0) / 4294967296;
+}
+
+// ---------- the blur-and-fade the whole video uses ----------
+
+/**
+ * How present something is at t: fades in over [inAt, inAt + inDur], out over [outAt, outAt + outDur].
+ * Returns `a` (in progress), `b` (out progress) and `v` (visible amount).
+ */
+export function presence(t, inAt, inDur = 0.5, outAt = Infinity, outDur = 0.4, eIn = ease.expo, eOut = ease.inOutCubic) {
+ const a = eIn(prog(t, inAt, inAt + inDur));
+ const b = Number.isFinite(outAt) ? eOut(prog(t, outAt, outAt + outDur)) : 0;
+ return { a, b, v: a * (1 - b) };
+}
+
+/** Blur-fade an element in and out: rises `dy` px from below on the way in, drifts `dyOut` on the way out. */
+export function blurFade(el, t, { inAt, inDur = 0.55, outAt = Infinity, outDur = 0.4, blur = 14, dy = 18, dyOut = -12, s0 = 1, s1 = 1, x = 0, y = 0, s = 1, eIn, eOut } = {}) {
+ const { a, b, v } = presence(t, inAt, inDur, outAt, outDur, eIn, eOut);
+ put(el, {
+ o: v,
+ x,
+ y: y + (1 - a) * dy + b * dyOut,
+ s: s * lerp(s0, 1, a) * lerp(1, s1, b),
+ blur: blur * Math.max(1 - a, b),
+ });
+ return v;
+}
+
+// ---------- styles ----------
+
+const f = (n, d = 2) => (Math.abs(n) < 1e-4 ? "0" : n.toFixed(d));
+
+/** Sets opacity, transform and blur in one go, only writing what changed. */
+export function put(el, { o = 1, x = 0, y = 0, z = 0, s = 1, sx = 1, sy = 1, rx = 0, ry = 0, rz = 0, blur = 0, raw = "" } = {}) {
+ let tr = "";
+ if (x || y || z) tr += `translate3d(${f(x)}px,${f(y)}px,${f(z)}px) `;
+ if (rx) tr += `rotateX(${f(rx, 3)}deg) `;
+ if (ry) tr += `rotateY(${f(ry, 3)}deg) `;
+ if (rz) tr += `rotateZ(${f(rz, 3)}deg) `;
+ if (s !== 1 || sx !== 1 || sy !== 1) tr += `scale(${f(s * sx, 4)},${f(s * sy, 4)}) `;
+ tr += raw;
+ const style = el.style;
+ const op = o <= 0.002 ? "0" : o >= 0.998 ? "1" : o.toFixed(3);
+ if (el._o !== op) {
+ style.opacity = op;
+ style.visibility = op === "0" ? "hidden" : "";
+ el._o = op;
+ }
+ if (op === "0") return;
+ tr = tr.trim() || "none";
+ if (el._tr !== tr) style.transform = el._tr = tr;
+ const fl = blur > 0.04 ? `blur(${f(blur)}px)` : "none";
+ if (el._fl !== fl) style.filter = el._fl = fl;
+}
+
+export function setStyle(el, prop, value) {
+ const key = "_s_" + prop;
+ if (el[key] !== value) {
+ el.style.setProperty(prop, value);
+ el[key] = value;
+ }
+}
+
+export function show(el, on) {
+ const v = on ? "" : "none";
+ if (el._d !== v) el.style.display = el._d = v;
+}
+
+export function mix(c1, c2, p) {
+ const a = hex(c1), b = hex(c2);
+ return `rgb(${Math.round(lerp(a[0], b[0], p))},${Math.round(lerp(a[1], b[1], p))},${Math.round(lerp(a[2], b[2], p))})`;
+}
+const hexCache = new Map();
+function hex(c) {
+ let v = hexCache.get(c);
+ if (!v) {
+ const n = parseInt(c.slice(1), 16);
+ v = [(n >> 16) & 255, (n >> 8) & 255, n & 255];
+ hexCache.set(c, v);
+ }
+ return v;
+}
+
+// ---------- DOM ----------
+
+export function el(tag, cls, parent, html) {
+ const e = document.createElement(tag);
+ if (cls) e.className = cls;
+ if (html !== undefined) e.innerHTML = html;
+ if (parent) parent.append(e);
+ return e;
+}
+
+/** Width and height of some text in a given class, laid out off screen. */
+export function measure(html, cls) {
+ const probe = el("span", cls, document.body, html);
+ probe.style.cssText += ";position:absolute;left:-9999px;top:0;white-space:nowrap;visibility:hidden";
+ const r = probe.getBoundingClientRect();
+ probe.remove();
+ return { w: r.width, h: r.height };
+}
+
+// ---------- recorded clips ----------
+
+let manifest = {};
+export const setManifest = (m) => (manifest = m);
+export const clipInfo = (slug) => manifest[slug];
+
+/** Length of a clip in seconds. */
+export const clipLen = (slug) => (manifest[slug].frames - 1) / manifest[slug].fps;
+
+/** URL of the frame of `slug` at `lt` seconds into it (held at the ends, or wrapped with loop). */
+export function frameUrl(slug, lt, { small = false, loop = false } = {}) {
+ const c = manifest[slug];
+ let i = Math.round(lt * c.fps);
+ i = loop ? ((i % c.frames) + c.frames) % c.frames : clamp(i, 0, c.frames - 1);
+ return `clips/${slug}/${small ? "t" : "f"}/${String(i + 1).padStart(4, "0")}.jpg`;
+}
+
+// Images whose source changed this frame; the renderer waits for them to decode before the screenshot.
+let pending = [];
+export function setSrc(img, url) {
+ if (img._u === url) return;
+ img._u = url;
+ img.src = url;
+ pending.push(img.decode().catch(() => {}));
+}
+export async function settleImages() {
+ while (pending.length) {
+ const p = pending;
+ pending = [];
+ await Promise.all(p);
+ }
+}
+
+/** An <img> showing a clip, sized to `w` x `h` CSS px. */
+export function clipImg(parent, slug, w, h, cls = "clip") {
+ const img = el("img", cls, parent);
+ img.decoding = "sync";
+ img.draggable = false;
+ img.width = w;
+ img.height = h;
+ img.alt = "";
+ img.dataset.slug = slug;
+ return img;
+}
diff --git a/site/video/src/main.js b/site/video/src/main.js
new file mode 100644
index 0000000..3acfcef
--- /dev/null
+++ b/site/video/src/main.js
@@ -0,0 +1,113 @@
+// 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):
+//
+// 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";
+import * as intro from "./intro.js";
+import * as how from "./how.js";
+import * as examples from "./examples.js";
+import * as helix from "./helix.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();