Skip to content

programmatic video rendering framework that is actually fast

feat: add made-of-motion GPU promo example (#193)

Dmitriy Kovalenko81dd93738733
diff --git a/Cargo.lock b/Cargo.lock
index 8a16d75e..2c791002 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1916,6 +1916,16 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dae608c151f68243f2b000364e1f7b186d9c29845f7d2d85bd31b9ad77ad552b"
+[[package]]
+name = "made-of-motion"
+version = "1.2.0"
+dependencies = [
+ "fframes",
+ "fframes_native_player",
+ "fframes_skia_renderer",
+ "flate2",
+]
+
[[package]]
name = "malloc_buf"
version = "0.0.6"
diff --git a/Cargo.toml b/Cargo.toml
index ec25b3a2..89ac55d2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -48,6 +48,7 @@ members = [
# "fframes-lyon-renderer",
"examples/signal-lab",
"examples/fframes-intro",
+ "examples/made-of-motion",
]
[workspace.lints.rust]
diff --git a/examples/made-of-motion/.gitignore b/examples/made-of-motion/.gitignore
new file mode 100644
index 00000000..e27a0e60
--- /dev/null
+++ b/examples/made-of-motion/.gitignore
@@ -0,0 +1,4 @@
+dynamic_media/*
+!dynamic_media/portrait-clean.mp4
+!dynamic_media/soundtrack.wav
+!dynamic_media/soundtrack.m4a
diff --git a/examples/made-of-motion/Cargo.toml b/examples/made-of-motion/Cargo.toml
new file mode 100644
index 00000000..95d29631
--- /dev/null
+++ b/examples/made-of-motion/Cargo.toml
@@ -0,0 +1,23 @@
+[package]
+name = "made-of-motion"
+version = "1.2.0"
+edition = "2024"
+publish = false
+
+[dependencies]
+flate2 = "1"
+fframes = { workspace = true, features = ["compile-time-svgtree", "cli"] }
+
+[target.'cfg(target_os = "macos")'.dependencies]
+fframes_skia_renderer = { workspace = true, features = ["metal"] }
+fframes_native_player = { workspace = true, features = ["metal"] }
+
+[target.'cfg(not(target_os = "macos"))'.dependencies]
+fframes_skia_renderer = { workspace = true, features = ["vulkan"] }
+fframes_native_player.workspace = true
+
+[target.'cfg(not(windows))'.dependencies]
+fframes = { workspace = true, features = ["h264", "libav-agree-gpl", "build-portable"] }
+
+[lints]
+workspace = true
diff --git a/examples/made-of-motion/README.md b/examples/made-of-motion/README.md
new file mode 100644
index 00000000..569848ec
--- /dev/null
+++ b/examples/made-of-motion/README.md
@@ -0,0 +1,140 @@
+# Made of motion
+
+A 489-frame, 1440×1080 fframes promo with pixel objects, a continuous perspective
+carousel, thermal performances, paper texture, and per-exposure vector ink. Metal
+on macOS; Vulkan elsewhere. This GPU example has no web-editor bridge.
+
+The film adapts the [reference film](https://x.com/jordanarchivess/status/2107536262894915762)
+to fframes: “how do you turn a few lines of code into a feeling?”, three cards
+(**code. / motion. / feeling.**), and seven flying letters assembling into the
+fframes wordmark. Original cut boundaries and audio are retained.
+
+## Final assets
+
+This example contains the final data used by the approved film. No Python,
+reconstruction scripts, analysis inputs, or original reference download are needed
+to build, preview, or export it. `assets.json` records the source provenance,
+tracing settings, and SHA-256 hashes of the final assets.
+
+| Location | Contents |
+| --- | --- |
+| `src/vector_ink/*.paths.gz` | Five compressed archives of text SVG paths, covering all measured ink exposures |
+| `src/*_capture.rs` | Final source-frame measurements for ink, opening effects, hand placement, and camera poses |
+| `src/opening-type.path` | Authored title geometry snapped to a pixel grid for the opening's one-frame type pulse |
+| `media/` | Three embedded fonts, the original pixel-object atlas, and the hand silhouette/heat-field atlas |
+| `dynamic_media/portrait-clean.mp4` | Final cleaned portrait footage |
+| `dynamic_media/soundtrack.wav` | Stereo float-PCM soundtrack for native playback |
+| `dynamic_media/soundtrack.m4a` | Original AAC packets for final export |
+
+Keep all three runtime media files next to the example when moving the project.
+They are included in the source asset set; missing media is an error, not a request
+to regenerate it. The final export belongs in `output/made-of-motion.mp4`;
+`output/` is excluded from source control.
+
+## Native preview
+
+Run these commands from the repository root:
+
+```sh
+cargo run --release -p made-of-motion -- preview 0s
+cargo run --release -p made-of-motion -- preview 0.7s # handwritten pen and star
+cargo run --release -p made-of-motion -- preview 3.5s # orange ball and portrait
+cargo run --release -p made-of-motion -- preview 6.5s # ring and three handoffs
+cargo run --release -p made-of-motion -- preview 13.6s # hand and white strokes
+cargo run --release -p made-of-motion -- preview 19s # red ink and wordmark
+```
+
+Space pauses; h/l seek; j/k step one frame. Use the native preview for revisions
+before requesting a full export.
+
+`--ink-only` displays the vector exposures at their original source positions on
+neutral paper, without objects, footage, grain or branding adaptations. It also
+works with frame, strip, onion, SVG and inspect commands.
+
+```sh
+cargo run --release -p made-of-motion -- --ink-only preview 0s
+cargo run --release -p made-of-motion -- inspect --all-frames
+cargo run --release -p made-of-motion -- --ink-only frame 21,51,90,170,334,416
+cargo run --release -p made-of-motion -- onion 158..199 -n 10 -o output/onion-orbit.png
+cargo run --release -p made-of-motion -- --ink-only onion 414..430 -n 12 -o output/onion-ink.png
+```
+
+## What is vector, shader, or footage?
+
+| Layer | Implementation |
+| --- | --- |
+| Handwritten opening, brown/red/white pen strokes, black dots and whips, broad gray trails | SVG paths traced independently for each measured exposure |
+| Portrait marks, hand marks, red feature-card marks and inter-card speed lines | Per-exposure SVG contours; source caption/icon regions excluded or reconstructed |
+| Red marks around the ending letters | Four measured SVG nib tracks translated onto seven brand letters |
+| Portrait, 3.88–6.38s | Cleaned source footage with SVG ink added back and shader caption cleanup |
+| Hand, 13.83–15.92s | Source-derived silhouette and smooth heat field; shader recreates palette, background and light |
+| Electric star and contracting orange ball | SkSL geometry with measured centre/radius/rotation/cusp parameters |
+| Paper, grain, four-frame thermal cut and collision light | Procedural shaders |
+| Icons, ring, hero motion, typography | Original pixel atlas and Rust animation; selected motion measurements inform poses |
+
+No reference ink pixels are sampled at runtime. `VectorInk` decompresses the text
+SVG archives and builds the scene trees once, then samples by global frame index.
+Contours retain pressure and soft trails with 64 opacity levels, even-odd fills,
+0.4px simplification tolerance, and 0.1px coordinate precision.
+
+This is vector rotoscoping, not recovery of the creator's original splines or a
+fluid simulation. Source compression, pigment/opacity estimation and reconstructed
+occlusions prevent a claim of pixel-identical recovery. The brand ending preserves
+the larger final red gestures through frame 488, following assembly and the fast
+camera pullback. Only the independent black gestures fade. Ink-only mode keeps
+the four original tracks at their source positions.
+
+The featured icons occupy permanent slots in one continuously rotating wheel.
+Flights cover frames 190–205, 227–242 and 261–270; returns cover 214–225, 249–259
+and 280–294. During feature cards the other icons are hidden while their tracks
+continue rotating. Returning icons dock in their moving vacant slots.
+
+`objects.rs` prepares the trajectories with cached `timeline!` animations;
+`hero.rs` uses those same poses. The motion diamond eases between measured camera
+poses. `flight.rs` retains the seven letter flights, three-frame assembly and
+four-frame camera pullback.
+
+`opening.rs` retains the oversized type through frame 13, with full-width dashed
+x-height/baseline rulers, lateral camera moves and a cursor wipe. Two one-frame
+color flashes precede it. A pixel pulse and four broken-line exposures collapse
+into a measured selection around the adapted copy; that selection blinks on
+frames 18–20 and 22. The large type intentionally crosses the canvas edge during
+the camera moves, so inspection reports expected clipping warnings there.
+
+## Explicit final export
+
+The source has 489 frames at 24000/1001 fps. Native preview uses 24 fps, about 20ms
+shorter over the whole film, with decoded stereo audio and no gain changes or
+limiting. For delivery, the following FFmpeg step restores the rational cadence
+and copies the original AAC packets unchanged. It replaces the final output file.
+
+Run only when a full export is requested:
+
+```sh
+cargo run --release -p made-of-motion -- render \
+ -o examples/made-of-motion/output/made-of-motion.24fps.mp4
+
+ffmpeg -hide_banner -loglevel error -y \
+ -i examples/made-of-motion/output/made-of-motion.24fps.mp4 \
+ -i examples/made-of-motion/dynamic_media/soundtrack.m4a \
+ -map 0:v:0 -map 1:a:0 \
+ -vf 'settb=1/24000,setpts=N*1001' -r 24000/1001 -fps_mode cfr \
+ -c:v libx264 -crf 16 -preset slow -pix_fmt yuv420p \
+ -c:a copy -video_track_timescale 24000 -movflags +faststart \
+ examples/made-of-motion/output/made-of-motion.mp4
+```
+
+Verify the delivered video:
+
+```sh
+ffprobe -v error -select_streams v:0 \
+ -show_entries stream=width,height,r_frame_rate,nb_frames \
+ examples/made-of-motion/output/made-of-motion.mp4
+
+ffmpeg -v error -i examples/made-of-motion/output/made-of-motion.mp4 \
+ -map 0:a:0 -c:a copy -f adts - | shasum -a 256
+```
+
+Expect 1440×1080, 489 frames, `24000/1001` fps, and the `audio_adts_sha256` value
+from `assets.json`. No tests are added; use inspection, frames, onions, formatting
+and the repository's Clippy rules when changing the example.
diff --git a/examples/made-of-motion/assets.json b/examples/made-of-motion/assets.json
new file mode 100644
index 00000000..0b39af81
--- /dev/null
+++ b/examples/made-of-motion/assets.json
@@ -0,0 +1,95 @@
+{
+ "reference": "https://x.com/jordanarchivess/status/2107536262894915762",
+ "source_sha256": "7f170273c308c7fb2ce17126fba4d0048e4a9a476438c76144a58c9c840309df",
+ "source_dimensions": [
+ 1440,
+ 1080
+ ],
+ "source_fps": "24000/1001",
+ "source_frames": 489,
+ "preview_fps": 24,
+ "audio_adts_sha256": "091c219bd421472f5fa74f7c1987a86db61ca8148962e6ee1302adc0f394c30a",
+ "vector_ink": {
+ "method": "Supervised per-exposure matting followed by subpixel opacity contour vectorization",
+ "opacity_levels": 64,
+ "contour_tolerance_pixels": 0.4,
+ "coordinate_precision_pixels": 0.1,
+ "pigment_frames": 384,
+ "path_count": 34272,
+ "limitations": [
+ "Visible source pigment is measured; overlapping source text and icons are excluded or reconstructed from annotated curves.",
+ "Opacity and pigment color are estimates from the compressed reference, not original alpha layers.",
+ "The branded ending maps four measured red nib tracks onto seven approved letter tracks, preserving the final gestures through assembly and camera pullback. --ink-only retains original source positions."
+ ]
+ },
+ "files": {
+ "dynamic_media/portrait-clean.mp4": {
+ "bytes": 4570487,
+ "sha256": "215ebf6ccec5496524e7d6f63d892d1ddb54ab08de3157c87104deb5edc8ea1c"
+ },
+ "dynamic_media/soundtrack.m4a": {
+ "bytes": 332207,
+ "sha256": "487fb902ee7ed1cbc733ea37214ebcf84c7d7f42681fc18721f1fa7249c67e17"
+ },
+ "dynamic_media/soundtrack.wav": {
+ "bytes": 7856220,
+ "sha256": "200f0958e057292b5e4f2689e4b8c14fcf9cfea4e0110fa66e5fe781a56049fd"
+ },
+ "media/InstrumentSerif-Italic.ttf": {
+ "bytes": 71592,
+ "sha256": "08939b8bdf534afec24ae0ef5e03f948940cd9a8fe08e7fecbad040e62327385"
+ },
+ "media/Inter_24pt-Bold.ttf": {
+ "bytes": 344028,
+ "sha256": "6e56a080abad19a16d985801909378d26d0da425265289d5d1ebf38baa50cba9"
+ },
+ "media/JetBrainsMono-Regular.ttf": {
+ "bytes": 114320,
+ "sha256": "4391a6a20152f6c1cd05524e81c594b1a556117e027332a1c7042e799b7777e8"
+ },
+ "media/hand-field.png": {
+ "bytes": 3492320,
+ "sha256": "cb1813c57d9356df9e92a27ed3d5f4bcfb4964a88999984c8c9359dfd024a58e"
+ },
+ "media/objects.png": {
+ "bytes": 11583,
+ "sha256": "370bade0a5b2347bc50dd6daa286a2d271702900f5fabdae327f2d118d97aec3"
+ },
+ "src/ink_capture.rs": {
+ "bytes": 5890,
+ "sha256": "c7df1a69fc121a7836982daece6a96db0ac76fd0be7f764421d03c05264a9c76"
+ },
+ "src/opening_capture.rs": {
+ "bytes": 2297,
+ "sha256": "a9e99623b2a04aa66a57d7680f7d84da2528ebcf2fbed33dbf653ab3661cde90"
+ },
+ "src/restoration_capture.rs": {
+ "bytes": 3043,
+ "sha256": "c7d3edc6cc0a995cffdec368d6ba07d292a2d306697ae32d32305559ca14b193"
+ },
+ "src/vector_ink/000.paths.gz": {
+ "bytes": 3161634,
+ "sha256": "e603c3b3b64a7bfa69a39d0255ea3eb58a81334cffa64722aa74058ca4ca25f5"
+ },
+ "src/vector_ink/100.paths.gz": {
+ "bytes": 1583603,
+ "sha256": "e266b7a4e11a532c847113a255433668936fc6c576654be6a6a94e9d54c25eb9"
+ },
+ "src/vector_ink/200.paths.gz": {
+ "bytes": 7813293,
+ "sha256": "5c27feb87a58f3b89a9c26562c66f0ca2189130767ec4c8683cdd105c6cce180"
+ },
+ "src/vector_ink/300.paths.gz": {
+ "bytes": 2189282,
+ "sha256": "0f45f14c0f941a338bac41c9b0c462989399a40727ff7b8001670a36eaf155c4"
+ },
+ "src/vector_ink/400.paths.gz": {
+ "bytes": 4653529,
+ "sha256": "2c7ab1d08dfd61c7bca24e1df178fe257fe23c3472f9a02955c78d74a9929af7"
+ },
+ "src/opening-type.path": {
+ "bytes": 3182,
+ "sha256": "e3c3d27400c94e980b49728f075f21eef041da4d0fd0895a69da0a12bbae14d8"
+ }
+ }
+}
diff --git a/examples/made-of-motion/dynamic_media/portrait-clean.mp4 b/examples/made-of-motion/dynamic_media/portrait-clean.mp4
new file mode 100644
index 00000000..ae46cac2
Binary files /dev/null and b/examples/made-of-motion/dynamic_media/portrait-clean.mp4 differ
diff --git a/examples/made-of-motion/dynamic_media/soundtrack.m4a b/examples/made-of-motion/dynamic_media/soundtrack.m4a
new file mode 100644
index 00000000..7a6dfd8d
Binary files /dev/null and b/examples/made-of-motion/dynamic_media/soundtrack.m4a differ
diff --git a/examples/made-of-motion/dynamic_media/soundtrack.wav b/examples/made-of-motion/dynamic_media/soundtrack.wav
new file mode 100644
index 00000000..8310122d
Binary files /dev/null and b/examples/made-of-motion/dynamic_media/soundtrack.wav differ
diff --git a/examples/made-of-motion/media/InstrumentSerif-Italic.ttf b/examples/made-of-motion/media/InstrumentSerif-Italic.ttf
new file mode 100644
index 00000000..192c3eda
Binary files /dev/null and b/examples/made-of-motion/media/InstrumentSerif-Italic.ttf differ
diff --git a/examples/made-of-motion/media/Inter_24pt-Bold.ttf b/examples/made-of-motion/media/Inter_24pt-Bold.ttf
new file mode 100644
index 00000000..46b3583c
Binary files /dev/null and b/examples/made-of-motion/media/Inter_24pt-Bold.ttf differ
diff --git a/examples/made-of-motion/media/JetBrainsMono-Regular.ttf b/examples/made-of-motion/media/JetBrainsMono-Regular.ttf
new file mode 100644
index 00000000..7d26f5a5
Binary files /dev/null and b/examples/made-of-motion/media/JetBrainsMono-Regular.ttf differ
diff --git a/examples/made-of-motion/media/hand-field.png b/examples/made-of-motion/media/hand-field.png
new file mode 100644
index 00000000..d7293dbe
Binary files /dev/null and b/examples/made-of-motion/media/hand-field.png differ
diff --git a/examples/made-of-motion/media/objects.png b/examples/made-of-motion/media/objects.png
new file mode 100644
index 00000000..78f4f37a
Binary files /dev/null and b/examples/made-of-motion/media/objects.png differ
diff --git a/examples/made-of-motion/src/flight.rs b/examples/made-of-motion/src/flight.rs
new file mode 100644
index 00000000..f9128ab6
--- /dev/null
+++ b/examples/made-of-motion/src/flight.rs
@@ -0,0 +1,75 @@
+//! Reference-derived letter flights.
+use fframes::{Frame, animation::Easing};
+
+use crate::ink_capture;
+
+#[derive(Debug, Clone, Copy)]
+pub(super) struct Letter {
+ pub position: [f32; 2],
+ pub angle: f32,
+ pub scale: f32,
+}
+
+#[derive(Debug)]
+pub(super) struct Flight {
+ pub letters: Vec<[Letter; 7]>,
+}
+
+impl Flight {
+ pub(super) fn new() -> Self {
+ // Three frames to assemble, four to pull the camera back. This is
+ // a cut-speed move, not a UI-like 700 ms ease-in/out.
+ let gather = fframes::timeline!(
+ at 2.541_667 => 2.666_667, animate 0.0_f32 => 1.0, Easing::EaseIn,
+ );
+ let target = [-229., -181., -124., -47.5, 66., 167.5, 226.];
+ let mut letters = Vec::with_capacity(76);
+ let path = |index: f32, i: usize| {
+ // Replay the measured high-energy flight in independent phases.
+ // The three extra brand letters use reflected versions of those
+ // trajectories, rather than orbiting seven fixed anchor points.
+ let phase = (index * (0.80 + i as f32 * 0.025) + i as f32 * 3.1).rem_euclid(52.);
+ let phase = if phase <= 26. { phase } else { 52. - phase };
+ let sample = 3. + phase;
+ let a = sample.floor() as usize;
+ let b = (a + 1).min(ink_capture::LETTERS.len() - 1);
+ let f = sample.fract();
+ let aa = ink_capture::LETTERS[a][i % 4];
+ let bb = ink_capture::LETTERS[b][i % 4];
+ let mut x = aa[0] + (bb[0] - aa[0]) * f;
+ let mut y = aa[1] + (bb[1] - aa[1]) * f;
+ if i >= 4 {
+ x = 1440. - x;
+ y = 1080. - y;
+ }
+ // Softly fit the few off-canvas source excursions into this edit.
+ [
+ 60. + x.clamp(0., 1440.) * (1320. / 1440.),
+ 85. + y.clamp(0., 1080.) * (910. / 1080.),
+ ]
+ };
+ let mut angles = [0.0_f32; 7];
+ for index in 0..76 {
+ let frame = Frame::new(index, index + 413, 24);
+ let g = frame.animate(&gather);
+ let poses = std::array::from_fn(|i| {
+ let [x, y] = path(index as f32, i);
+ let [px, py] = path(index as f32 - 0.5, i);
+ let speed = ((x - px).powi(2) + (y - py).powi(2)).sqrt() * 2.;
+ let direction = if i % 2 == 0 { 1. } else { -1. };
+ angles[i] += direction * (speed * 0.34 + 3.1);
+ let margin = 52. + 270. * 4. * g * (1. - g);
+ Letter {
+ position: [
+ (x * (1. - g) + (720. + target[i] * 2.8) * g).clamp(margin, 1440. - margin),
+ y * (1. - g) + (540. + 39. * 2.8) * g,
+ ],
+ angle: angles[i] * (1. - g),
+ scale: (1.05 + (speed / 170.).min(0.65)) * (1. - g) + (194. / 54. * 2.8) * g,
+ }
+ });
+ letters.push(poses);
+ }
+ Self { letters }
+ }
+}
diff --git a/examples/made-of-motion/src/hero.rs b/examples/made-of-motion/src/hero.rs
new file mode 100644
index 00000000..5f6ac838
--- /dev/null
+++ b/examples/made-of-motion/src/hero.rs
@@ -0,0 +1,202 @@
+//! Cached hero poses share the ring trajectories; measured vector ink supplies the gestures.
+use fframes::{FFramesContext, Frame, Svgr, Transform, animation::Easing};
+
+use crate::{Studio, label, objects, restoration_capture};
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub(super) enum Card {
+ Code,
+ Motion,
+ Feeling,
+}
+
+#[derive(Debug)]
+struct Exposure {
+ object: objects::Object,
+ title_opacity: f32,
+}
+
+#[derive(Debug)]
+pub(super) struct Heroes {
+ code: Vec<Exposure>,
+ feeling: Vec<Exposure>,
+ motion: Vec<Exposure>,
+}
+
+impl Heroes {
+ pub(super) fn new(objects: &mut [Vec<objects::Object>]) -> Self {
+ let arrival = fframes::timeline!(
+ at 0.0 => 0.208_333, animate 0.0_f32 => 1.0, Easing::CubicBezier(0.12,0.9,0.22,1.),
+ );
+ let push = fframes::timeline!(
+ at 0.208_333 => 0.583_333, animate 0.0_f32 => 0.25, Easing::Linear,
+ at 0.583_333 => 0.875, animate 0.25_f32 => 1.0, Easing::EaseIn,
+ );
+ let yaw = fframes::timeline!(
+ at 0.0 => 0.166_667, animate -0.85_f32 => -0.28, Easing::CubicBezier(0.16,1.,0.3,1.),
+ at 0.166_667 => 0.833_333, animate -0.28_f32 => 0.40, Easing::EaseInOut,
+ );
+ let spin = fframes::timeline!(
+ at 0.0 => 0.875, animate -0.38_f32 => 2.95, Easing::Linear,
+ );
+ let build = |feeling| {
+ (0..if feeling { 21 } else { 20 })
+ .map(|index| {
+ let frame = Frame::new(index, index, 24);
+ let entry = frame.animate(&arrival);
+ let push = frame.animate(&push);
+ let yaw = frame.animate(&yaw);
+ let object = objects::Object::new(
+ if feeling { 4 } else { 0 },
+ [
+ 442. - 720. - (1. - entry) * 74.,
+ -9. + (1. - entry) * 68.,
+ 1250. - push * 70.,
+ ],
+ (if feeling { 555. } else { 530. }) * (0.82 + entry * 0.18),
+ [
+ if feeling { yaw * 0.6 } else { yaw },
+ 0.16 - push * 0.20,
+ if feeling {
+ frame.animate(&spin)
+ } else {
+ -0.15 + entry * 0.05 + push * 0.13
+ },
+ ],
+ 0.,
+ );
+ Exposure {
+ object,
+ title_opacity: 1.,
+ }
+ })
+ .collect()
+ };
+ let mut heroes = Self {
+ code: build(false),
+ feeling: build(true),
+ motion: motion_exposures(),
+ };
+ for ((exposures, keep_spinning), schedule) in [
+ (&mut heroes.code, false),
+ (&mut heroes.motion, false),
+ (&mut heroes.feeling, true),
+ ]
+ .into_iter()
+ .zip(objects::EXCURSIONS)
+ {
+ let mut poses = exposures
+ .iter()
+ .map(|exposure| exposure.object.clone())
+ .collect::<Vec<_>>();
+ objects::ring_excursion(objects, &mut poses, schedule, keep_spinning);
+ let arrival = (schedule.arrival - schedule.start) as f32 / 24.;
+ let exit = (schedule.return_start - schedule.start) as f32 / 24.;
+ let caption = fframes::timeline!(
+ at (arrival - 2. / 24.) => arrival, animate 0.0_f32 => 1.0, Easing::EaseOut,
+ at exit => (exit + 3. / 24.), animate 1.0_f32 => 0.0, Easing::EaseInOut,
+ );
+ for (index, (exposure, object)) in exposures.iter_mut().zip(poses).enumerate() {
+ exposure.object = object;
+ exposure.title_opacity =
+ Frame::new(index, schedule.start + index, 24).animate(&caption);
+ }
+ }
+ heroes
+ }
+
+ pub(super) fn draw(
+ &self,
+ frame: &Frame,
+ ctx: &FFramesContext<'_, '_>,
+ s: &Studio,
+ card: Card,
+ ) -> Svgr<'static> {
+ let exposures = match card {
+ Card::Code => &self.code,
+ Card::Motion => &self.motion,
+ Card::Feeling => &self.feeling,
+ };
+ let pose = &exposures[frame.index.min(exposures.len() - 1)];
+ fframes::svgr!(<g>
+ {s.background(frame,1.,0.)}
+ {s.ink.draw(frame, ctx)}
+ // The other eleven tracks keep rotating off-screen. This is the
+ // selected track's same global pose, including both flights.
+ {pose.object.draw(frame,ctx,&s.object)}
+ <g opacity={pose.title_opacity}>{type_block(frame,card)}</g>
+ </g>)
+ }
+}
+
+fn type_block(frame: &Frame, card: Card) -> Svgr<'static> {
+ let (copy, cursor) = match card {
+ Card::Code => ("code.", 1120.),
+ Card::Motion => ("motion.", 1256.),
+ Card::Feeling => ("feeling.", 1246.),
+ };
+ fframes::svgr!(<g>
+ <g transform={frame.animate(fframes::timeline!(
+ at 0.0 => 0.166_667, animate Transform::translate(48,18) => Transform::translate(0,0), Easing::CubicBezier(0.12,1.,0.25,1.),
+ ))}>
+ {label(copy,800.,559.,112.,"#f4efe4",false)}
+ <rect x={cursor} y="477" height="86" fill="#ed3d27"
+ width={frame.animate(fframes::timeline!(at 0.0 => 0.125, animate 76.0_f32 => 6.0, Easing::EaseOut))}/>
+ </g>
+ <g transform={frame.animate(fframes::timeline!(
+ at 0.041_667 => 0.25, animate Transform::translate(0,24) => Transform::translate(0,0), Easing::CubicBezier(0.16,1.,0.3,1.),
+ ))} opacity={frame.animate(fframes::timeline!(at 0.041_667 => 0.166_667, animate 0.0_f32 => 1.0, Easing::EaseOut))}>
+ {match card {
+ Card::Feeling => fframes::svgr!(<g>
+ <text x="807" y="617" font-family="Instrument Serif" font-style="italic" font-size="35" fill="#d4cabb">"every frame matters."</text>
+ <path d="M811 653 C905 641 970 662 1045 647" fill="none" stroke="#ed3d27" stroke-width="2"/>
+ </g>),
+ Card::Code => fframes::svgr!(<text x="807" y="611" font-family="JetBrains Mono" font-size="23" fill="#bce788">"Rust + SVG"</text>),
+ Card::Motion => fframes::svgr!(<text x="807" y="611" font-family="JetBrains Mono" font-size="23" fill="#c0a1ef">"timeline!"</text>),
+ }}
+ </g>
+ </g>)
+}
+
+fn motion_exposures() -> Vec<Exposure> {
+ let arrive = fframes::timeline!(
+ at 0.0 => 0.166_667, animate 0.0_f32 => 1.0, Easing::CubicBezier(0.12,0.9,0.22,1.),
+ );
+ // Keep the measured silhouettes, but interpolate between them instead of
+ // holding each exposure and jumping to the next. Start after the shared
+ // ring arrival (local frame 5); the return then restores the normal aspect.
+ let normal = restoration_capture::CAMERA_POSE[5];
+ let tall = restoration_capture::CAMERA_POSE[12];
+ let flat = restoration_capture::CAMERA_POSE[17];
+ let deformation = std::array::from_fn::<_, 3, _>(|axis| {
+ fframes::timeline!(
+ at (5.0 / 24.0) => (10.0 / 24.0), animate normal[axis] => tall[axis], Easing::CubicBezier(0.42,0.,0.58,1.),
+ at (10.0 / 24.0) => (15.0 / 24.0), animate tall[axis] => flat[axis], Easing::CubicBezier(0.42,0.,0.58,1.),
+ )
+ });
+ (0..16)
+ .map(|index| {
+ let frame = Frame::new(index, index, 24);
+ let entry = frame.animate(&arrive);
+ let [sx, sy, roll] = deformation.each_ref().map(|curve| frame.animate(curve));
+ let stretch = [sx, sy];
+ let wide = ((stretch[0] - 1.) / 1.2).clamp(0., 1.);
+ let object = objects::Object::new(
+ 5,
+ [
+ -296. + wide * 25. - (1. - entry) * 60.,
+ -8. + (1. - entry) * 74.,
+ 1250.,
+ ],
+ 470. * (0.83 + entry * 0.17),
+ [0.10, 0.035, roll],
+ 0.,
+ )
+ .with_stretch(stretch);
+ Exposure {
+ object,
+ title_opacity: 1.,
+ }
+ })
+ .collect()
+}
diff --git a/examples/made-of-motion/src/ink.rs b/examples/made-of-motion/src/ink.rs
new file mode 100644
index 00000000..e12edddc
--- /dev/null
+++ b/examples/made-of-motion/src/ink.rs
@@ -0,0 +1,77 @@
+//! Frame-exact vector ink plus procedural collision illumination.
+use crate::{objects::Impact, vector_ink::VectorInk};
+use fframes::{FFramesContext, Frame, Shader, ShaderUniforms, Svgr, Transform, animation::Easing};
+
+pub(super) fn dust(frame: &Frame, light: bool) -> Svgr<'static> {
+ let t = frame.global_index as f32 / 24.;
+ let fill = if light { "#ded7c9" } else { "#2c2825" };
+ let particles = (0..10)
+ .map(|i| {
+ let p = i as f32;
+ let x = 135. + (p * 431. + t * (11. + p)).rem_euclid(1170.);
+ let y = 110. + (p * 197. - t * (5. + p * 2.)).rem_euclid(860.);
+ let r = if i % 3 == 0 { 1.7 } else { 0.8 };
+ fframes::svgr!(<circle cx={x} cy={y} r={r} fill={fill} opacity="0.32" />)
+ })
+ .collect::<Vec<_>>();
+ fframes::svgr!(<g>{particles}</g>)
+}
+
+#[derive(Debug)]
+pub(super) struct Ink {
+ impact_shader: Shader,
+ impacts: Vec<Impact>,
+ vectors: VectorInk,
+}
+
+impl Ink {
+ pub(super) fn new(impacts: &[Impact]) -> Self {
+ Self {
+ impact_shader: Shader::sksl(include_str!("shaders/impact.sksl")),
+ impacts: impacts.to_vec(),
+ vectors: VectorInk::new(),
+ }
+ }
+
+ pub(super) fn impacts(&self, frame: &Frame) -> Svgr<'static> {
+ let bursts=self.impacts.iter().filter_map(|hit| {
+ let age=frame.global_index as f32-hit.at as f32;
+ if !(0.0..7.0).contains(&age) { return None; }
+ let layer=self.impact_shader.draw(frame,ShaderUniforms::new()
+ .float("uAge",age).float("uSeed",hit.at as f32)
+ .float2("uDirection",hit.direction[0],hit.direction[1]));
+ let [x,y]=hit.position;
+ Some(fframes::svgr!(<image href={layer.href()} x={x-170.} y={y-170.} width="340" height="340"/>))
+ }).collect::<Vec<_>>();
+ fframes::svgr!(<g>{bursts}</g>)
+ }
+
+ pub(super) fn draw(&self, frame: &Frame, _ctx: &FFramesContext<'_, '_>) -> Svgr<'static> {
+ self.vectors.draw(frame)
+ }
+
+ /// Retarget the reference's "you're" loop to "code" in the opening copy.
+ /// The fixed font places their word centres at x=793 and x=900 respectively;
+ /// code is 7/8 as wide. Ease into that mapping before the loop closes, then
+ /// release it with the original pen's exit. Ink inspection keeps source positions.
+ pub(super) fn draw_question(&self, frame: &Frame) -> Svgr<'static> {
+ fframes::svgr!(<g transform={frame.animate(fframes::timeline!(
+ at 1.125 => 1.291_667,
+ animate Transform::default() => Transform { translate_x: 206.125, translate_y: -3., scale: (0.875, 1.).into(), ..Default::default() },
+ Easing::EaseInOut,
+ at 1.458_333 => 1.541_667,
+ animate Transform { translate_x: 206.125, translate_y: -3., scale: (0.875, 1.).into(), ..Default::default() } => Transform::default(),
+ Easing::EaseIn,
+ ))}>
+ {self.vectors.draw(frame)}
+ </g>)
+ }
+
+ pub(super) fn draw_signature(
+ &self,
+ frame: &Frame,
+ letters: &[crate::flight::Letter; 7],
+ ) -> Svgr<'static> {
+ self.vectors.draw_signature(frame, letters)
+ }
+}
diff --git a/examples/made-of-motion/src/ink_capture.rs b/examples/made-of-motion/src/ink_capture.rs
new file mode 100644
index 00000000..4f63610e
--- /dev/null
+++ b/examples/made-of-motion/src/ink_capture.rs
@@ -0,0 +1,77 @@
+//! Final measured source-frame exposures, without interpolation.
+#[rustfmt::skip]
+pub(super) const LETTERS: &[[[f32; 2]; 4]] = &[
+ [[130.00, 740.00], [754.00, 968.00], [1288.00, 80.00], [650.00, 774.00]],
+ [[130.00, 740.00], [754.00, 968.00], [1288.00, 80.00], [650.00, 774.00]],
+ [[130.00, 740.00], [754.00, 968.00], [1288.00, 80.00], [650.00, 774.00]],
+ [[130.00, 740.00], [754.00, 968.00], [1288.00, 80.00], [650.00, 774.00]],
+ [[224.00, 1000.00], [934.00, 822.00], [1148.00, 134.00], [514.00, 486.00]],
+ [[328.00, 904.00], [1078.00, 700.00], [1018.00, 280.00], [400.00, 264.00]],
+ [[429.45, 746.18], [1184.92, 618.31], [919.29, 412.18], [309.08, 80.39]],
+ [[509.97, 615.56], [1293.66, 530.83], [809.00, 507.79], [338.93, 75.28]],
+ [[593.53, 488.28], [1373.15, 459.83], [744.68, 566.58], [453.74, 178.13]],
+ [[659.62, 372.53], [1429.69, 405.23], [692.23, 624.51], [541.91, 263.50]],
+ [[718.17, 277.24], [1371.45, 384.61], [649.05, 677.80], [621.58, 339.67]],
+ [[770.00, 196.00], [1306.00, 370.00], [612.00, 728.00], [686.00, 406.00]],
+ [[817.44, 113.32], [1243.53, 355.79], [576.69, 764.84], [747.20, 464.42]],
+ [[859.46, 42.26], [1191.41, 345.36], [544.65, 794.88], [799.59, 516.32]],
+ [[873.38, 11.89], [1144.83, 334.21], [519.01, 818.68], [845.63, 559.40]],
+ [[812.04, 31.35], [1106.62, 325.53], [496.89, 838.94], [887.00, 596.67]],
+ [[758.48, 54.00], [1068.29, 313.71], [480.21, 852.13], [923.05, 630.99]],
+ [[710.76, 77.51], [1035.57, 309.22], [468.71, 862.04], [955.12, 661.79]],
+ [[668.01, 98.61], [1007.05, 302.67], [456.91, 871.28], [985.31, 689.66]],
+ [[627.01, 117.27], [982.43, 297.73], [451.44, 877.44], [1011.79, 714.28]],
+ [[592.70, 134.08], [959.30, 292.40], [446.16, 883.76], [1034.50, 735.81]],
+ [[559.77, 150.62], [940.62, 287.47], [443.94, 888.65], [1055.60, 756.76]],
+ [[530.48, 165.51], [922.74, 284.97], [442.63, 892.63], [1073.74, 773.76]],
+ [[504.04, 178.28], [907.51, 282.35], [439.61, 895.78], [1090.01, 789.55]],
+ [[480.19, 187.98], [892.58, 279.90], [440.60, 899.67], [1104.22, 802.89]],
+ [[458.16, 197.76], [880.77, 276.86], [439.81, 901.74], [1116.71, 816.52]],
+ [[439.53, 207.22], [869.80, 273.49], [439.46, 904.21], [1127.37, 828.12]],
+ [[423.42, 214.29], [860.85, 272.01], [439.35, 905.78], [1137.21, 835.72]],
+ [[407.23, 220.04], [852.68, 268.54], [440.16, 907.22], [1144.59, 845.01]],
+ [[393.20, 226.41], [845.10, 266.97], [440.70, 906.71], [1151.59, 851.02]],
+ [[382.89, 231.23], [837.41, 267.09], [440.33, 909.89], [1157.04, 856.87]],
+ [[372.23, 234.97], [833.09, 264.74], [440.12, 910.12], [1162.81, 863.84]],
+ [[363.28, 240.36], [829.05, 263.00], [440.95, 909.77], [1166.56, 868.34]],
+ [[356.77, 243.77], [824.93, 262.97], [440.87, 908.60], [1169.86, 871.18]],
+ [[349.81, 245.41], [822.31, 262.50], [440.66, 909.38], [1174.61, 874.59]],
+ [[344.68, 247.89], [818.95, 261.26], [439.78, 908.14], [1175.00, 877.47]],
+ [[340.82, 249.82], [816.69, 261.41], [440.76, 908.11], [1177.25, 879.99]],
+ [[336.89, 251.46], [814.68, 260.53], [438.87, 906.56], [1179.13, 881.49]],
+ [[334.54, 253.49], [811.75, 260.98], [440.52, 905.56], [1180.36, 883.16]],
+ [[331.45, 254.49], [810.87, 260.94], [437.82, 905.47], [1182.60, 884.05]],
+ [[330.61, 254.28], [811.17, 260.69], [439.92, 904.87], [1181.64, 884.10]],
+ [[329.16, 254.18], [810.76, 259.54], [441.53, 903.54], [1183.27, 884.60]],
+ [[328.95, 253.83], [809.15, 260.79], [442.03, 903.41], [1184.48, 885.19]],
+ [[329.25, 254.03], [809.02, 259.95], [440.68, 903.81], [1184.15, 885.71]],
+ [[329.00, 254.28], [809.06, 258.17], [441.82, 902.44], [1185.74, 886.76]],
+ [[329.13, 256.40], [808.72, 257.76], [442.29, 899.06], [1186.05, 885.39]],
+ [[330.81, 255.88], [808.30, 261.47], [442.00, 897.51], [1185.05, 885.85]],
+ [[331.82, 257.81], [809.20, 262.70], [442.43, 898.62], [1183.65, 884.35]],
+ [[332.37, 258.81], [807.10, 262.86], [443.47, 897.58], [1180.83, 883.39]],
+ [[333.55, 258.39], [806.12, 265.12], [442.46, 893.88], [1179.53, 882.72]],
+ [[335.74, 259.33], [806.53, 264.81], [442.97, 894.47], [1177.30, 879.79]],
+ [[336.34, 259.32], [806.90, 265.07], [443.33, 889.32], [1175.81, 879.08]],
+ [[337.88, 259.13], [806.17, 265.47], [444.03, 888.09], [1175.53, 876.48]],
+ [[338.59, 261.64], [805.26, 265.99], [444.52, 886.66], [1174.06, 872.34]],
+ [[341.92, 262.94], [803.04, 267.81], [446.10, 884.88], [1172.79, 873.62]],
+ [[344.44, 263.05], [803.03, 269.48], [446.90, 881.77], [1169.93, 874.26]],
+ [[345.89, 266.25], [803.81, 270.90], [447.04, 877.62], [1167.14, 872.38]],
+ [[346.12, 266.30], [803.47, 272.53], [448.84, 877.24], [1164.96, 869.58]],
+ [[348.05, 269.28], [800.82, 274.04], [452.08, 873.41], [1164.10, 868.81]],
+ [[351.59, 271.11], [800.24, 275.89], [452.32, 869.52], [1159.42, 864.98]],
+ [[353.65, 271.61], [800.87, 278.60], [452.91, 865.47], [1156.48, 861.96]],
+ [[357.79, 274.07], [800.03, 279.10], [457.84, 860.02], [1154.78, 860.38]],
+ [[362.74, 275.26], [798.04, 282.17], [460.57, 854.20], [1146.78, 853.78]],
+ [[366.68, 278.05], [798.23, 283.37], [463.56, 848.33], [1143.48, 850.52]],
+ [[370.68, 280.15], [797.17, 286.86], [467.83, 841.52], [1138.65, 845.01]],
+ [[376.82, 284.47], [794.61, 291.29], [472.18, 831.08], [1131.56, 838.18]],
+ [[384.41, 288.16], [792.32, 297.75], [477.12, 825.39], [1123.87, 832.88]],
+ [[392.98, 293.83], [789.24, 301.97], [480.37, 815.44], [1114.73, 825.28]],
+ [[403.41, 301.66], [785.48, 308.67], [486.74, 801.92], [1101.92, 813.22]],
+ [[417.38, 310.45], [781.31, 319.70], [495.70, 783.31], [1087.52, 802.00]],
+ [[435.76, 322.59], [776.65, 331.19], [504.63, 764.22], [1067.35, 783.38]],
+ [[460.11, 336.21], [769.68, 348.70], [518.77, 736.35], [1039.65, 762.62]],
+ [[495.58, 358.93], [758.72, 372.32], [536.93, 698.36], [997.94, 726.63]],
+];
diff --git a/examples/made-of-motion/src/lib.rs b/examples/made-of-motion/src/lib.rs
new file mode 100644
index 00000000..fc22610d
--- /dev/null
+++ b/examples/made-of-motion/src/lib.rs
@@ -0,0 +1,440 @@
+//! A 489-frame analog / pixel collage film for fframes. Authored at 24 fps for
+//! native preview; the documented `FFmpeg` export restores the source's 24000/1001
+//! timestamps and copies its AAC packets without remixing or re-encoding them.
+mod flight;
+mod hero;
+mod ink;
+mod ink_capture;
+mod objects;
+mod opening;
+mod opening_capture;
+mod restoration_capture;
+mod vector_ink;
+
+use std::sync::Arc;
+
+use fframes::{
+ AudioMap, AudioTimestamp, AudioTrack, Color, Duration, FFramesContext, FFramesSyncedVideoFrame,
+ Frame, Scene, Scenes, Shader, ShaderUniforms, Svgr, SyncVideoFrameInput, Transform, Video,
+ animation::Easing, include_media_dir,
+};
+
+include_media_dir!(pub struct MotionMedia, "examples/made-of-motion/media");
+
+const QUESTION: &str = "how do you turn a few lines of code into a feeling?";
+
+#[derive(Clone, Copy, Debug)]
+enum Kind {
+ Question,
+ Signal,
+ Portrait,
+ Thermal,
+ Ring,
+ Code,
+ Carousel,
+ Motion,
+ Feeling,
+ Scatter,
+ Hand,
+ Pulse(usize),
+ Signature,
+}
+
+// Source frame boundaries, end exclusive. Keep these aligned to the music edit.
+const EDIT: [(&str, usize, Kind); 18] = [
+ ("Question", 48, Kind::Question),
+ ("Signal", 93, Kind::Signal),
+ ("Portrait", 153, Kind::Portrait),
+ ("ThermalCut", 157, Kind::Thermal),
+ ("Orbit", 200, Kind::Ring),
+ ("Code", 220, Kind::Code),
+ ("CarouselA", 237, Kind::Carousel),
+ ("Motion", 253, Kind::Motion),
+ ("CarouselB", 265, Kind::Carousel),
+ ("Feeling", 286, Kind::Feeling),
+ ("OrbitReturn", 302, Kind::Ring),
+ ("Scatter", 331, Kind::Scatter),
+ ("Human", 382, Kind::Hand),
+ ("M", 389, Kind::Pulse(0)),
+ ("O", 397, Kind::Pulse(1)),
+ ("V", 403, Kind::Pulse(2)),
+ ("E", 413, Kind::Pulse(3)),
+ ("Fframes", 489, Kind::Signature),
+];
+
+#[derive(Debug)]
+struct Studio {
+ paper: Shader,
+ signal: Shader,
+ ink: ink::Ink,
+ print: Shader,
+ object: Shader,
+ performance: Shader,
+ hand: Shader,
+ thermal_cut: Shader,
+ objects: Vec<Vec<objects::Object>>,
+ flight: flight::Flight,
+ heroes: hero::Heroes,
+}
+
+impl Studio {
+ fn background(&self, frame: &Frame, mode: f32, vignette: f32) -> Svgr<'static> {
+ let layer = self.paper.draw(
+ frame,
+ ShaderUniforms::new()
+ .float("uMode", mode)
+ .float("uVignette", vignette),
+ );
+ fframes::svgr!(<image href={layer.href()} width="1440" height="1080" />)
+ }
+
+ fn signal(&self, frame: &Frame) -> Svgr<'static> {
+ let pose = match frame.index {
+ 0 => [1240., 540., 170., 670., 0., 0.42],
+ 1 => [550., 540., 680., 660., 0.17, 0.42],
+ 2 => [350., 540., 740., 950., -0.68, 0.38],
+ n => opening_capture::STAR[(n - 3).min(37)],
+ };
+ let layer = self.signal.draw(
+ frame,
+ ShaderUniforms::new()
+ .float4("uPose", pose[0], pose[1], pose[2], pose[3])
+ .float("uAngle", pose[4])
+ .float("uPower", pose[5]),
+ );
+ fframes::svgr!(<image href={layer.href()} width="1440" height="1080" />)
+ }
+
+ fn print(&self, frame: &Frame, strength: f32) -> Svgr<'static> {
+ let layer = self
+ .print
+ .draw(frame, ShaderUniforms::new().float("uStrength", strength));
+ fframes::svgr!(<image href={layer.href()} width="1440" height="1080" />)
+ }
+
+ fn objects(&self, frame: &Frame, ctx: &FFramesContext<'_, '_>) -> Svgr<'static> {
+ let group = self.objects[frame.global_index.min(488)]
+ .iter()
+ .map(|o| o.draw(frame, ctx, &self.object))
+ .collect::<Vec<_>>();
+ fframes::svgr!(<g>{group}</g>)
+ }
+
+ fn performance(
+ &self,
+ frame: &Frame,
+ ctx: &FFramesContext<'_, '_>,
+ file: &str,
+ ) -> Svgr<'static> {
+ let Some(video) = frame.get_synced_video_frame(ctx, file, &SyncVideoFrameInput::default())
+ else {
+ return self.background(frame, 1., 0.);
+ };
+ let source = video.into_image();
+ let layer = self
+ .performance
+ .draw(frame, ShaderUniforms::new().image("uSource", &source));
+ fframes::svgr!(<image href={layer.href()} width="1440" height="1080" />)
+ }
+
+ fn hand(&self, frame: &Frame, ctx: &FFramesContext<'_, '_>) -> Svgr<'static> {
+ let Some(field) = ctx.get_image("hand-field.png") else {
+ return self.background(frame, 1., 0.);
+ };
+ let [ax, ay, x, y, w, h] = restoration_capture::HAND[frame.index.min(50)];
+ let layer = self.hand.draw(
+ frame,
+ ShaderUniforms::new()
+ .image("uField", field)
+ .float2("uAtlas", ax, ay)
+ .float4("uRect", x, y, w, h),
+ );
+ fframes::svgr!(<image href={layer.href()} width="1440" height="1080" />)
+ }
+
+ fn thermal_cut(&self, frame: &Frame, ctx: &FFramesContext<'_, '_>) -> Svgr<'static> {
+ let layer = self.thermal_cut.draw(frame, ShaderUniforms::new());
+ fframes::svgr!(<g>
+ <image href={layer.href()} width="1440" height="1080" />
+ <g opacity={frame.animate(fframes::timeline!(
+ at 0.0 => 0.125, animate 0.0_f32 => 0.94, Easing::EaseOut,
+ ))}>{self.objects(frame,ctx)}</g>
+ </g>)
+ }
+}
+
+#[derive(Debug)]
+struct Shot {
+ name: &'static str,
+ length: usize,
+ kind: Kind,
+ studio: Arc<Studio>,
+}
+
+impl Scene for Shot {
+ fn name(&self) -> &'static str {
+ self.name
+ }
+ fn duration(&self) -> Duration<'_> {
+ Duration::Frames(self.length)
+ }
+
+ fn render_frame<'a>(&'a self, mut frame: Frame, ctx: &FFramesContext<'a, '_>) -> Svgr<'a> {
+ let s = &self.studio;
+ let content = match self.kind {
+ Kind::Question => {
+ fframes::svgr!(<g>{s.background(&frame,0.,0.)}
+ {if frame.index==0 {Svgr::empty()} else {opening::draw(&mut frame,ctx)}}
+ {s.ink.draw_question(&frame)}</g>)
+ }
+ Kind::Signal => {
+ let pulse = frame.index == 0;
+ let color = if pulse { "#f4eee0" } else { "#161616" };
+ fframes::svgr!(<g>
+ {s.signal(&frame)}
+ <g opacity={frame.animate(fframes::timeline!(at 1.25 => 1.375, animate 1.0_f32 => 0.0, Easing::EaseIn))}>
+ {s.objects(&frame,ctx)}
+ </g>
+ {s.ink.draw(&frame, ctx)}
+ <text x="720" y="554" font-family="Inter 24pt" font-weight="700" font-size="54"
+ letter-spacing="-1.25" fill={color} text-anchor="middle">
+ "how do "<tspan fill={if frame.index>=39 {"#fff4df"} else {color}}>"you"</tspan>
+ " turn a few lines of code into a feeling?"
+ </text>
+ </g>)
+ }
+ Kind::Portrait => {
+ let copy = match frame.index {
+ 0..=34 => "you don’t.",
+ 35..=38 => "you give",
+ 39..=42 => "you give it",
+ _ => "you give it fframes.",
+ };
+ let color = if frame.index >= 51 {
+ "#181714"
+ } else {
+ "#f3eee1"
+ };
+ fframes::svgr!(<g>{s.performance(&frame,ctx,"portrait-clean.mp4")}
+ {s.ink.draw(&frame, ctx)}
+ {label(copy,208.,554.,46.,color,false)}
+ </g>)
+ }
+ Kind::Thermal => s.thermal_cut(&frame, ctx),
+ Kind::Ring | Kind::Carousel | Kind::Scatter => {
+ let scatter = matches!(self.kind, Kind::Scatter);
+ fframes::svgr!(<g>
+ {s.background(&frame,0.,0.08)}
+ {s.objects(&frame,ctx)}
+ {s.ink.impacts(&frame)}
+ {s.ink.draw(&frame, ctx)}
+ {if scatter && frame.index>23 { label("from your mind",720.,552.,32.,"#1d1916",true) } else { Svgr::empty() }}
+ </g>)
+ }
+ Kind::Code => s.heroes.draw(&frame, ctx, s, hero::Card::Code),
+ Kind::Feeling => s.heroes.draw(&frame, ctx, s, hero::Card::Feeling),
+ Kind::Motion => s.heroes.draw(&frame, ctx, s, hero::Card::Motion),
+ Kind::Hand => {
+ let performance = if frame.index == 0 {
+ let stack = (0..12)
+ .map(|i| {
+ let x = 720. + (i as f32 * 0.55).cos() * 130.;
+ objects::hero(i, x, 150. + i as f32 * 65., 170., i as f32 * 0.13)
+ .draw(&frame, ctx, &s.object)
+ })
+ .collect::<Vec<_>>();
+ fframes::svgr!(<g>{s.background(&frame,1.,0.)}
+ <ellipse cx="720" cy="535" rx="76" ry="184" fill="url(#stack-light)"/>{stack}
+ </g>)
+ } else {
+ s.hand(&frame, ctx)
+ };
+ let copy = match frame.index {
+ 0..=2 => "from",
+ 3..=5 => "from your",
+ _ => "from your mind",
+ };
+ fframes::svgr!(<g>{performance}{s.ink.draw(&frame,ctx)}
+ {label(copy,208.,554.,42.,"#f1ecdf",false)}
+ <g opacity={frame.animate(fframes::timeline!(at 0.416_667 => 0.625, animate 0.0_f32 => 1.0, Easing::EaseOut))}>
+ {label("to every frame.",1050.,554.,42.,"#f1ecdf",false)}
+ </g>
+ </g>)
+ }
+ Kind::Pulse(index) => pulse(&frame, ctx, s, index),
+ Kind::Signature => signature(&frame, s),
+ };
+ let live = matches!(self.kind, Kind::Portrait | Kind::Thermal | Kind::Hand)
+ || (matches!(self.kind, Kind::Question) && frame.index == 0);
+ let light = matches!(self.kind, Kind::Code | Kind::Motion | Kind::Feeling);
+ fframes::svgr!(<g>
+ {content}
+ {if live { Svgr::empty() } else { ink::dust(&frame,light) }}
+ {if live { Svgr::empty() } else { s.print(&frame,0.045) }}
+ </g>)
+ }
+}
+
+fn label(copy: &str, x: f32, y: f32, size: f32, color: &str, center: bool) -> Svgr<'static> {
+ let anchor = if center { "middle" } else { "start" };
+ fframes::svgr!(<text x={x} y={y} font-family="Inter 24pt" font-weight="700" font-size={size}
+ letter-spacing="-1.25" fill={color.to_owned()} text-anchor={anchor}>{copy.to_owned()}</text>)
+}
+
+fn pulse(frame: &Frame, ctx: &FFramesContext<'_, '_>, s: &Studio, index: usize) -> Svgr<'static> {
+ let mode = match index {
+ 1 => 1.,
+ 3 if frame.index < 3 => 1.,
+ 2 => 2.,
+ _ => 0.,
+ };
+ let color = if index == 0 { "#27221c" } else { "#ede9df" };
+ let icons = [3, 0, 7, 4];
+ let object = objects::hero(
+ icons[index],
+ 720.,
+ 540.,
+ 370.,
+ frame.global_index as f32 * 0.13,
+ )
+ .draw(frame, ctx, &s.object);
+ let letters = ["M", "O", "V", "E"]
+ .iter()
+ .enumerate()
+ .take(index + 1)
+ .map(|(i, ch)| label(ch, 250. + i as f32 * 312., 552., 32., color, true))
+ .collect::<Vec<_>>();
+ fframes::svgr!(<g>{s.background(frame,mode,if index==3 {1.35} else {0.5})}{object}{letters}</g>)
+}
+
+fn signature(frame: &Frame, s: &Studio) -> Svgr<'static> {
+ let poses = s.flight.letters[frame.index.min(75)];
+ let letters = ["f", "f", "r", "a", "m", "e", "s"];
+ let orbit=letters.into_iter().zip(poses).map(|(ch,pose)| {
+ let [x,y]=pose.position;
+ let angle=pose.angle;
+ let scale=pose.scale;
+ fframes::svgr!(<g transform={format!("translate({x} {y}) rotate({angle}) scale({scale})")}>
+ <text x="0" y="0" text-anchor="middle" font-family="Instrument Serif" font-style="italic"
+ font-size="54" fill="#35221b" stroke="#35221b" stroke-width="0.35">{ch}</text>
+ </g>)
+ }).collect::<Vec<_>>();
+ fframes::svgr!(<g>
+ {s.background(frame,0.,0.025)}
+ {s.ink.draw_signature(frame, &poses)}
+ <g opacity={frame.animate(fframes::timeline!(at 2.625 => 2.666_667, animate 1.0_f32 => 0.0, Easing::EaseOut))}>{orbit}</g>
+ <g opacity={frame.animate(fframes::timeline!(at 2.625 => 2.666_667, animate 0.0_f32 => 1.0, Easing::EaseOut))}>
+ <g transform="translate(720 540)">
+ <g transform={frame.animate(fframes::timeline!(
+ at 2.666_667 => 2.833_333,
+ animate Transform::scale(2.8) => Transform::scale(1.),
+ Easing::CubicBezier(0.12,0.92,0.20,1.),
+ ))}>
+ <text x="0" y="39" text-anchor="middle" font-family="Instrument Serif" font-style="italic"
+ font-size="194" letter-spacing="-5" fill="#24201b">"fframes"</text>
+ </g>
+ </g>
+ <g opacity={frame.animate(fframes::timeline!(at 2.833_333 => 3.083_333, animate 0.0_f32 => 1.0, Easing::EaseOut))}
+ transform={frame.animate(fframes::timeline!(at 2.833_333 => 3.083_333, animate Transform::translate(0,12) => Transform::translate(0,0), Easing::EaseOut))}>
+ <text x="720" y="643" text-anchor="middle" font-family="JetBrains Mono" font-size="19"
+ letter-spacing="1" fill="#4b4136">"video, written in code."</text>
+ <circle cx="720" cy="703" r="4.5" fill="#eb6c35"/>
+ </g>
+ </g>
+ </g>)
+}
+
+/// The complete source-timed film, ready for Metal/Vulkan native preview.
+#[derive(Debug)]
+pub struct MadeOfMotion {
+ shots: Vec<Shot>,
+ ink_only: bool,
+}
+
+impl MadeOfMotion {
+ pub fn new() -> Self {
+ let (mut objects, impacts) = objects::choreography();
+ let flight = flight::Flight::new();
+ let ink = ink::Ink::new(&impacts);
+ let heroes = hero::Heroes::new(&mut objects);
+ let studio = Arc::new(Studio {
+ paper: Shader::sksl(include_str!("shaders/paper.sksl")),
+ signal: Shader::sksl(include_str!("shaders/signal.sksl")),
+ ink,
+ print: Shader::sksl(include_str!("shaders/print.sksl")),
+ object: Shader::sksl(include_str!("shaders/object.sksl")),
+ performance: Shader::sksl(include_str!("shaders/performance.sksl")),
+ hand: Shader::sksl(include_str!("shaders/hand.sksl")),
+ thermal_cut: Shader::sksl(include_str!("shaders/thermal_cut.sksl")),
+ objects,
+ flight,
+ heroes,
+ });
+ let mut start = 0;
+ let shots = EDIT
+ .into_iter()
+ .map(|(name, end, kind)| {
+ let length = end - start;
+ start = end;
+ Shot {
+ name,
+ length,
+ kind,
+ studio: Arc::clone(&studio),
+ }
+ })
+ .collect();
+ Self {
+ shots,
+ ink_only: false,
+ }
+ }
+
+ /// Show the source-timed vector exposures on neutral paper for inspection.
+ pub fn with_ink_only(mut self, enabled: bool) -> Self {
+ self.ink_only = enabled;
+ self
+ }
+}
+
+impl Default for MadeOfMotion {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+impl Video for MadeOfMotion {
+ const FPS: usize = 24;
+ const WIDTH: usize = 1440;
+ const HEIGHT: usize = 1080;
+ const BACKGROUND_COLOR: Color = Color::BLACK;
+ fn duration(&self) -> Duration<'_> {
+ Duration::Frames(489)
+ }
+ fn define_scenes(&self) -> Scenes<'_> {
+ Scenes::from(
+ self.shots
+ .iter()
+ .map(|s| s as &dyn Scene)
+ .collect::<Vec<_>>(),
+ )
+ }
+ fn audio(&self) -> AudioMap<'_> {
+ AudioMap::from([AudioTrack::new(
+ "soundtrack.wav",
+ AudioTimestamp::Second(0.)..AudioTimestamp::Eof,
+ )])
+ }
+ fn render_frame<'a>(&'a self, frame: Frame, ctx: &FFramesContext<'a, '_>) -> Svgr<'a> {
+ fframes::svgr!(<svg xmlns="http://www.w3.org/2000/svg" width="1440" height="1080" viewBox="0 0 1440 1080">
+ <defs>
+ <radialGradient id="stack-light"><stop offset="0" stop-color="#e8e8df"/>
+ <stop offset="1" stop-color="#e8e8df" stop-opacity="0"/>
+ </radialGradient></defs>
+ {if self.ink_only {
+ fframes::svgr!(<g><rect width="1440" height="1080" fill="#e4e4e4"/>
+ {self.shots[0].studio.ink.draw(&frame, ctx)}</g>)
+ } else { ctx.render_scenes(&frame) }}
+ </svg>)
+ }
+}
diff --git a/examples/made-of-motion/src/main.rs b/examples/made-of-motion/src/main.rs
new file mode 100644
index 00000000..917c5ba1
--- /dev/null
+++ b/examples/made-of-motion/src/main.rs
@@ -0,0 +1,80 @@
+use std::process::ExitCode;
+
+use fframes::cli::clap;
+use fframes::{
+ AudioMixOptions, CombinedMediaProvider, EncoderOptions, MediaDirectory, MediaProvider,
+ RenderOptions, StaticMediaProvider, Video, cli,
+};
+use fframes_skia_renderer::{SkiaFFramesRenderer, SkiaPipelineConfig};
+use made_of_motion::{MadeOfMotion, MotionMedia};
+
+#[derive(Debug, cli::clap::Args)]
+struct Args {
+ /// Inspect only the frame-by-frame SVG ink, without objects or footage.
+ #[arg(long, global = true)]
+ ink_only: bool,
+}
+
+fn run() -> Result<ExitCode, Box<dyn std::error::Error>> {
+ let args = cli::parse::<Args>();
+ let media = MotionMedia::prepare()?;
+ let folder = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("dynamic_media");
+ for file in ["portrait-clean.mp4", "soundtrack.wav"] {
+ if !folder.join(file).is_file() {
+ return Err(format!(
+ "Missing {}. Restore the final media supplied with this example; see README.md.",
+ folder.join(file).display()
+ )
+ .into());
+ }
+ }
+ let directory = MediaDirectory::read_folder(folder)?;
+ let dynamic = directory.process_media_source()?;
+ let all = CombinedMediaProvider::from([&media as &dyn MediaProvider, &dynamic]);
+ let video = MadeOfMotion::new().with_ink_only(args.app.ink_only);
+ #[cfg(target_os = "macos")]
+ let gpu =
+ fframes_skia_renderer::metal::SkiaMetalCtx::new(MadeOfMotion::WIDTH, MadeOfMotion::HEIGHT)?;
+ #[cfg(not(target_os = "macos"))]
+ let gpu = fframes_skia_renderer::vulkan::SkiaVulkanCtx::new(
+ MadeOfMotion::WIDTH,
+ MadeOfMotion::HEIGHT,
+ )?;
+ #[cfg(target_os = "macos")]
+ let backend = SkiaFFramesRenderer::new_metal(&gpu, SkiaPipelineConfig::default())?;
+ #[cfg(not(target_os = "macos"))]
+ let backend = SkiaFFramesRenderer::new_vulkan(&gpu, SkiaPipelineConfig::default())?;
+ Ok(cli::new(
+ &video,
+ RenderOptions {
+ media: Some(&all),
+ video_encoder_options: EncoderOptions {
+ preferred_encoder: Some("libx264"),
+ codec_params: Some(&[("crf", "16"), ("preset", "medium")]),
+ ..Default::default()
+ },
+ audio_mix: AudioMixOptions {
+ limiter: None,
+ ..Default::default()
+ },
+ ..Default::default()
+ },
+ )
+ .args(args)
+ .backend(backend)
+ .preview(fframes_native_player::cli_preview)
+ .default_output(
+ std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("output/made-of-motion.mp4"),
+ )
+ .run())
+}
+
+fn main() -> ExitCode {
+ match run() {
+ Ok(code) => code,
+ Err(error) => {
+ eprintln!("made-of-motion: {error}");
+ ExitCode::FAILURE
+ }
+ }
+}
diff --git a/examples/made-of-motion/src/objects.rs b/examples/made-of-motion/src/objects.rs
new file mode 100644
index 00000000..19f93b68
--- /dev/null
+++ b/examples/made-of-motion/src/objects.rs
@@ -0,0 +1,510 @@
+//! Independently rotating pixel objects in camera space. Camera moves and ring
+//! deformation are sampled from fframes timelines once, when the video is built.
+use std::f32::consts::{PI, TAU};
+
+use fframes::{FFramesContext, Frame, Shader, ShaderUniforms, Svgr, animation::Easing};
+
+type V3 = [f32; 3];
+
+#[derive(Clone, Copy)]
+pub(super) struct RingExcursion {
+ pub start: usize,
+ departure: usize,
+ pub arrival: usize,
+ pub return_start: usize,
+ return_end: usize,
+}
+
+// Each return finishes before the next object leaves. The wheel keeps its
+// position and angular phase even while hidden behind the feature cards.
+pub(super) const EXCURSIONS: [RingExcursion; 3] = [
+ RingExcursion {
+ start: 200,
+ departure: 190,
+ arrival: 205,
+ return_start: 214,
+ return_end: 225,
+ },
+ RingExcursion {
+ start: 237,
+ departure: 227,
+ arrival: 242,
+ return_start: 249,
+ return_end: 259,
+ },
+ RingExcursion {
+ start: 265,
+ departure: 261,
+ arrival: 270,
+ return_start: 280,
+ return_end: 294,
+ },
+];
+
+fn turn(mut p: V3, a: usize, b: usize, angle: f32) -> V3 {
+ let (s, c) = angle.sin_cos();
+ (p[a], p[b]) = (c * p[a] - s * p[b], s * p[a] + c * p[b]);
+ p
+}
+
+#[derive(Clone, Debug)]
+pub(super) struct Object {
+ icon: usize,
+ center: V3,
+ right: V3,
+ down: V3,
+ size: f32,
+ stretch: [f32; 2],
+ heat: f32,
+ soot: f32,
+ pixels: f32,
+ angles: V3,
+ bounds: [f32; 4],
+}
+
+impl Object {
+ // Shared camera-space interpolation keeps the selected ring object alive
+ // through the edit; rebuilding a separate hero entrance caused the jump.
+ fn handoff(&self, target: &Self, progress: f32, lift: f32) -> Self {
+ let mix = |a: f32, b: f32| a + (b - a) * progress;
+ let mut center = std::array::from_fn(|i| mix(self.center[i], target.center[i]));
+ center[1] -= (progress * PI).sin() * lift;
+ let mut object = Self::new(
+ self.icon,
+ center,
+ mix(self.size, target.size),
+ std::array::from_fn(|i| mix(self.angles[i], target.angles[i])),
+ mix(self.heat, target.heat),
+ );
+ object.soot = mix(self.soot, target.soot);
+ object.pixels = mix(self.pixels, target.pixels);
+ object.with_stretch(std::array::from_fn(|i| {
+ mix(self.stretch[i], target.stretch[i])
+ }))
+ }
+
+ // Continue the feature's last measured velocity through the background
+ // cut. The return destination is sampled separately from the real slot.
+ fn continued(&self, previous: &Self, elapsed: f32) -> Self {
+ let extend = |a: f32, b: f32| a + (a - b) * elapsed;
+ let mut object = Self::new(
+ self.icon,
+ std::array::from_fn(|i| extend(self.center[i], previous.center[i])),
+ extend(self.size, previous.size),
+ std::array::from_fn(|i| extend(self.angles[i], previous.angles[i])),
+ self.heat,
+ );
+ object.soot = self.soot;
+ object.pixels = self.pixels;
+ object.with_stretch(self.stretch)
+ }
+
+ fn foreground(&self, amount: f32) -> Self {
+ // Scale camera position and physical size together: the projected pose
+ // is identical, but the flying icon clears the other ring objects.
+ let ratio = 1. + (550_f32.min(self.center[2]) / self.center[2] - 1.) * amount;
+ let mut object = Self::new(
+ self.icon,
+ self.center.map(|value| value * ratio),
+ self.size * ratio,
+ self.angles,
+ self.heat,
+ );
+ object.soot = self.soot;
+ object.pixels = self.pixels;
+ object.with_stretch(self.stretch)
+ }
+
+ pub(super) fn new(icon: usize, center: V3, size: f32, angles: V3, heat: f32) -> Self {
+ let rotate = |p| {
+ turn(
+ turn(turn(p, 0, 2, angles[0]), 1, 2, angles[1]),
+ 0,
+ 1,
+ angles[2],
+ )
+ };
+ let right = rotate([1., 0., 0.]);
+ let down = rotate([0., 1., 0.]);
+ Self {
+ icon,
+ center,
+ right,
+ down,
+ size,
+ stretch: [1.; 2],
+ heat,
+ soot: 0.,
+ pixels: 32.,
+ angles,
+ bounds: [0.; 4],
+ }
+ .with_stretch([1.; 2])
+ }
+
+ pub(super) fn with_stretch(mut self, stretch: [f32; 2]) -> Self {
+ self.stretch = stretch;
+ let mut low = [1440_f32, 1080_f32];
+ let mut high = [0_f32, 0_f32];
+ for (x, y) in [(-1., -1.), (1., -1.), (1., 1.), (-1., 1.)] {
+ let p: V3 = std::array::from_fn(|i| {
+ self.center[i]
+ + (x * self.right[i] * stretch[0] + y * self.down[i] * stretch[1])
+ * self.size
+ * 0.5
+ });
+ let screen = [720. + 1250. * p[0] / p[2], 540. + 1250. * p[1] / p[2]];
+ for i in 0..2 {
+ low[i] = low[i].min(screen[i]);
+ high[i] = high[i].max(screen[i]);
+ }
+ }
+ let x = (low[0] - 2.).floor().max(0.);
+ let y = (low[1] - 2.).floor().max(0.);
+ let w = (high[0] + 2.).ceil().min(1440.) - x;
+ let h = (high[1] + 2.).ceil().min(1080.) - y;
+ self.bounds = [x, y, w, h];
+ self
+ }
+
+ pub(super) fn draw(
+ &self,
+ frame: &Frame,
+ ctx: &FFramesContext<'_, '_>,
+ shader: &Shader,
+ ) -> Svgr<'static> {
+ let Some(atlas) = ctx.get_image("objects.png") else {
+ return Svgr::empty();
+ };
+ let [x, y, w, h] = self.bounds;
+ if w <= 0. || h <= 0. {
+ return Svgr::empty();
+ }
+ let layer = shader.draw(
+ frame,
+ ShaderUniforms::new()
+ .image("uAtlas", atlas)
+ .float2("uOrigin", x, y)
+ .float3("uCenter", self.center[0], self.center[1], self.center[2])
+ .float3("uRight", self.right[0], self.right[1], self.right[2])
+ .float3("uDown", self.down[0], self.down[1], self.down[2])
+ .float("uSize", self.size)
+ .float2("uStretch", self.stretch[0], self.stretch[1])
+ .float2(
+ "uCell",
+ (self.icon % 4) as f32 * 64.,
+ (self.icon / 4) as f32 * 64.,
+ )
+ .float("uHeat", self.heat)
+ .float("uSoot", self.soot)
+ .float("uPixels", self.pixels),
+ );
+ fframes::svgr!(<image href={layer.href()} x={x} y={y} width={w} height={h} />)
+ }
+}
+
+/// Replace one permanent slot's occupant with a complete excursion, including
+/// the feature hold. Feature cards show only the selected track; the hidden
+/// wheel keeps rotating so its vacant slot remains the exact return target.
+pub(super) fn ring_excursion(
+ frames: &mut [Vec<Object>],
+ heroes: &mut [Object],
+ schedule: RingExcursion,
+ keep_spinning: bool,
+) {
+ let RingExcursion {
+ start,
+ departure,
+ arrival,
+ return_start,
+ return_end,
+ } = schedule;
+ let outward_seconds = (arrival - departure) as f32 / 24.;
+ let return_seconds = (return_end - return_start) as f32 / 24.;
+ let pull = fframes::timeline!(
+ at 0.0 => outward_seconds, animate 0.0_f32 => 1.0, Easing::CubicBezier(0.42,0.,0.58,1.),
+ );
+ let rejoin = fframes::timeline!(
+ at 0.0 => return_seconds, animate 0.0_f32 => 1.0, Easing::CubicBezier(0.42,0.,0.58,1.),
+ );
+ // All feature poses live in front of the wheel, with the same projected
+ // size as the authored card. Flight depth now interpolates continuously.
+ let original = heroes
+ .iter()
+ .map(|pose| pose.foreground(1.))
+ .collect::<Vec<_>>();
+ let target = original[arrival - start].clone();
+ let icon = target.icon;
+ let end = start + heroes.len();
+ let Some(destination_roll) = frames[return_end]
+ .iter()
+ .find(|object| object.icon == icon)
+ .map(|object| object.angles[2])
+ else {
+ return;
+ };
+ let roll_offset = if keep_spinning {
+ ((original[return_start - start].angles[2] - destination_roll) / TAU).ceil() * TAU
+ } else {
+ 0.
+ };
+ for (index, objects) in frames
+ .iter_mut()
+ .enumerate()
+ .take(return_end + 1)
+ .skip(departure)
+ {
+ if let Some(selected) = objects.iter_mut().find(|object| object.icon == icon) {
+ // This exact, still-moving slot exists for every frame, including
+ // the black cards. Replace its occupant once; never draw a duplicate
+ // in the wheel, and never reconstruct its location across a cut.
+ let mut slot = selected.clone();
+ let pose = if index <= arrival {
+ let frame = Frame::new(index - departure, index, 24);
+ slot.handoff(&target, frame.animate(&pull), 90.)
+ } else if index < return_start {
+ original[index - start].clone()
+ } else {
+ let source = if index < end {
+ original[index - start].clone()
+ } else {
+ original[original.len() - 1]
+ .continued(&original[original.len() - 2], (index + 1 - end) as f32)
+ };
+ slot.angles[2] += roll_offset;
+ let frame = Frame::new(index - return_start, index, 24);
+ source.handoff(&slot, frame.animate(&rejoin), -55.)
+ };
+ *selected = pose.clone();
+ if (start..end).contains(&index) {
+ heroes[index - start] = pose;
+ }
+ }
+ objects.sort_by(|a, b| b.center[2].total_cmp(&a.center[2]));
+ }
+}
+
+pub(super) fn hero(icon: usize, x: f32, y: f32, size: f32, time: f32) -> Object {
+ Object::new(
+ icon,
+ [x - 720., y - 540., 1250.],
+ size,
+ [
+ (time * 6.0 + 0.4).sin() * 0.8,
+ 0.15 * (time * 4.).cos(),
+ -0.10 + (time * 2.7).sin() * 0.25,
+ ],
+ 0.,
+ )
+}
+
+fn base_choreography() -> Vec<Vec<Object>> {
+ let tilt = fframes::timeline!(
+ at 6.541_667 => 7.291_667, animate 0.34_f32 => 0.63, Easing::CubicBezier(0.65,0.,0.35,1.),
+ at 7.291_667 => 7.833_333, animate 0.63_f32 => 0.50, Easing::EaseInOut,
+ at 7.833_333 => 8.333_333, animate 0.50_f32 => 0.48, Easing::EaseInOut,
+ at 11.916_667 => 12.5, animate 0.48_f32 => 0.98, Easing::CubicBezier(0.16,1.,0.3,1.),
+ );
+ let explode = fframes::timeline!(
+ at 12.583_333 => 13.0, animate 0.0_f32 => 1.0, Easing::CubicBezier(0.16,1.,0.3,1.),
+ );
+ // Arrange the three featured objects along the approaching arc. At their
+ // departure frames (190, 227, 261), each sits just left of the nearest
+ // point, rather than being lifted through the ring from its far side.
+ // Keep angular velocity continuous across the hero/background cuts.
+ let front_angle = 1.95;
+ let departure_rotation = front_angle + PI * 0.5 - 2. * TAU / 12.;
+ let scatter_rotation = departure_rotation + (302. - 190.) / 24.;
+ let spin = fframes::timeline!(
+ at (153.0 / 24.0) => (302.0 / 24.0),
+ animate (departure_rotation + (153. - 190.) / 24.) => scatter_rotation,
+ Easing::Linear,
+ );
+ let order = [10, 7, 0, 6, 11, 9, 3, 2, 1, 4, 8, 5];
+ (0..489)
+ .map(|index| {
+ let frame = Frame::new(index, index, 24);
+ let t = frame.seconds();
+ let open = frame.animate(&explode);
+ let plane = frame.animate(&tilt);
+ let rotation = frame.animate(&spin);
+ let mut objects = Vec::with_capacity(12);
+ if (48..93).contains(&index) {
+ let positions = [[735., 351.], [1060., 348.], [960., 665.], [1120., 869.]];
+ for (i, icon) in [7, 1, 11, 0].into_iter().enumerate() {
+ let local = (index - 48) as f32;
+ let phase = local * 0.11 + i as f32 * 2.3;
+ let x = positions[i][0] + phase.sin() * 15.;
+ let y = positions[i][1] + (phase * 0.8).cos() * 13.;
+ let mut object = Object::new(
+ icon,
+ [x - 720., y - 540., 1250.],
+ 104.,
+ [(phase * 0.82).sin() * 0.68, 0.12, phase.sin() * 0.16],
+ 0.,
+ );
+ // The source briefly breaks these distant objects down
+ // into big mosaic pixels, then resolves their detail again.
+ object.pixels = match index {
+ 48..=54 => 16.,
+ 75..=77 => 12.,
+ 78..=81 => 6.,
+ 82..=84 => 10.,
+ _ => 32.,
+ };
+ objects.push(object);
+ }
+ } else if (153..331).contains(&index) {
+ for (i, icon) in order.into_iter().enumerate() {
+ let a = i as f32 * TAU / 12. + rotation - PI * 0.5;
+ let (sin, cos) = a.sin_cos();
+ let radius = 355.;
+ let mut x = cos * radius;
+ let mut y = sin * radius * plane;
+ let mut z = 1250. - sin * 600. * (1. - plane * plane).sqrt();
+ // Explosion retains tangential momentum. Individual pieces then
+ // drift and tumble; it is not a flat scaling of the whole ring.
+ if open > 0. {
+ let a0 = i as f32 * TAU / 12. + scatter_rotation - PI * 0.5;
+ let targets = [
+ [0., -420.],
+ [150., -100.],
+ [420., -280.],
+ [350., 140.],
+ [530., 100.],
+ [520., 340.],
+ [-80., 30.],
+ [-360., 350.],
+ [-480., -130.],
+ [-360., -50.],
+ [-240., 70.],
+ [180., 200.],
+ ];
+ let drift = (t - 13.).max(0.);
+ x = a0.cos() * radius * (1. - open)
+ + targets[i][0] * open
+ + drift * 45. * a0.sin();
+ y = a0.sin() * radius * 0.98 * (1. - open)
+ + targets[i][1] * open
+ + drift * 32. * a0.cos();
+ z = 1250. + open * (i as f32 * 3.7).sin() * 140.;
+ }
+ let roll = (t * 0.9 + i as f32).sin() * 0.12
+ + open * (t - 12.58) * (i as f32 - 5.) * 0.17;
+ let yaw = (t * 1.05 + i as f32 * 1.7).sin() * 0.35 + open * (t - 12.58) * 0.75;
+ let heat = if index < 157 {
+ 1. - (index - 153) as f32 * 0.14
+ } else if icon == 3 || icon == 5 {
+ ((t * 3. + i as f32).sin() - 0.85).max(0.) * 4.
+ } else {
+ 0.
+ };
+ objects.push(Object::new(
+ icon,
+ [x, y, z],
+ 195. - open * 35.,
+ [yaw, 0.1, roll],
+ heat,
+ ));
+ }
+ }
+ objects.sort_by(|a, b| b.center[2].total_cmp(&a.center[2]));
+ objects
+ })
+ .collect()
+}
+
+#[derive(Debug, Clone)]
+pub(super) struct Impact {
+ pub at: usize,
+ pub position: [f32; 2],
+ pub direction: [f32; 2],
+ icon: usize,
+ approach: [f32; 2],
+}
+
+pub(super) fn choreography() -> (Vec<Vec<Object>>, Vec<Impact>) {
+ let mut frames = base_choreography();
+ let mut impacts = Vec::new();
+ // Pick the object at each reference contact point so the nib, flare and
+ // response all use one event. This remains correct if the ring is retimed.
+ for (at, desired, direction) in [
+ (172, [1045., 592.], [0.65, 0.6]),
+ (177, [767., 659.], [0.0, 1.0]),
+ (182, [425., 671.], [-0.75, 0.65]),
+ (188, [340., 487.], [-0.91, -0.41]),
+ (312, [1080., 575.], [0.45, 0.9]),
+ (318, [400., 878.], [-0.9, -0.1]),
+ ] {
+ let nearest = frames[at]
+ .iter()
+ .filter(|o| impacts.last().is_none_or(|h: &Impact| h.icon != o.icon))
+ .min_by(|a, b| {
+ let distance = |o: &Object| {
+ let x = 720. + o.center[0] * 1250. / o.center[2];
+ let y = 540. + o.center[1] * 1250. / o.center[2];
+ (x - desired[0]).powi(2) + (y - desired[1]).powi(2)
+ };
+ distance(a).total_cmp(&distance(b))
+ });
+ if let Some(object) = nearest {
+ impacts.push(Impact {
+ at,
+ icon: object.icon,
+ direction,
+ position: desired,
+ approach: [
+ (desired[0] - 720.) * object.center[2] / 1250. - object.center[0],
+ (desired[1] - 540.) * object.center[2] / 1250. - object.center[1],
+ ],
+ });
+ }
+ }
+ let response = fframes::timeline!(
+ at 0.0 => 0.083_333, animate 0.0_f32 => 1.0, Easing::EaseOut,
+ at 0.083_333, animate 1.0_f32 => 0.0,
+ Easing::Spring { mass: 1.0, stiffness: 190.0, damping: 14.0 },
+ );
+ let approach = fframes::timeline!(
+ at 0.0 => 0.125, animate 0.0_f32 => 1.0, Easing::EaseInOut,
+ at 0.125 => 0.75, animate 1.0_f32 => 0.0, Easing::EaseOut,
+ );
+ for (index, objects) in frames.iter_mut().enumerate() {
+ for object in objects.iter_mut() {
+ let mut center = object.center;
+ let mut angles = object.angles;
+ let mut heat = object.heat;
+ let mut soot = 0.0_f32;
+ for hit in &impacts {
+ if hit.icon != object.icon || index + 3 < hit.at || index > hit.at + 25 {
+ continue;
+ }
+ let arrive = Frame::new(index + 3 - hit.at, index, 24).animate(&approach);
+ center[0] += hit.approach[0] * arrive;
+ center[1] += hit.approach[1] * arrive;
+ if index < hit.at {
+ continue;
+ }
+ let elapsed = index - hit.at;
+ let kick = Frame::new(elapsed, index, 24).animate(&response);
+ center[0] += hit.direction[0] * 98. * kick;
+ center[1] += hit.direction[1] * 72. * kick;
+ center[2] -= 85. * kick;
+ angles[0] += kick * 0.84;
+ angles[2] += kick * hit.direction[0] * 0.43;
+ heat = heat.max((1. - elapsed as f32 / 5.).max(0.) * 0.83);
+ soot = soot.max(
+ ((elapsed as f32 - 3.) / 4.).clamp(0., 1.)
+ * (1. - (elapsed as f32 - 11.).max(0.) / 12.).max(0.)
+ * 0.92,
+ );
+ }
+ let pixels = object.pixels;
+ *object = Object::new(object.icon, center, object.size, angles, heat);
+ object.soot = soot;
+ object.pixels = pixels;
+ }
+ objects.sort_by(|a, b| b.center[2].total_cmp(&a.center[2]));
+ }
+ (frames, impacts)
+}
diff --git a/examples/made-of-motion/src/opening-type.path b/examples/made-of-motion/src/opening-type.path
new file mode 100644
index 00000000..64a22c2e
--- /dev/null
+++ b/examples/made-of-motion/src/opening-type.path
@@ -0,0 +1 @@
+M112 368h48v16h-48z M112 384h48v16h-48z M1056 384h48v16h-48z M112 400h48v16h-48z M1056 400h48v16h-48z M112 416h48v16h-48z M1056 416h48v16h-48z M16 432h80v16h-80z M112 432h48v16h-48z M224 432h80v16h-80z M416 432h48v16h-48z M544 432h48v16h-48z M640 432h80v16h-80z M784 432h48v16h-48z M912 432h32v16h-32z M1024 432h112v16h-112z M1152 432h48v16h-48z M1264 432h48v16h-48z M1344 432h48v16h-48z M1408 432h32v16h-32z M0 448h160v16h-160z M208 448h112v16h-112z M432 448h48v16h-48z M544 448h48v16h-48z M624 448h128v16h-128z M784 448h48v16h-48z M896 448h48v16h-48z M1024 448h112v16h-112z M1152 448h48v16h-48z M1264 448h48v16h-48z M1344 448h96v16h-96z M0 464h160v16h-160z M192 464h144v16h-144z M432 464h48v16h-48z M544 464h48v16h-48z M608 464h144v16h-144z M784 464h48v16h-48z M896 464h48v16h-48z M1040 464h96v16h-96z M1152 464h48v16h-48z M1264 464h48v16h-48z M1344 464h96v16h-96z M0 480h48v16h-48z M96 480h64v16h-64z M176 480h64v16h-64z M288 480h48v16h-48z M432 480h48v16h-48z M528 480h48v16h-48z M608 480h48v16h-48z M720 480h48v16h-48z M784 480h48v16h-48z M896 480h48v16h-48z M1056 480h48v16h-48z M1152 480h48v16h-48z M1264 480h48v16h-48z M1344 480h64v16h-64z M0 496h32v16h-32z M112 496h48v16h-48z M176 496h48v16h-48z M288 496h64v16h-64z M448 496h48v16h-48z M528 496h48v16h-48z M608 496h48v16h-48z M720 496h48v16h-48z M784 496h48v16h-48z M896 496h48v16h-48z M1056 496h48v16h-48z M1152 496h48v16h-48z M1264 496h48v16h-48z M1344 496h48v16h-48z M0 512h32v16h-32z M112 512h48v16h-48z M176 512h48v16h-48z M304 512h48v16h-48z M448 512h48v16h-48z M528 512h48v16h-48z M592 512h48v16h-48z M720 512h48v16h-48z M784 512h48v16h-48z M896 512h48v16h-48z M1056 512h48v16h-48z M1152 512h48v16h-48z M1264 512h48v16h-48z M1344 512h48v16h-48z M0 528h32v16h-32z M112 528h48v16h-48z M176 528h48v16h-48z M304 528h48v16h-48z M448 528h48v16h-48z M512 528h48v16h-48z M592 528h48v16h-48z M720 528h48v16h-48z M784 528h48v16h-48z M896 528h48v16h-48z M1056 528h48v16h-48z M1152 528h48v16h-48z M1264 528h48v16h-48z M1344 528h48v16h-48z M0 544h32v16h-32z M112 544h48v16h-48z M176 544h48v16h-48z M288 544h64v16h-64z M464 544h32v16h-32z M512 544h48v16h-48z M608 544h48v16h-48z M720 544h48v16h-48z M784 544h48v16h-48z M896 544h48v16h-48z M1056 544h48v16h-48z M1152 544h48v16h-48z M1264 544h48v16h-48z M1344 544h48v16h-48z M0 560h48v16h-48z M96 560h64v16h-64z M176 560h64v16h-64z M288 560h48v16h-48z M464 560h80v16h-80z M608 560h48v16h-48z M704 560h64v16h-64z M800 560h48v16h-48z M896 560h48v16h-48z M1056 560h48v16h-48z M1152 560h64v16h-64z M1264 560h48v16h-48z M1344 560h48v16h-48z M0 576h160v16h-160z M192 576h144v16h-144z M464 576h80v16h-80z M608 576h144v16h-144z M800 576h144v16h-144z M1056 576h80v16h-80z M1168 576h144v16h-144z M1344 576h48v16h-48z M0 592h160v16h-160z M208 592h112v16h-112z M480 592h64v16h-64z M624 592h112v16h-112z M800 592h144v16h-144z M1056 592h80v16h-80z M1168 592h144v16h-144z M1344 592h48v16h-48z M32 608h64v16h-64z M112 608h48v16h-48z M224 608h80v16h-80z M480 608h48v16h-48z M640 608h80v16h-80z M816 608h64v16h-64z M912 608h32v16h-32z M1088 608h48v16h-48z M1184 608h64v16h-64z M1264 608h48v16h-48z M1344 608h48v16h-48z M480 624h48v16h-48z M464 640h64v16h-64z M432 656h80v16h-80z M432 672h64v16h-64z
diff --git a/examples/made-of-motion/src/opening.rs b/examples/made-of-motion/src/opening.rs
new file mode 100644
index 00000000..27faa4d6
--- /dev/null
+++ b/examples/made-of-motion/src/opening.rs
@@ -0,0 +1,149 @@
+//! Opening typography: source-timed rulers, lateral camera moves and selection collapse.
+
+use fframes::{FFramesContext, FontQuery, Frame, Svgr, Transform, animation::Easing};
+
+use crate::{QUESTION, label};
+
+pub(super) fn draw(frame: &mut Frame, ctx: &FFramesContext<'_, '_>) -> Svgr<'static> {
+ let n = frame.index;
+ if n >= 18 {
+ let count = (4 + (n - 13) * 8 / 32).min(12);
+ let copy = prefix(count);
+ let selection = if matches!(n, 18..=20 | 22) {
+ let width = frame
+ .text_width(
+ ctx,
+ FontQuery {
+ family: "Inter 24pt",
+ size: 54,
+ weight: 700,
+ ..Default::default()
+ },
+ copy,
+ )
+ .map_or(450., |width| {
+ width as f32 - 1.25 * copy.chars().count().saturating_sub(1) as f32
+ });
+ let right = 106.25 + width + 24.;
+ // The reference briefly resolves into a typesetting selection, then
+ // blinks it off/on once. Keep both end caps outside our adapted copy.
+ fframes::svgr!(<g opacity={if n == 18 {0.40} else if n == 22 {0.78} else {0.58}}>
+ <path d={format!("M82 444 H{right} M82 628 H{right}")}
+ stroke="#553424" stroke-width="2.3" stroke-dasharray="6 7" fill="none"/>
+ <path d={format!("M72 444 H92 M82 444 V628 M72 628 H92 M{} 444 H{} M{right} 444 V628 M{} 628 H{}",right-10.,right+10.,right-10.,right+10.)}
+ stroke="#38241b" stroke-width="6" fill="none"/>
+ </g>)
+ } else {
+ Svgr::empty()
+ };
+ return fframes::svgr!(<g>{selection}{label(copy,106.25,554.,54.,"#171611",false)}</g>);
+ }
+
+ if n >= 14 {
+ return collapse(frame);
+ }
+
+ let count = match n {
+ 0..=4 => 1,
+ 5..=7 => 2,
+ 8..=12 => 3,
+ _ => 4,
+ };
+ let copy = prefix(count);
+ let flash = match n {
+ 1 => fframes::svgr!(<rect width="1440" height="1080" fill="#ce101c"/>),
+ 2 => fframes::svgr!(<rect width="1440" height="1080" fill="#e8b900"/>),
+ _ => Svgr::empty(),
+ };
+ let rulers = if n == 2 {
+ fframes::svgr!(<path d="M0 108 H1440 M0 957 H1440" fill="none"
+ stroke="#654020" stroke-width="8" stroke-dasharray="44 44"/>)
+ } else if n >= 3 {
+ // These are x-height/baseline rulers, not padding above and below the
+ // word. They stay full-width while the oversized type pans through them.
+ fframes::svgr!(<path d="M0 444 H1440 M0 620 H1440" fill="none"
+ stroke="#633b25" stroke-width="4" stroke-dasharray="44 44"
+ stroke-dashoffset={n as f32 * 3.0} opacity="0.86"/>)
+ } else {
+ Svgr::empty()
+ };
+ if n == 13 {
+ return fframes::svgr!(<g>{rulers}
+ <path d={include_str!("opening-type.path")} fill="#211914"/>
+ </g>);
+ }
+ let cursor = match n {
+ 8 => fframes::svgr!(<rect x="506" y="369" width="934" height="257" fill="#191716"/>),
+ 9 => fframes::svgr!(<rect x="890" y="369" width="456" height="257" fill="#191716"/>),
+ 10 => fframes::svgr!(<rect x="1252" y="369" width="9" height="257" fill="#38241b"/>),
+ _ => Svgr::empty(),
+ };
+ fframes::svgr!(<g>
+ {flash}{rulers}
+ <g transform={frame.animate(fframes::timeline!(
+ at 0.208_333 => 0.25,
+ animate Transform::translate(421.,0.) => Transform::translate(366.,0.), Easing::Linear,
+ at 0.25 => 0.291_667,
+ animate Transform::translate(366.,0.) => Transform::translate(-125.,0.), Easing::Linear,
+ at 0.291_667 => 0.375,
+ animate Transform::translate(-125.,0.) => Transform::translate(-176.,0.), Easing::EaseOut,
+ at 0.375 => 0.416_667,
+ animate Transform::translate(-176.,0.) => Transform::translate(-500.,0.), Easing::Linear,
+ at 0.416_667 => 0.458_333,
+ animate Transform::translate(-500.,0.) => Transform::translate(-705.,0.), Easing::EaseOut,
+ at 0.458_333 => 0.5,
+ animate Transform::translate(-705.,0.) => Transform::translate(-722.,0.), Easing::EaseOut,
+ ))}>
+ <g transform={Transform { translate_y: if n == 1 {1130.} else {620.}, scale: (6.,if n == 1 {30.} else {6.5}).into(), ..Default::default() }}>
+ {label(copy,0.,0.,54.,"#211914",false)}
+ </g>
+ </g>
+ {cursor}
+ </g>)
+}
+
+fn prefix(count: usize) -> &'static str {
+ let end = QUESTION
+ .match_indices(' ')
+ .nth(count.saturating_sub(1))
+ .map_or(QUESTION.len(), |(index, _)| index);
+ &QUESTION[..end]
+}
+
+fn collapse(frame: &Frame) -> Svgr<'static> {
+ // Four source exposures collapse the large lettering into broken scanlines
+ // before the small selection resolves. This is geometry, not source footage.
+ let (streaks, cursor, blur) = match frame.index {
+ 14 => (
+ "M220 548 L223 516 L240 526 L230 536 L250 550 M281 528 L301 543 M330 526 L344 516 L335 541 M374 523 L365 541 M409 528 L427 544 M465 526 L454 544 M501 529 L511 545 M538 529 L551 543 M578 537 H777 M830 542 L853 530 M881 540 L899 523",
+ "M0 0",
+ 5.,
+ ),
+ 15 => (
+ "M144 517 V540 H175 M212 540 H257 M286 540 H302 M329 540 H342 M377 540 H389 M408 540 H430 M500 540 H507 M549 540 H647 M709 540 L723 520 L739 540 H759",
+ "M1100 448 H1115 M1107 490 V519 M1107 563 V586",
+ 4.,
+ ),
+ 16 => (
+ "M178 539 H218 M292 539 H303 M325 539 H394 M513 539 H557 M577 539 H587 M628 539 H638 M681 539 H691 M710 539 H733",
+ "M905 470 V508 M905 551 V581",
+ 2.5,
+ ),
+ _ => (
+ "M114 539 H122 M143 539 H161 M221 539 H250 M276 539 H292 M320 539 H350 M377 539 H419 M454 539 H472 M491 539 H528 M571 539 H593 M641 539 H659 M686 539 H704",
+ "M793 431 H825 M809 472 V494 M809 550 V590",
+ 4.,
+ ),
+ };
+ fframes::svgr!(<g>
+ <defs>
+ <filter id="opening-focus" x="-20%" y="-100%" width="140%" height="300%">
+ <feGaussianBlur stdDeviation={blur}/>
+ </filter>
+ </defs>
+ <g filter="url(#opening-focus)" opacity="0.82">
+ <path d={streaks} fill="none" stroke="#211914" stroke-width="13" stroke-linecap="round"/>
+ <path d={cursor} fill="none" stroke="#38241b" stroke-width="12"/>
+ </g>
+ </g>)
+}
diff --git a/examples/made-of-motion/src/opening_capture.rs b/examples/made-of-motion/src/opening_capture.rs
new file mode 100644
index 00000000..a6aa683d
--- /dev/null
+++ b/examples/made-of-motion/src/opening_capture.rs
@@ -0,0 +1,42 @@
+// Final measured opening exposures and electric-star poses.
+// Global frames 51..88: centre, radii, angle, cusp exponent (1440x1080 units).
+pub(super) const STAR: [[f32; 6]; 38] = [
+ [240.00, 546.96, 562.04, 1245.45, -0.47054, 0.35798],
+ [207.11, 541.20, 790.01, 1083.29, -0.26457, 0.32646],
+ [162.79, 540.33, 1113.33, 1595.71, -0.09731, 0.28000],
+ [131.40, 541.88, 934.88, 1393.59, 0.03507, 0.29964],
+ [107.59, 539.54, 945.84, 1230.68, 0.13865, 0.30862],
+ [89.53, 540.39, 899.34, 1160.45, 0.22398, 0.31312],
+ [74.72, 540.29, 859.24, 1013.45, 0.29862, 0.32674],
+ [62.06, 539.11, 820.07, 896.56, 0.36082, 0.33978],
+ [51.56, 537.90, 751.05, 803.24, 0.41656, 0.35801],
+ [44.51, 539.29, 854.90, 988.11, 0.45968, 0.32622],
+ [38.19, 537.55, 764.81, 781.78, 0.50129, 0.35788],
+ [33.93, 536.73, 753.43, 771.54, 0.53495, 0.35866],
+ [29.98, 536.85, 795.98, 843.09, 0.56496, 0.34650],
+ [25.56, 536.63, 944.98, 992.66, 0.59022, 0.31945],
+ [22.93, 536.75, 1172.10, 1233.63, 0.61307, 0.29016],
+ [20.43, 536.08, 1102.61, 1125.99, 0.63413, 0.29928],
+ [17.97, 536.57, 1034.13, 1050.59, 0.65134, 0.30707],
+ [15.83, 536.72, 1032.35, 1009.49, 0.66743, 0.31001],
+ [14.03, 537.28, 970.18, 974.79, 0.67994, 0.31620],
+ [11.65, 537.96, 905.43, 919.72, 0.69102, 0.32459],
+ [10.08, 537.74, 849.62, 867.02, 0.70322, 0.33405],
+ [10.21, 537.53, 786.01, 782.16, 0.71277, 0.34902],
+ [9.84, 537.37, 795.06, 788.31, 0.72221, 0.34680],
+ [9.91, 539.10, 752.11, 747.97, 0.72783, 0.35661],
+ [10.12, 538.99, 739.51, 740.55, 0.73641, 0.35873],
+ [10.03, 540.33, 711.00, 723.38, 0.73970, 0.36541],
+ [10.22, 537.69, 720.09, 738.30, 0.75013, 0.36147],
+ [9.66, 538.22, 733.30, 743.22, 0.75547, 0.35878],
+ [10.33, 539.15, 756.28, 756.76, 0.75855, 0.35300],
+ [11.45, 537.85, 715.65, 716.02, 0.76540, 0.36432],
+ [11.40, 537.16, 715.03, 722.79, 0.77079, 0.36322],
+ [12.10, 537.54, 714.15, 727.89, 0.77438, 0.36136],
+ [11.99, 539.31, 724.96, 730.99, 0.77493, 0.35994],
+ [13.55, 538.38, 726.28, 725.40, 0.78115, 0.36020],
+ [14.14, 539.23, 727.87, 736.29, 0.78280, 0.36011],
+ [14.54, 537.85, 767.55, 766.64, 0.78933, 0.35326],
+ [16.81, 537.80, 787.85, 785.55, 0.79304, 0.34942],
+ [20.59, 538.14, 770.81, 780.11, 0.79606, 0.35345],
+];
diff --git a/examples/made-of-motion/src/restoration_capture.rs b/examples/made-of-motion/src/restoration_capture.rs
new file mode 100644
index 00000000..eb78e550
--- /dev/null
+++ b/examples/made-of-motion/src/restoration_capture.rs
@@ -0,0 +1,78 @@
+//! Final measured hand placements and camera poses. Atlas xy, canvas xy, size.
+pub(super) const HAND: [[f32; 6]; 51] = [
+ [0., 0., 0., 0., 0., 0.],
+ [0., 0., 439., 644., 351., 436.],
+ [367., 0., 404., 578., 385., 502.],
+ [768., 0., 418., 502., 422., 578.],
+ [1206., 0., 356., 432., 458., 648.],
+ [1680., 0., 317., 408., 493., 672.],
+ [2189., 0., 322., 380., 513., 700.],
+ [2718., 0., 361., 382., 497., 698.],
+ [3231., 0., 405., 373., 466., 707.],
+ [0., 723., 493., 363., 405., 717.],
+ [421., 723., 490., 362., 430., 718.],
+ [867., 723., 486., 362., 452., 718.],
+ [1335., 723., 480., 360., 470., 720.],
+ [1821., 723., 478., 358., 480., 722.],
+ [2317., 723., 478., 358., 480., 722.],
+ [2813., 723., 479., 355., 483., 725.],
+ [3312., 723., 482., 352., 485., 728.],
+ [0., 1467., 486., 351., 484., 729.],
+ [500., 1467., 494., 352., 476., 728.],
+ [992., 1467., 494., 352., 474., 728.],
+ [1482., 1467., 499., 350., 467., 730.],
+ [1965., 1467., 498., 352., 468., 728.],
+ [2449., 1467., 502., 350., 462., 730.],
+ [2927., 1467., 502., 350., 462., 730.],
+ [3405., 1467., 508., 350., 456., 730.],
+ [0., 2213., 508., 350., 456., 730.],
+ [472., 2213., 510., 350., 454., 730.],
+ [942., 2213., 510., 350., 452., 730.],
+ [1410., 2213., 508., 350., 454., 730.],
+ [1880., 2213., 508., 350., 454., 730.],
+ [2350., 2213., 508., 350., 454., 730.],
+ [2820., 2213., 508., 352., 452., 728.],
+ [3288., 2213., 508., 352., 452., 728.],
+ [0., 2959., 508., 352., 452., 728.],
+ [468., 2959., 508., 352., 452., 728.],
+ [936., 2959., 508., 352., 452., 728.],
+ [1404., 2959., 508., 352., 452., 728.],
+ [1872., 2959., 508., 352., 452., 728.],
+ [2340., 2959., 508., 356., 440., 724.],
+ [2796., 2959., 507., 356., 441., 724.],
+ [3253., 2959., 506., 356., 440., 724.],
+ [0., 3703., 504., 360., 432., 720.],
+ [448., 3703., 506., 364., 428., 716.],
+ [892., 3703., 507., 376., 453., 704.],
+ [1361., 3703., 524., 382., 455., 698.],
+ [1832., 3703., 568., 396., 439., 684.],
+ [2287., 3703., 607., 452., 417., 628.],
+ [2720., 3703., 616., 478., 414., 602.],
+ [3150., 3703., 625., 484., 383., 596.],
+ [3549., 3703., 626., 432., 288., 648.],
+ [0., 4439., 158., 594., 541., 486.],
+];
+
+// Measured camera-body extents in its local axes, relative to frames 205–208.
+pub(super) const CAMERA_POSE: [[f32; 3]; 20] = [
+ [1.0338, 1.0246, 0.0000],
+ [1.0055, 1.0066, -0.1400],
+ [0.9937, 0.9925, -0.1650],
+ [1.0047, 1.0249, -0.1950],
+ [1.0127, 1.0172, -0.2000],
+ [1.0064, 1.0064, -0.1950],
+ [1.0004, 1.0016, -0.2000],
+ [0.9983, 0.9984, -0.2000],
+ [0.9996, 0.9873, -0.2050],
+ [0.9940, 2.5386, -0.2450],
+ [0.9914, 2.5427, -0.2550],
+ [0.9897, 2.5466, -0.2600],
+ [0.9934, 2.5427, -0.2550],
+ [0.9914, 2.5461, -0.2600],
+ [0.9914, 2.5456, -0.2600],
+ [2.2523, 0.5908, -0.2250],
+ [2.2569, 0.5926, -0.2350],
+ [2.2605, 0.5903, -0.2400],
+ [2.2495, 0.5893, -0.2650],
+ [2.1833, 0.5964, -0.4400],
+];
diff --git a/examples/made-of-motion/src/shaders/hand.sksl b/examples/made-of-motion/src/shaders/hand.sksl
new file mode 100644
index 00000000..4a132805
--- /dev/null
+++ b/examples/made-of-motion/src/shaders/hand.sksl
@@ -0,0 +1,41 @@
+uniform shader uField;
+uniform float2 uAtlas;
+uniform float4 uRect;
+uniform float iTime;
+uniform int iFrame;
+
+float hash(float2 p) { return fract(sin(dot(p,float2(127.1,311.7)))*43758.5453); }
+float noise(float2 p) {
+ float2 a=floor(p), f=fract(p); f=f*f*(3.-2.*f);
+ return mix(mix(hash(a),hash(a+float2(1,0)),f.x),
+ mix(hash(a+float2(0,1)),hash(a+1.),f.x),f.y);
+}
+half4 field(float2 p) {
+ float2 q=p-uRect.xy;
+ if(min(q.x,q.y)<0. || q.x>=uRect.z || q.y>=uRect.w) return half4(0);
+ return uField.eval(uAtlas+q);
+}
+float3 thermal(float h) {
+ float3 c=mix(float3(.15,.025,.28),float3(.65,.016,.14),smoothstep(.03,.24,h));
+ c=mix(c,float3(.96,.075,.016),smoothstep(.24,.45,h));
+ c=mix(c,float3(1.,.51,.018),smoothstep(.44,.72,h));
+ c=mix(c,float3(1.,.83,.31),smoothstep(.69,.88,h));
+ return mix(c,float3(1.,.96,.80),smoothstep(.87,1.,h));
+}
+half4 main(float2 p) {
+ float grain=hash(floor(p*.84)+float(iFrame)*19.7)-.5;
+ float cloud=(noise(p/290.)-.5)*.017+(noise(p/59.)-.5)*.005;
+ float flare=smoothstep(1.65,2.0833,iTime);
+ float light=exp(-length((p-float2(790,620))/float2(850,770)));
+ float3 bg=float3(.046,.049,.050)+cloud+grain*.012;
+ bg+=flare*(float3(.17,.14,.15)*light+float3(.024,.005,.002));
+ half4 f=field(p);
+ float alpha=float(f.a);
+ float heat=alpha>.001 ? float(f.r)/alpha : .3;
+ float halo=(field(p+float2(14,0)).a+field(p-float2(14,0)).a
+ +field(p+float2(0,14)).a+field(p-float2(0,14)).a)*.25;
+ bg+=float3(.16,.025,.004)*halo*(1.-alpha)*.18;
+ float3 body=thermal(heat+grain*.018);
+ body+=grain*.021+(noise(p/3.1)-.5)*.007;
+ return half4(mix(bg,body,alpha),1);
+}
diff --git a/examples/made-of-motion/src/shaders/impact.sksl b/examples/made-of-motion/src/shaders/impact.sksl
new file mode 100644
index 00000000..74794d32
--- /dev/null
+++ b/examples/made-of-motion/src/shaders/impact.sksl
@@ -0,0 +1,29 @@
+uniform float uAge;
+uniform float uSeed;
+uniform float2 uDirection;
+float hash(float p) { return fract(sin(p*127.1+uSeed*71.7)*43758.5453); }
+half4 main(float2 p) {
+ float2 q=p-float2(170.);
+ float t=uAge;
+ float fade=exp(-t*.42);
+ float r=length(q);
+ float grain=fract(sin(dot(floor(p),float2(127.1,311.7)))*43758.5453);
+ float cloud=exp(-r*r/(2300.+t*380.))*.76;
+ cloud*=smoothstep(.16,.92,grain);
+ float rays=0.;
+ for(int i=0;i<7;i++) {
+ float fi=float(i);
+ float angle=hash(fi)*6.283185;
+ float2 v=float2(cos(angle),sin(angle));
+ float along=dot(q,v);
+ float side=abs(q.x*v.y-q.y*v.x);
+ float start=32.+t*7.;
+ float len=28.+hash(fi+11.)*54.;
+ float tip=clamp((along-start)/len,0.,1.);
+ float width=(1.-tip)*(2.+hash(fi+41.)*3.);
+ float ray=(1.-smoothstep(width,width+1.,side))*step(start,along)*step(along,start+len);
+ rays=max(rays,ray);
+ }
+ float alpha=clamp(max(cloud,rays)*fade,0.,1.);
+ return half4(half3(float3(.96,.59,.025)*alpha),half(alpha));
+}
diff --git a/examples/made-of-motion/src/shaders/object.sksl b/examples/made-of-motion/src/shaders/object.sksl
new file mode 100644
index 00000000..57e81c18
--- /dev/null
+++ b/examples/made-of-motion/src/shaders/object.sksl
@@ -0,0 +1,37 @@
+uniform shader uAtlas;
+uniform float2 uOrigin;
+uniform float3 uCenter;
+uniform float3 uRight;
+uniform float3 uDown;
+uniform float uSize;
+uniform float2 uStretch;
+uniform float2 uCell;
+uniform float uHeat;
+uniform float uSoot;
+uniform float uPixels;
+
+half4 sampleObject(float2 p) {
+ float3 ray=float3((p+uOrigin-float2(720,540))/1250.,1.);
+ float3 normal=cross(uRight,uDown);
+ float den=dot(ray,normal);
+ if(abs(den)<.00001) return half4(0);
+ float3 hit=ray*(dot(uCenter,normal)/den)-uCenter;
+ float2 uv=float2(dot(hit,uRight),dot(hit,uDown))/(uSize*uStretch)+.5;
+ if(min(uv.x,uv.y)<0. || max(uv.x,uv.y)>=1.) return half4(0);
+ half4 c=uAtlas.eval(uCell+floor((floor(uv*uPixels)+.5)*(64./uPixels))+.5);
+ float shade=.82+.18*abs(normal.z);
+ c.rgb*=shade;
+ if(uHeat>0.) {
+ float h=sin(uv.x*5.+uv.y*8.)*.5+.5;
+ float3 heat=mix(float3(.9,.09,.015),float3(1.,.9,.39),h);
+ c.rgb=mix(c.rgb,half3(heat)*c.a,uHeat);
+ }
+ float stain=1.-smoothstep(.28,.60,length((uv-float2(.43,.5))*float2(1.,.82)));
+ c.rgb=mix(c.rgb,half3(.022,.019,.016)*c.a,uSoot*stain);
+ return c;
+}
+half4 main(float2 p) {
+ // Coverage AA at the projected pixel edges; never blur across atlas texels.
+ return (sampleObject(p+float2(-.28,-.28))+sampleObject(p+float2(.28,-.28))
+ +sampleObject(p+float2(-.28,.28))+sampleObject(p+float2(.28,.28)))*.25;
+}
diff --git a/examples/made-of-motion/src/shaders/paper.sksl b/examples/made-of-motion/src/shaders/paper.sksl
new file mode 100644
index 00000000..f3da6df1
--- /dev/null
+++ b/examples/made-of-motion/src/shaders/paper.sksl
@@ -0,0 +1,22 @@
+uniform float3 iResolution;
+uniform float iTime;
+uniform float uMode;
+uniform float uVignette;
+
+float hash(float2 p) { return fract(sin(dot(p, float2(127.1, 311.7))) * 43758.5453); }
+float noise(float2 p) {
+ float2 q=floor(p), f=fract(p); f=f*f*(3.-2.*f);
+ return mix(mix(hash(q),hash(q+float2(1,0)),f.x),mix(hash(q+float2(0,1)),hash(q+1.),f.x),f.y);
+}
+half4 main(float2 p) {
+ float2 uv=p/iResolution.xy;
+ float2 d=(uv-float2(.52,.48))*float2(1.15,1.);
+ float cloud=noise(p/280.)*.5+noise(p/81.)*.22+noise(p/14.)*.09;
+ float grain=(hash(floor(p*.72)+floor(iTime*24.)*19.7)-.5)*.058;
+ float edge=smoothstep(.20,.79,length(d));
+ float3 c=float3(.883,.880,.857)+(cloud-.4)*.085+grain;
+ c-=edge*(.10+uVignette*.72);
+ if(uMode>.5 && uMode<1.5) c=float3(.048,.049,.048)+(cloud-.4)*.021+grain*.20;
+ if(uMode>1.5) c=float3(.91,.105,.065)+(cloud-.4)*.09+grain*.7-edge*.10;
+ return half4(c,1);
+}
diff --git a/examples/made-of-motion/src/shaders/performance.sksl b/examples/made-of-motion/src/shaders/performance.sksl
new file mode 100644
index 00000000..fd193cdf
--- /dev/null
+++ b/examples/made-of-motion/src/shaders/performance.sksl
@@ -0,0 +1,39 @@
+uniform shader uSource;
+uniform int iFrame;
+float box(float2 p,float4 r) {
+ float2 d=max(r.xy-p,p-r.zw);
+ return 1.-smoothstep(-3.,5.,max(d.x,d.y));
+}
+half4 boundary(float2 p) {
+ return (uSource.eval(p+float2(5,0))+uSource.eval(p-float2(5,0))
+ +uSource.eval(p+float2(0,5))+uSource.eval(p-float2(0,5)))*.25;
+}
+half4 main(float2 p) {
+ half4 c=uSource.eval(p);
+ // The portrait is the only remaining live-action plate. The hand now has
+ // an isolated thermal field and the four-frame icon flash is procedural.
+ if(iFrame<9) {
+ // The first caption is heavily defocused. Its wide halo needs a wider
+ // matte; preserve chromatic performance pixels crossing that region.
+ float2 d=max(float2(150,466)-p,p-float2(782,610));
+ float a=1.-smoothstep(-12.,18.,max(d.x,d.y));
+ float chroma=max(c.r,max(c.g,c.b))-min(c.r,min(c.g,c.b));
+ a*=1.-smoothstep(.08,.18,chroma);
+ return mix(c,uSource.eval(float2(105.+p.x*.04,p.y)),a);
+ }
+ float4 r=float4(166,482,595,598);
+ float2 uv=clamp((p-r.xy)/(r.zw-r.xy),0.,1.);
+ // Boundary-constrained interpolation follows the light sweep. Copying an
+ // upper strip made a dark rectangle when the portrait turned white.
+ half4 vertical=mix(boundary(float2(p.x,r.y)),boundary(float2(p.x,r.w)),uv.y);
+ half4 horizontal=mix(boundary(float2(r.x,p.y)),boundary(float2(r.z,p.y)),uv.x);
+ half4 corners=mix(mix(boundary(r.xy),boundary(r.zy),uv.x),
+ mix(boundary(r.xw),boundary(r.zw),uv.x),uv.y);
+ half4 grain=uSource.eval(p-float2(0,137))-boundary(p-float2(0,137));
+ float a=box(p,float4(181,499,579,578));
+ c=mix(c,clamp(vertical+horizontal-corners+grain*.7,0.,1.),a);
+ // The source caret is a separate element farther right than its caption.
+ float caret=box(p,float4(630,505,662,570));
+ c=mix(c,uSource.eval(p-float2(27,0)),caret);
+ return c;
+}
diff --git a/examples/made-of-motion/src/shaders/print.sksl b/examples/made-of-motion/src/shaders/print.sksl
new file mode 100644
index 00000000..aa5f7e86
--- /dev/null
+++ b/examples/made-of-motion/src/shaders/print.sksl
@@ -0,0 +1,8 @@
+uniform float iTime;
+uniform float uStrength;
+float hash(float2 p) { return fract(sin(dot(p,float2(17.13,93.17)))*47111.81); }
+half4 main(float2 p) {
+ float h=hash(floor(p*.78)+floor(iTime*24.)*float2(13,37));
+ float a=abs(h-.5)*uStrength;
+ return half4(half3(step(.5,h)*a),a);
+}
diff --git a/examples/made-of-motion/src/shaders/signal.sksl b/examples/made-of-motion/src/shaders/signal.sksl
new file mode 100644
index 00000000..555aadf7
--- /dev/null
+++ b/examples/made-of-motion/src/shaders/signal.sksl
@@ -0,0 +1,87 @@
+// Bent electric cusp photographed through paper grain and a warm optical halo.
+uniform float3 iResolution;
+uniform float iTime;
+uniform int iFrame;
+uniform float4 uPose;
+uniform float uAngle;
+uniform float uPower;
+
+float hash(float2 p) { return fract(sin(dot(p,float2(127.1,311.7)))*43758.5453); }
+float noise(float2 p) {
+ float2 q=floor(p), f=fract(p); f=f*f*(3.-2.*f);
+ return mix(mix(hash(q),hash(q+float2(1,0)),f.x),mix(hash(q+float2(0,1)),hash(q+1.),f.x),f.y);
+}
+float cusp(float2 p) {
+ float2 q=p-uPose.xy;
+ float2 radius=uPose.zw;
+ q=float2(cos(uAngle)*q.x+sin(uAngle)*q.y,-sin(uAngle)*q.x+cos(uAngle)*q.y)/radius;
+ float2 a=max(abs(q),float2(.00001));
+ float f=pow(a.x,uPower)+pow(a.y,uPower)-1.;
+ float2 gradient=uPower*pow(max(a,float2(.035)),float2(uPower-1.))/radius;
+ return f/max(length(gradient),.0002);
+}
+half4 main(float2 p) {
+ float f=float(iFrame);
+ // Tiny filament displacement is attached to the edge, not moving grain.
+ float2 warped=p+float2(noise(p/8.+float2(iTime*.4,0.))-.5,noise(p/13.)-.5)*2.;
+ float fold=clamp(f-43.,0.,1.);
+ float2 cuspPoint=float2(warped.x*mix(1.,.72,fold),535.+(warped.y-535.)*mix(1.,1.45,fold));
+ float d=cusp(cuspPoint);
+ float3 paper=float3(.896,.89,.885);
+ float2 light=(p-float2(1190.,545.))/float2(800.,1160.);
+ float illumination=exp(-dot(light,light)*1.16);
+ float3 shadow=float3(.075,.071,.074);
+ float3 c=mix(shadow,paper,smoothstep(.12,.94,illumination));
+ c-=pow(max(0.,(500.-p.y)/500.),1.3)*.14*smoothstep(300.,850.,p.x);
+ // Brown photographic shoulder surrounding the blue. The far-right field
+ // stays luminous while the upper/lower left corners fall almost to black.
+ c+=exp(-pow((p.x-350.)/170.,2.))*float3(.105,.070,.067);
+ float shoulder=exp(-abs(d)/125.)*.19;
+ c+=float3(.36,.145,.072)*shoulder;
+ float edge=exp(-abs(d)/8.5);
+ float bloom=exp(-abs(d)/26.);
+ float blue=smoothstep(4.,16.,f);
+ float3 core=mix(float3(.06,.84,.76),float3(.12,.25,.81),blue);
+ core+=float3(.02,.09,.03)*noise(p/100.);
+ float softness=mix(17.,3.2,smoothstep(2.,8.,f));
+ float inside=1.-smoothstep(-softness,softness,d);
+ float3 electric=mix(core,float3(.12,.63,.54),exp(-abs(d)/14.)*.77);
+ c=mix(c,electric,inside);
+ c+=float3(.018,.14,.105)*bloom*(1.-inside)+float3(.01,.025,.018)*edge;
+ // Measured flash/recoil exposures: the star crosses from right to left,
+ // almost vanishes in the white exposure, then gains contrast while turning.
+ float wash=f==3. ? .63 : f==4. ? .35 : f==5. ? .13 : 0.;
+ c=mix(c,float3(.885,.885,.875),wash);
+ if(f==0.) c=mix(float3(.90,.035,.028),float3(.95,.78,.17),inside);
+ if(f==1.) c=mix(float3(.86,.67,.02),float3(.80,.93,.08),inside*.83);
+ if(f==2.) c=float3(.89,.89,.88);
+ // A warm paper bloom contracts rapidly into an orange ball, then exits
+ // into the portrait. Each radius/centre is tied to a source exposure.
+ if(f>=41.) {
+ float a=clamp(f-41.,0.,1.);
+ float b=clamp(f-42.,0.,1.);
+ float e=clamp(f-43.,0.,1.);
+ float2 centre=mix(float2(810,540),float2(730,530),a);
+ centre=mix(centre,float2(610,550),b);
+ centre=mix(centre,float2(430,540),e);
+ float2 radius=mix(float2(590,650),float2(470,540),a);
+ radius=mix(radius,float2(365,445),b);
+ radius=mix(radius,float2(200,275),e);
+ float2 q=(p-centre)/radius;
+ float r=length(q);
+ float glow=exp(-pow(r,2.55)*1.55);
+ float halo=exp(-pow((r-.81)*3.8,2.));
+ float3 hot=mix(float3(.84,.61,.47),float3(.94,.40,.19),a);
+ hot=mix(hot,float3(.99,.35,.065),b);
+ hot=mix(hot,float3(.96,.22,.015),e);
+ float3 dark=float3(.045,.043,.044);
+ c=dark+(hot-dark)*glow+float3(.15,-.026,-.012)*halo;
+ float3 filament=mix(float3(.14,.075,.47),float3(.52,.012,.045),clamp((f-41.)*.5,0.,1.));
+ c=mix(c,filament*(.60+.40*exp(-abs(d)/90.)),inside*.92);
+ c+=float3(.10,.06,.042)*exp(-abs(d)/4.5);
+
+ }
+ float grain=(hash(floor(p*.73)+f*19.7)-.5)*.072;
+ c+=(noise(p/77.)-.5)*.022+grain;
+ return half4(clamp(c,0.,1.),1.);
+}
diff --git a/examples/made-of-motion/src/shaders/thermal_cut.sksl b/examples/made-of-motion/src/shaders/thermal_cut.sksl
new file mode 100644
index 00000000..e0776921
--- /dev/null
+++ b/examples/made-of-motion/src/shaders/thermal_cut.sksl
@@ -0,0 +1,18 @@
+uniform int iFrame;
+float hash(float2 p) {return fract(sin(dot(p,float2(127.1,311.7)))*43758.5453);}
+half4 main(float2 p) {
+ float f=float(iFrame);
+ float grain=hash(floor(p*.8)+f*21.3)-.5;
+ float reveal=smoothstep(.9,3.8,f);
+ float vignette=smoothstep(220.,1050.,length((p-float2(735,590))*float2(1.,.8)));
+ float3 paper=float3(.878,.875,.853)-vignette*.10;
+ float3 c=mix(float3(.044,.043,.044),paper,reveal);
+ float y=970.-f*134.;
+ float glow=exp(-pow((p.y-y)/190.,2.)-pow((p.x-690.)/580.,2.));
+ float strength=max(0.,1.-f*.36);
+ c=mix(c,float3(.93,.018,.003),glow*strength);
+ c=mix(c,float3(1.,.64,.025),pow(glow,2.6)*strength);
+ c=mix(c,float3(1.,.94,.70),pow(glow,7.)*strength);
+ c+=grain*mix(.014,.052,reveal);
+ return half4(c,1);
+}
diff --git a/examples/made-of-motion/src/vector_ink.rs b/examples/made-of-motion/src/vector_ink.rs
new file mode 100644
index 00000000..692bfa70
--- /dev/null
+++ b/examples/made-of-motion/src/vector_ink.rs
@@ -0,0 +1,130 @@
+//! Per-exposure vector contours, measured at the reference's native cadence.
+//! Soft ink is a stack of translucent outlines, not an image or video sample.
+
+use std::io::Read;
+
+use fframes::{Frame, Svgr, Transform, animation::Easing};
+use flate2::read::GzDecoder;
+
+use crate::{flight::Letter, ink_capture};
+
+const PIGMENTS: [&str; 11] = [
+ "#0a0907", "#40220f", "#c91c14", "#fffbea", "#ff2414", "#ffd155", "#c91c14", "#c91c14",
+ "#c91c14", "#c91c14", "#b91613",
+];
+
+#[derive(Debug)]
+pub(super) struct VectorInk {
+ frames: Vec<Svgr<'static>>,
+ letter_marks: Vec<[Svgr<'static>; 4]>,
+}
+
+impl VectorInk {
+ pub(super) fn new() -> Self {
+ let mut frames: Vec<Vec<Svgr<'static>>> = (0..489).map(|_| Vec::new()).collect();
+ let mut marks: Vec<[Vec<Svgr<'static>>; 4]> = (0..489)
+ .map(|_| std::array::from_fn(|_| Vec::new()))
+ .collect();
+ // Decompress the vector text once; no source pixels are embedded.
+ // Frame rendering only clones the prepared SVG tree.
+ let mut source = String::new();
+ for chunk in [
+ include_bytes!("vector_ink/000.paths.gz").as_slice(),
+ include_bytes!("vector_ink/100.paths.gz").as_slice(),
+ include_bytes!("vector_ink/200.paths.gz").as_slice(),
+ include_bytes!("vector_ink/300.paths.gz").as_slice(),
+ include_bytes!("vector_ink/400.paths.gz").as_slice(),
+ ] {
+ GzDecoder::new(chunk)
+ .read_to_string(&mut source)
+ .expect("the generated vector ink archive must contain valid UTF-8 paths");
+ }
+ for line in source.lines() {
+ let mut fields = line.splitn(4, '|');
+ let Some(index) = fields.next().and_then(|value| value.parse::<usize>().ok()) else {
+ continue;
+ };
+ let Some(pigment) = fields.next().and_then(|value| value.parse::<usize>().ok()) else {
+ continue;
+ };
+ let Some(color) = PIGMENTS.get(pigment) else {
+ continue;
+ };
+ let Some(opacity) = fields.next().and_then(|value| value.parse::<f32>().ok()) else {
+ continue;
+ };
+ let (Some(path), Some(frame)) = (fields.next(), frames.get_mut(index)) else {
+ continue;
+ };
+ let path = fframes::svgr!(<path d={path.to_owned()} fill={*color} fill-rule="evenodd" opacity={opacity}/>);
+ if (6..10).contains(&pigment) {
+ marks[index][pigment - 6].push(path);
+ } else {
+ frame.push(path);
+ }
+ }
+ Self {
+ frames: frames.into_iter().map(Svgr::from).collect(),
+ letter_marks: marks
+ .into_iter()
+ .map(|frame| frame.map(Svgr::from))
+ .collect(),
+ }
+ }
+
+ pub(super) fn draw(&self, frame: &Frame) -> Svgr<'static> {
+ let base = self
+ .frames
+ .get(frame.global_index)
+ .cloned()
+ .unwrap_or_default();
+ let marks = self
+ .letter_marks
+ .get(frame.global_index)
+ .cloned()
+ .unwrap_or_default();
+ fframes::svgr!(<g>{base}{marks.into_iter().collect::<Vec<_>>()}</g>)
+ }
+
+ /// Preserve source nib shapes and exposure timing through the seven brand
+ /// flights and final camera pullback. `draw` remains the unmodified trace.
+ pub(super) fn draw_signature(&self, frame: &Frame, letters: &[Letter; 7]) -> Svgr<'static> {
+ let n = frame.global_index.min(488);
+ let source =
+ ink_capture::LETTERS[(n.saturating_sub(413)).min(ink_capture::LETTERS.len() - 1)];
+ let marks = letters
+ .iter()
+ .enumerate()
+ .map(|(i, letter)| {
+ let [sx, sy] = source[i % 4];
+ let [x, y] = letter.position;
+ let shape = self.letter_marks[n][i % 4].clone();
+ fframes::svgr!(<g transform={Transform::translate(x, y)}>
+ <g transform={frame.animate(fframes::timeline!(
+ at 2.541_667 => 2.666_667,
+ animate Transform::scale(1.) => Transform::scale(2.8), Easing::EaseIn,
+ ))}>
+ <g transform={Transform::translate(-sx, -sy)}>{shape}</g>
+ </g>
+ </g>)
+ })
+ .collect::<Vec<_>>();
+ // The reference's longest, strongest red gestures are its last twelve
+ // frames. Keep them after assembly, attached to the same camera as the
+ // wordmark; only the independent black gestures leave the composition.
+ fframes::svgr!(<g>
+ <g opacity={frame.animate(fframes::timeline!(
+ at 2.541_667 => 2.708_333, animate 1.0_f32 => 0.0, Easing::EaseOut,
+ ))}>{self.frames[n].clone()}</g>
+ <g transform="translate(720 540)">
+ <g transform={frame.animate(fframes::timeline!(
+ at 2.666_667 => 2.833_333,
+ animate Transform::scale(1.) => Transform::scale(1. / 2.8),
+ Easing::CubicBezier(0.12,0.92,0.20,1.),
+ ))}>
+ <g transform="translate(-720 -540)">{marks}</g>
+ </g>
+ </g>
+ </g>)
+ }
+}
diff --git a/examples/made-of-motion/src/vector_ink/000.paths.gz b/examples/made-of-motion/src/vector_ink/000.paths.gz
new file mode 100644
index 00000000..15f43ffc
Binary files /dev/null and b/examples/made-of-motion/src/vector_ink/000.paths.gz differ
diff --git a/examples/made-of-motion/src/vector_ink/100.paths.gz b/examples/made-of-motion/src/vector_ink/100.paths.gz
new file mode 100644
index 00000000..083ccb87
Binary files /dev/null and b/examples/made-of-motion/src/vector_ink/100.paths.gz differ
diff --git a/examples/made-of-motion/src/vector_ink/200.paths.gz b/examples/made-of-motion/src/vector_ink/200.paths.gz
new file mode 100644
index 00000000..438291bf
Binary files /dev/null and b/examples/made-of-motion/src/vector_ink/200.paths.gz differ
diff --git a/examples/made-of-motion/src/vector_ink/300.paths.gz b/examples/made-of-motion/src/vector_ink/300.paths.gz
new file mode 100644
index 00000000..9e8fdaa8
Binary files /dev/null and b/examples/made-of-motion/src/vector_ink/300.paths.gz differ
diff --git a/examples/made-of-motion/src/vector_ink/400.paths.gz b/examples/made-of-motion/src/vector_ink/400.paths.gz
new file mode 100644
index 00000000..1c313021
Binary files /dev/null and b/examples/made-of-motion/src/vector_ink/400.paths.gz differ