在你的浏览器里,实时渲染。
这不是视频。Valle 的引擎编译成了 WebAssembly,正在用 WebGPU 绘制每一帧。
0 / 0
01-aurora.motion.tsx 在 GitHub 上查看 ↗
// Aurora: a slow field of light from one WGSL shader, and a serif title that comes into focus
// letter by letter. Designed at 1920 x 1080, 30 fps, 5 s.
export const composition = { width: 1920, height: 1080, fps: 30, duration: 5 };
// The fonts are Google Fonts' files through jsDelivr, at a pinned commit, under the SIL Open Font License 1.1.
export const controls = {
resources: {
Instrument: resource({
kind: "font",
default: [
"https://…/ofl/instrumentserif/InstrumentSerif-Regular.ttf",
"https://…/ofl/instrumentserif/InstrumentSerif-Italic.ttf",
],
}),
Geist: resource({
kind: "font",
default:
"https://…/ofl/geist/Geist%5Bwght%5D.ttf",
}),
GeistMono: resource({
kind: "font",
default:
"https://…/ofl/geistmono/GeistMono%5Bwght%5D.ttf",
}),
},
};
const WHITE = "#F6F2EC";
// The small mono captions at the corners.
const LABEL = { fontFamily: "GeistMono", fontSize: 20, letterSpacing: 4 };
const TITLE_SIZE = 300;
const RING = { x: 1560, y: 372, r: 178 };
// Domain-warped noise: two warps feed a third field, and each paints one colour of the light.
const AURORA = `
struct Params { time: f32, gain: f32 }
@group(2) @binding(0) var<uniform> params: Params;
fn hash(p: vec2f) -> f32 {
var q = fract(vec3f(p.x, p.y, p.x) * 0.1031);
q += dot(q, q.yzx + 33.33);
return fract((q.x + q.y) * q.z);
}
fn noise(p: vec2f) -> f32 {
let i = floor(p);
let f = fract(p);
let u = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);
return mix(
mix(hash(i), hash(i + vec2f(1.0, 0.0)), u.x),
mix(hash(i + vec2f(0.0, 1.0)), hash(i + vec2f(1.0, 1.0)), u.x),
u.y,
);
}
fn fbm(start: vec2f) -> f32 {
var p = start;
var sum = 0.0;
var amp = 0.5;
for (var i = 0; i < 5; i++) {
sum += amp * noise(p);
p = vec2f(p.x * 1.6 - p.y * 1.2, p.x * 1.2 + p.y * 1.6) + vec2f(3.1, 1.7);
amp *= 0.5;
}
return sum;
}
fn shade(input: ShaderInput) -> vec4f {
let aspect = input.size.x / input.size.y;
let p = vec2f(input.uv.x * aspect, input.uv.y) * 0.95;
let t = params.time * 0.11;
let q = vec2f(fbm(p + vec2f(0.0, t)), fbm(p + vec2f(5.2, 1.3 - t)));
let r = vec2f(
fbm(p + 2.6 * q + vec2f(1.7, 9.2) + 1.3 * t),
fbm(p + 2.6 * q + vec2f(8.3, 2.8) - 1.1 * t),
);
let f = fbm(p + 3.0 * r);
var color = mix(vec3f(0.016, 0.014, 0.05), vec3f(0.10, 0.08, 0.46), smoothstep(0.2, 0.75, f));
color = mix(color, vec3f(0.56, 0.13, 0.66), smoothstep(0.42, 0.78, q.x) * 0.85);
color = mix(color, vec3f(1.0, 0.38, 0.17), smoothstep(0.5, 0.82, r.x) * 0.9);
color += vec3f(0.04, 0.5, 0.56) * smoothstep(0.52, 0.8, r.y) * 0.4;
color += vec3f(1.0, 0.82, 0.6) * smoothstep(0.7, 0.95, r.x * f * 2.0) * 0.35;
// Darker toward the corners, so the light sits in the middle of the frame.
let d = (input.uv - vec2f(0.56, 0.56)) * vec2f(1.0, 1.25);
let vignette = 1.0 - smoothstep(0.25, 0.95, length(d));
return vec4f(color * (0.3 + 0.7 * vignette) * params.gain, 1.0);
}`;
// 60 ticks around the ring, every fifth one longer.
const TICKS = Array.from({ length: 60 }, (_, i) => {
const a = (i / 60) * Math.PI * 2;
const inner = RING.r - (i % 5 === 0 ? 22 : 12);
return {
key: `tick-${i}`,
x1: (inner * Math.cos(a)).toFixed(2),
y1: (inner * Math.sin(a)).toFixed(2),
x2: ((RING.r - 4) * Math.cos(a)).toFixed(2),
y2: ((RING.r - 4) * Math.sin(a)).toFixed(2),
major: i % 5 === 0,
};
});
// One line of the title: every letter rises into place and comes into focus after the one before.
function Line({ text, start, italic }) {
const { seconds } = useCurrentTime();
return (
<Text
split="char"
style={{
fontFamily: "Instrument",
fontStyle: italic ? "italic" : "normal",
fontSize: TITLE_SIZE,
lineHeight: 0.9,
letterSpacing: -6,
color: WHITE,
whiteSpace: "pre",
}}
perUnit={(unit) => {
const t = seconds - start - unit.index * 0.045;
const arrive = interpolate(t, [0, 1.1], [0, 1], { easing: "easeOutExpo" });
const sharp = interpolate(t, [0, 0.8], [0, 1], { easing: "easeOutCubic" });
return {
opacity: interpolate(t, [0, 0.5], [0, 1], { easing: "easeOutCubic" }),
translate: `0px ${(1 - arrive) * 90}px`,
filter: sharp < 1 ? `blur(${18 * (1 - sharp)}px)` : "none",
};
}}
>
{text}
</Text>
);
}
function Dial() {
const { seconds } = useCurrentTime();
const draw = interpolate(seconds, [1.1, 2.5], [0, 1], { easing: "easeInOutCubic" });
const ticks = interpolate(seconds, [1.5, 2.5], [0, 1], { easing: "easeOutCubic" });
const hand = -90 + 360 * (seconds / 5);
return (
<svg
className="absolute"
width={1}
height={1}
style={{ left: RING.x, top: RING.y, overflow: "visible" }}
>
<circle
r={RING.r}
fill="none"
stroke="#F6F2EC8C"
strokeWidth={1.5}
pathLength={1}
strokeDasharray="1 1"
strokeDashoffset={1 - draw}
transform="rotate(-90)"
/>
<g opacity={ticks} transform={`rotate(${seconds * 6})`}>
{TICKS.map((tick) => (
<line
key={tick.key}
x1={tick.x1}
y1={tick.y1}
x2={tick.x2}
y2={tick.y2}
stroke={tick.major ? "#F6F2ECCC" : "#F6F2EC59"}
strokeWidth={1.5}
/>
))}
</g>
<g opacity={ticks} transform={`rotate(${hand})`}>
<line x1={0} y1={0} x2={RING.r - 34} y2={0} stroke="#F6F2ECB3" strokeWidth={1.5} />
<circle cx={RING.r} cy={0} r={7} fill={WHITE} />
</g>
<circle r={4} fill={WHITE} opacity={ticks} />
</svg>
);
}
export default function Aurora() {
const { seconds } = useCurrentTime();
const gain = interpolate(seconds, [0, 1.4], [0, 1], { easing: "easeOutCubic" });
const meta = interpolate(seconds, [0.5, 1.3], [0, 1], { easing: "easeOutCubic" });
const rule = interpolate(seconds, [1.9, 2.9], [0, 1], { easing: "easeOutExpo" });
const caption = interpolate(seconds, [2.2, 3.0], [0, 1], { easing: "easeOutCubic" });
const push = 1 + 0.035 * (seconds / 5);
return (
<View className="relative h-full w-full" style={{ backgroundColor: "#05050A" }}>
<ShaderLayer
key="light"
code={AURORA}
uniforms={{ time: seconds, gain }}
style={{
position: "absolute",
left: 0,
top: 0,
width: 1920,
height: 1080,
filter: `film-grain(${Math.floor(seconds * 24)} 0.12 1.5px)`,
}}
/>
{/* A shade under the type, so the letters keep their contrast wherever the light goes. */}
<View
key="shade"
className="absolute inset-0"
style={{
backgroundImage:
"linear-gradient(200deg, #05050A00 35%, #05050A8C 100%), linear-gradient(180deg, #05050A66 0%, #05050A00 22%)",
}}
/>
<View
key="meta"
className="absolute flex justify-between"
style={{ left: 96, right: 96, top: 72, opacity: meta }}
>
<Text style={{ ...LABEL, color: "#F6F2ECB3" }}>N° 01 — AURORA</Text>
<Text
style={{
fontFamily: "GeistMono",
fontSize: 20,
letterSpacing: 4,
color: "#F6F2ECB3",
fontVariantNumeric: "tabular-nums",
}}
>
T + {formatNumber(seconds, { decimals: 2 })} S
</Text>
</View>
<Dial key="dial" />
<View
key="title"
className="absolute flex flex-col"
style={{ left: 96, top: 356, scale: push, transformOrigin: "0% 100%" }}
>
<Line key="first" text="Light, in" start={0.35} />
<Line key="second" text="motion." start={0.7} italic />
</View>
<View
key="rule"
className="absolute"
style={{
left: 100,
top: 944,
width: 1720,
height: 1.5,
backgroundColor: "#F6F2EC73",
scale: `${rule} 1`,
transformOrigin: "0% 50%",
}}
/>
<View
key="caption"
className="absolute flex justify-between"
style={{
left: 100,
right: 100,
top: 968,
opacity: caption,
translate: `0px ${(1 - caption) * 14}px`,
}}
>
<Text style={{ fontFamily: "Geist", fontSize: 26, fontWeight: 400, color: "#F6F2ECD9" }}>
Every frame is a pure function of time.
</Text>
<Text style={{ ...LABEL, color: "#F6F2EC99" }}>WGSL · 5 OCTAVES · 2 WARPS</Text>
</View>
</View>
);
} 02-variable.motion.tsx 在 GitHub 上查看 ↗
// Variable: one word in a variable font, a wave of weight and width running through its
// letters and colouring them, until every letter locks at its heaviest and widest.
// Designed at 1920 x 1080, 30 fps, 5 s.
export const composition = { width: 1920, height: 1080, fps: 30, duration: 5 };
// The fonts are Google Fonts' files through jsDelivr, at a pinned commit, under the SIL Open Font License 1.1.
export const controls = {
resources: {
Archivo: resource({
kind: "font",
default:
"https://…/ofl/archivo/Archivo%5Bwdth,wght%5D.ttf",
}),
GeistMono: resource({
kind: "font",
default:
"https://…/ofl/geistmono/GeistMono%5Bwght%5D.ttf",
}),
},
};
const NIGHT = "#0B0A0D";
const CREAM = "#F4EEE4";
const ORANGE = "#FF9F45";
// The small mono captions at the corners.
const LABEL = { fontFamily: "GeistMono", fontSize: 20, letterSpacing: 4 };
const WORD = "RHYTHM";
const LETTERS = WORD.split("").map((letter, index) => ({ key: `letter-${index}`, letter, index }));
// The curve under the word: the wave itself, drawn in dots, one large dot a letter.
const CURVE = { left: 96, width: 1728, top: 742, height: 104 };
const DOTS = Array.from({ length: 109 }, (_, i) => ({ key: `dot-${i}`, u: (i / 108) * 5 }));
// How heavy and wide the letter at `u` is, from 0 to 1: flat as it arrives, then the wave,
// then locked at 1.
function level(seconds, u) {
const depth = interpolate(seconds, [0.6, 1.7], [0, 1], { easing: "easeInOutSine" });
const lock = interpolate(seconds, [3.6, 4.25], [0, 1], { easing: "easeInOutCubic" });
const wave = (0.5 + 0.5 * Math.sin(seconds * 2.4 - u * 0.72)) * depth;
return wave + (1 - wave) * lock;
}
// Light and narrow is cool and dim; heavy and wide is warm.
function tint(amount) {
return interpolate(amount, [0, 0.5, 1], ["#4B4F8C", CREAM, ORANGE], { colorSpace: "oklch" });
}
export default function Variable() {
const { seconds } = useCurrentTime();
const meta = interpolate(seconds, [0.9, 1.7], [0, 1], { easing: "easeOutCubic" });
const lock = interpolate(seconds, [3.6, 4.25], [0, 1], { easing: "easeInOutCubic" });
const locked = interpolate(seconds, [4.15, 4.5], [0, 1], { easing: "easeOutCubic" });
const first = level(seconds, 0);
const dot = spring(seconds - 1.4, { duration: 0.5, bounce: 0.4 });
return (
<View className="relative h-full w-full" style={{ backgroundColor: NIGHT }}>
<View
key="glow"
className="absolute inset-0"
style={{
backgroundImage:
"radial-gradient(ellipse 980px 520px at 960px 430px, #3A1D5C80 0%, #0B0A0D00 100%)",
}}
/>
<View
key="warmth"
className="absolute inset-0"
style={{
opacity: lock,
backgroundImage:
"radial-gradient(ellipse 1100px 460px at 960px 430px, #FF7A2E3D 0%, #0B0A0D00 100%)",
}}
/>
<View
key="word"
className="absolute flex justify-center"
style={{
left: 0,
top: 236,
width: 1920,
height: 400,
filter: `bloom(44px ${0.1 + 0.12 * lock} 0.62)`,
}}
>
<Text
split="char"
style={{
fontFamily: "Archivo",
fontSize: 288,
lineHeight: "400px",
whiteSpace: "pre",
color: CREAM,
}}
perUnit={(unit) => {
const amount = level(seconds, unit.index);
const rise = interpolate(
seconds,
[0.1 + unit.index * 0.07, 1.0 + unit.index * 0.07],
[0, 1],
{ easing: "easeOutExpo" },
);
return {
fontVariationSettings: `"wght" ${100 + 800 * amount}, "wdth" ${62 + 63 * amount}`,
color: tint(amount),
opacity: rise,
translate: `0px ${(1 - rise) * 150}px`,
};
}}
>
{WORD}
</Text>
</View>
<svg
key="curve"
className="absolute inset-0"
width={1920}
height={1080}
style={{ opacity: meta }}
>
<line
x1={CURVE.left}
y1={CURVE.top}
x2={CURVE.left + CURVE.width}
y2={CURVE.top}
stroke="#F4EEE41F"
strokeWidth={1.5}
/>
<line
x1={CURVE.left}
y1={CURVE.top + CURVE.height}
x2={CURVE.left + CURVE.width}
y2={CURVE.top + CURVE.height}
stroke="#F4EEE41F"
strokeWidth={1.5}
/>
{DOTS.map((point) => (
<circle
key={point.key}
cx={CURVE.left + (point.u / 5) * CURVE.width}
cy={CURVE.top + (1 - level(seconds, point.u)) * CURVE.height}
r={2.4}
fill="#F4EEE466"
/>
))}
{LETTERS.map((item) => {
const amount = level(seconds, item.index);
const x = CURVE.left + (item.index / 5) * CURVE.width;
const y = CURVE.top + (1 - amount) * CURVE.height;
return (
<g key={item.key}>
<line
x1={x}
y1={y}
x2={x}
y2={CURVE.top + CURVE.height}
stroke={tint(amount)}
strokeWidth={1.5}
opacity={0.5}
/>
<circle cx={x} cy={y} r={9} fill={tint(amount)} />
</g>
);
})}
</svg>
{LETTERS.map((item) => (
<Text
key={item.key}
className="absolute"
style={{
...LABEL,
left: CURVE.left + (item.index / 5) * CURVE.width - 30,
top: CURVE.top + CURVE.height + 22,
width: 60,
textAlign: "center",
letterSpacing: 0,
color: "#F4EEE499",
opacity: meta,
}}
>
{item.letter}
</Text>
))}
<View
key="head"
className="absolute flex justify-between"
style={{ left: 96, right: 96, top: 72, opacity: meta }}
>
<Text style={{ ...LABEL, color: CREAM }}>N° 02 — VARIABLE</Text>
<Text style={{ ...LABEL, color: CREAM }}>ONE FONT FILE · TWO AXES</Text>
</View>
<View
key="foot"
className="absolute flex items-center justify-between"
style={{ left: 96, right: 96, bottom: 64, opacity: meta }}
>
<View className="flex items-center" style={{ gap: 16 }}>
<View
style={{
width: 16,
height: 16,
borderRadius: 8,
backgroundColor: tint(first),
scale: dot,
}}
/>
<Text style={{ ...LABEL, color: CREAM, fontVariantNumeric: "tabular-nums" }}>
WGHT {padNumber(100 + 800 * first, { width: 3 })} · WDTH{" "}
{padNumber(62 + 63 * first, { width: 3 })}
</Text>
<Text style={{ ...LABEL, color: ORANGE, opacity: locked }}>LOCKED</Text>
</View>
<Text style={{ ...LABEL, color: CREAM }}>ARCHIVO · 100—900 · 62—125</Text>
</View>
</View>
);
} 03-liquid.motion.tsx 在 GitHub 上查看 ↗
// Liquid: a word pools out of one soft mass, and drops drift through its letters, merging and
// parting. A luminance <Mask> whose source is blurred and then given hard contrast.
// Designed at 1920 x 1080, 30 fps, 5 s.
export const composition = { width: 1920, height: 1080, fps: 30, duration: 5 };
// The fonts are Google Fonts' files through jsDelivr, at a pinned commit, under the SIL Open Font License 1.1.
export const controls = {
resources: {
Instrument: resource({
kind: "font",
default: [
"https://…/ofl/instrumentserif/InstrumentSerif-Regular.ttf",
"https://…/ofl/instrumentserif/InstrumentSerif-Italic.ttf",
],
}),
Geist: resource({
kind: "font",
default:
"https://…/ofl/geist/Geist%5Bwght%5D.ttf",
}),
GeistMono: resource({
kind: "font",
default:
"https://…/ofl/geistmono/GeistMono%5Bwght%5D.ttf",
}),
},
};
const BLUE = "#1B2CF2";
const CREAM = "#FFF4E6";
// The small mono captions at the corners.
const LABEL = { fontFamily: "GeistMono", fontSize: 20, letterSpacing: 4 };
const CENTER = { x: 960, y: 500 };
// Drops on their own ellipses, all wider and taller than the word, so they graze its edges and
// never cover a letter: radius, the ellipse, turns a second and a phase.
const DROPS = [
{ r: 66, rx: 790, ry: 262, speed: 0.11, phase: 0.3 },
{ r: 46, rx: 700, ry: 236, speed: -0.16, phase: 1.9 },
{ r: 78, rx: 850, ry: 286, speed: 0.08, phase: 3.4 },
{ r: 34, rx: 680, ry: 222, speed: 0.21, phase: 4.6 },
{ r: 54, rx: 740, ry: 250, speed: -0.13, phase: 5.5 },
{ r: 28, rx: 690, ry: 214, speed: -0.24, phase: 2.6 },
{ r: 40, rx: 880, ry: 300, speed: 0.14, phase: 0.9 },
].map((drop, index) => ({ ...drop, key: `drop-${index}`, delay: 0.25 + index * 0.09 }));
// White on black, blurred and then pushed to hard contrast: shapes that come near each other join.
function Field() {
const { seconds } = useCurrentTime();
const blur = interpolate(seconds, [0, 1.9], [72, 11], { easing: "easeOutQuart" });
const grow = interpolate(seconds, [0, 1.9], [0.82, 1], { easing: "easeOutQuart" });
return (
<View
className="absolute"
style={{
left: 0,
top: 0,
width: 1920,
height: 1080,
backgroundColor: "#000000",
filter: `blur(${blur}px) contrast(60)`,
}}
>
<View
key="word"
className="absolute flex items-center justify-center"
style={{ left: 0, top: CENTER.y - 320, width: 1920, height: 640, scale: grow }}
>
<Text
style={{
fontFamily: "Geist",
fontWeight: 900,
fontSize: 560,
lineHeight: 1,
letterSpacing: -22,
color: "#FFFFFF",
}}
>
melt
</Text>
</View>
{DROPS.map((drop) => {
const a = drop.phase + seconds * drop.speed * Math.PI * 2;
const pop = spring(seconds - drop.delay, { duration: 0.9, bounce: 0.2 });
return (
<View
key={drop.key}
className="absolute"
style={{
left: CENTER.x - drop.r,
top: CENTER.y - drop.r,
width: drop.r * 2,
height: drop.r * 2,
borderRadius: drop.r,
backgroundColor: "#FFFFFF",
translate: `${drop.rx * Math.cos(a)}px ${drop.ry * Math.sin(a)}px`,
scale: pop,
}}
/>
);
})}
</View>
);
}
export default function Liquid() {
const { seconds } = useCurrentTime();
const meta = interpolate(seconds, [0.8, 1.6], [0, 1], { easing: "easeOutCubic" });
const caption = interpolate(seconds, [1.7, 2.5], [0, 1], { easing: "easeOutCubic" });
const blur = interpolate(seconds, [0, 1.9], [72, 11], { easing: "easeOutQuart" });
const turn = 110 + 40 * Math.sin(seconds * 0.7);
return (
<View className="relative h-full w-full" style={{ backgroundColor: BLUE }}>
{/* A lighter pool behind the word, so the blue is not flat. */}
<View
key="pool"
className="absolute inset-0"
style={{
backgroundImage:
"radial-gradient(ellipse 70% 60% at 50% 46%, #3D55FF 0%, #1B2CF200 70%), linear-gradient(180deg, #1B2CF200 60%, #0E1AB0 100%)",
}}
/>
<Mask
key="liquid"
mode="luminance"
className="absolute"
style={{
left: 0,
top: 0,
width: 1920,
height: 1080,
filter: "drop-shadow(0px 26px 34px #070F8A8C)",
}}
source={<Field />}
>
<View
className="absolute inset-0"
style={{
backgroundImage: `linear-gradient(${turn}deg in oklch, #FFFFFF 18%, ${CREAM} 42%, #FFC2A1 68%, #FF7A4D 92%)`,
filter: "film-grain(7 0.1 1.5px)",
}}
/>
</Mask>
<View
key="head"
className="absolute flex justify-between"
style={{ left: 96, right: 96, top: 72, opacity: meta }}
>
<Text style={{ ...LABEL, color: CREAM }}>N° 03 — LIQUID</Text>
<Text
style={{
fontFamily: "GeistMono",
fontSize: 20,
letterSpacing: 4,
color: CREAM,
fontVariantNumeric: "tabular-nums",
}}
>
BLUR {formatNumber(blur, { decimals: 1 })} PX · CONTRAST 60
</Text>
</View>
<View
key="foot"
className="absolute flex items-end justify-between"
style={{
left: 96,
right: 96,
bottom: 68,
opacity: caption,
translate: `0px ${(1 - caption) * 16}px`,
}}
>
<Text
style={{
fontFamily: "Instrument",
fontStyle: "italic",
fontSize: 54,
lineHeight: 1,
color: CREAM,
}}
>
Letters that pool, merge and part.
</Text>
<Text style={{ ...LABEL, color: CREAM }}>ONE MASK · SEVEN DROPS</Text>
</View>
</View>
);
} 04-bloom.motion.tsx 在 GitHub 上查看 ↗
// Bloom: nine hundred seeds on one spiral. The angle between one seed and the next drifts toward
// the golden angle, and the arms of the spiral rearrange until the seeds pack evenly.
// Designed at 1920 x 1080, 30 fps, 5 s.
export const composition = { width: 1920, height: 1080, fps: 30, duration: 5 };
// The fonts are Google Fonts' files through jsDelivr, at a pinned commit, under the SIL Open Font License 1.1.
export const controls = {
resources: {
Instrument: resource({
kind: "font",
default: [
"https://…/ofl/instrumentserif/InstrumentSerif-Regular.ttf",
"https://…/ofl/instrumentserif/InstrumentSerif-Italic.ttf",
],
}),
GeistMono: resource({
kind: "font",
default:
"https://…/ofl/geistmono/GeistMono%5Bwght%5D.ttf",
}),
},
};
const NIGHT = "#0B0A0D";
const CREAM = "#F4EEE4";
// The small mono captions at the corners.
const LABEL = { fontFamily: "GeistMono", fontSize: 20, letterSpacing: 4 };
const CENTER = { x: 1180, y: 540 };
const RADIUS = 452;
const COUNT = 900;
const GOLDEN = 137.50776;
// Each seed's distance, size and colour are fixed; only its angle and its swell follow the time.
const SEEDS = Array.from({ length: COUNT }, (_, i) => {
const u = (i + 0.5) / COUNT;
return {
key: `seed-${i}`,
index: i,
distance: RADIUS * Math.sqrt(u),
size: 3 + 5 * Math.sqrt(u),
delay: 0.1 + 1.1 * u,
color: interpolate(u, [0, 0.3, 0.62, 1], ["#FFE9A8", "#FF9F45", "#F2416B", "#6B3BFF"], {
colorSpace: "oklch",
}),
};
});
export default function Bloom() {
const { seconds } = useCurrentTime();
const angle = interpolate(seconds, [0.4, 4.1], [GOLDEN - 0.62, GOLDEN], {
easing: "easeInOutCubic",
});
const turn = seconds * 5;
const meta = interpolate(seconds, [0.6, 1.4], [0, 1], { easing: "easeOutCubic" });
const title = interpolate(seconds, [0.9, 1.9], [0, 1], { easing: "easeOutCubic" });
const settled = interpolate(seconds, [4.0, 4.5], [0, 1], { easing: "easeOutCubic" });
const ring = interpolate(seconds, [0.3, 1.8], [0, 1], { easing: "easeInOutCubic" });
return (
<View className="relative h-full w-full" style={{ backgroundColor: NIGHT }}>
<View
key="glow"
className="absolute inset-0"
style={{
backgroundImage: `radial-gradient(circle 620px at ${CENTER.x}px ${CENTER.y}px, #3A1D5C66 0%, #0B0A0D00 100%)`,
}}
/>
<svg
key="field"
className="absolute inset-0"
width={1920}
height={1080}
style={{ filter: "bloom(26px 0.55 0.45)" }}
>
<circle
cx={CENTER.x}
cy={CENTER.y}
r={RADIUS + 34}
fill="none"
stroke="#F4EEE433"
strokeWidth={1.5}
pathLength={1}
strokeDasharray="1 1"
strokeDashoffset={1 - ring}
transform={`rotate(-90 ${CENTER.x} ${CENTER.y})`}
/>
<g transform={`translate(${CENTER.x} ${CENTER.y}) rotate(${turn})`}>
{SEEDS.map((seed) => {
const a = (seed.index * angle * Math.PI) / 180;
const born = interpolate(seconds, [seed.delay, seed.delay + 0.7], [0, 1], {
easing: "easeOutCubic",
});
// A swell that runs outward from the middle.
const swell = 0.8 + 0.2 * Math.sin(seconds * 2.6 - seed.distance * 0.016);
return (
<circle
key={seed.key}
cx={seed.distance * Math.cos(a)}
cy={seed.distance * Math.sin(a)}
r={seed.size * born * swell}
fill={seed.color}
/>
);
})}
</g>
</svg>
<View
key="head"
className="absolute flex justify-between"
style={{ left: 96, right: 96, top: 72, opacity: meta }}
>
<Text style={{ ...LABEL, color: CREAM }}>N° 04 — BLOOM</Text>
<Text style={{ ...LABEL, color: CREAM }}>900 SEEDS</Text>
</View>
<View
key="title"
className="absolute flex flex-col"
style={{
left: 96,
top: 318,
width: 560,
opacity: title,
translate: `0px ${(1 - title) * 24}px`,
}}
>
<Text
style={{
fontFamily: "Instrument",
fontSize: 148,
lineHeight: 0.95,
letterSpacing: -3,
color: CREAM,
}}
>
One angle,
</Text>
<Text
style={{
fontFamily: "Instrument",
fontStyle: "italic",
fontSize: 148,
lineHeight: 0.95,
letterSpacing: -3,
color: "#FF9F45",
}}
>
repeated.
</Text>
<View style={{ marginTop: 56, width: 420, height: 1.5, backgroundColor: "#F4EEE44D" }} />
<Text
style={{
marginTop: 28,
fontFamily: "GeistMono",
fontSize: 20,
letterSpacing: 4,
color: "#F4EEE499",
}}
>
ANGLE BETWEEN SEEDS
</Text>
<View className="flex items-baseline" style={{ marginTop: 10, gap: 20 }}>
<Text
style={{
fontFamily: "GeistMono",
fontSize: 64,
fontWeight: 300,
letterSpacing: -1,
color: CREAM,
fontVariantNumeric: "tabular-nums",
}}
>
{formatNumber(angle, { decimals: 3 })}°
</Text>
<Text
style={{
fontFamily: "GeistMono",
fontSize: 20,
letterSpacing: 4,
color: "#FF9F45",
opacity: settled,
}}
>
GOLDEN
</Text>
</View>
</View>
</View>
);
} 05-carousel.motion.tsx 在 GitHub 上查看 ↗
// Carousel: sixteen cards in a ring, each a small picture of its own. The camera starts close
// on one card, pulls back until the whole ring turns in perspective over its reflection, and
// the ring stops with a card facing the viewer. CSS 3D only.
// Designed at 1920 x 1080, 30 fps, 5 s.
export const composition = { width: 1920, height: 1080, fps: 30, duration: 5 };
// The fonts are Google Fonts' files through jsDelivr, at a pinned commit, under the SIL Open Font License 1.1.
export const controls = {
resources: {
Instrument: resource({
kind: "font",
default: [
"https://…/ofl/instrumentserif/InstrumentSerif-Regular.ttf",
"https://…/ofl/instrumentserif/InstrumentSerif-Italic.ttf",
],
}),
GeistMono: resource({
kind: "font",
default:
"https://…/ofl/geistmono/GeistMono%5Bwght%5D.ttf",
}),
},
};
const NIGHT = "#0B0A0D";
const CREAM = "#F4EEE4";
const ORANGE = "#FF9F45";
// The small mono captions at the corners.
const LABEL = { fontFamily: "GeistMono", fontSize: 20, letterSpacing: 4 };
const COUNT = 16;
const STEP = 360 / COUNT;
const PANEL = { width: 300, height: 430 };
const RING = 820;
const CENTER = { x: 960, y: 412 };
const PERSPECTIVE = 2600;
// Six kinds of card, going around the ring: the ground it is painted on, the colour its back
// and its reflection take, and the colour of its captions.
const KINDS = [
{
name: "LIGHT",
tint: "#7A3BFF",
ink: CREAM,
ground:
"radial-gradient(circle 210px at 236px 120px, #FF9F45 0%, #FF9F4500 100%), radial-gradient(circle 260px at 50px 330px, #7A3BFF 0%, #7A3BFF00 100%), linear-gradient(#150B33, #150B33)",
},
{ name: "TYPE", tint: "#F4EEE4", ink: "#16140F", ground: "linear-gradient(#F4EEE4, #E6DFD2)" },
{ name: "DATA", tint: "#FF9F45", ink: CREAM, ground: "linear-gradient(#1B1820, #121016)" },
{ name: "LIQUID", tint: "#1B2CF2", ink: CREAM, ground: "linear-gradient(#2536FF, #1420C4)" },
{ name: "SEEDS", tint: "#F2416B", ink: CREAM, ground: "linear-gradient(#17111C, #0B0A0D)" },
{ name: "CUT", tint: "#22C7A9", ink: CREAM, ground: "linear-gradient(#10201F, #0C1415)" },
];
const PANELS = Array.from({ length: COUNT }, (_, i) => ({
key: `panel-${i}`,
index: i,
kind: i % KINDS.length,
number: String(i + 1).padStart(2, "0"),
}));
const BARS = [0.34, 0.52, 0.44, 0.7, 0.62, 0.86, 1].map((value, i) => ({
key: `bar-${i}`,
value,
i,
}));
const DROPS = [
{ key: "a", x: 78, y: 150, size: 150 },
{ key: "b", x: 176, y: 206, size: 104 },
{ key: "c", x: 120, y: 268, size: 82 },
{ key: "d", x: 226, y: 122, size: 44 },
{ key: "e", x: 62, y: 322, size: 30 },
];
const SEEDS = Array.from({ length: 120 }, (_, i) => {
const u = (i + 0.5) / 120;
const a = (i * 137.50776 * Math.PI) / 180;
return {
key: `seed-${i}`,
x: 150 + 112 * Math.sqrt(u) * Math.cos(a),
y: 212 + 112 * Math.sqrt(u) * Math.sin(a),
r: 2 + 3.4 * Math.sqrt(u),
color: interpolate(u, [0, 0.4, 1], ["#FFE9A8", "#FF9F45", "#F2416B"], { colorSpace: "oklch" }),
};
});
const CLIPS = [
{ key: "a", row: 0, x: 0, w: 96, color: "#22C7A9" },
{ key: "b", row: 0, x: 104, w: 152, color: "#17907B" },
{ key: "c", row: 1, x: 40, w: 128, color: "#FF9F45" },
{ key: "d", row: 1, x: 176, w: 80, color: "#C9742A" },
{ key: "e", row: 2, x: 0, w: 60, color: "#7A3BFF" },
{ key: "f", row: 2, x: 68, w: 188, color: "#5B2CC4" },
{ key: "g", row: 3, x: 20, w: 216, color: "#F4EEE44D" },
];
// What a card shows, by its kind: fixed pictures, drawn once.
function Art({ kind }) {
if (kind === 0) {
return (
<Text
className="absolute"
style={{
left: 22,
top: 262,
fontFamily: "Instrument",
fontStyle: "italic",
fontSize: 104,
lineHeight: 1,
letterSpacing: -2,
color: CREAM,
}}
>
Light
</Text>
);
}
if (kind === 1) {
return (
<Text
className="absolute"
style={{
left: 0,
top: 96,
width: PANEL.width,
textAlign: "center",
fontFamily: "Instrument",
fontSize: 232,
lineHeight: 1,
letterSpacing: -8,
color: "#16140F",
}}
>
A<Span style={{ fontStyle: "italic", color: "#F03A17" }}>g</Span>
</Text>
);
}
if (kind === 2) {
return (
<svg className="absolute" style={{ left: 22, top: 110 }} width={256} height={240}>
{BARS.map((bar) => (
<rect
key={bar.key}
x={bar.i * 37}
y={232 - 216 * bar.value}
width={26}
height={216 * bar.value}
rx={5}
fill={interpolate(bar.value, [0.3, 1], ["#6B3BFF", "#FF9F45"], { colorSpace: "oklch" })}
/>
))}
<line x1={0} y1={236} x2={256} y2={236} stroke="#F4EEE44D" strokeWidth={1.5} />
</svg>
);
}
if (kind === 3) {
return (
<View className="absolute inset-0">
{DROPS.map((drop) => (
<View
key={drop.key}
className="absolute"
style={{
left: drop.x - drop.size / 2,
top: drop.y - drop.size / 2,
width: drop.size,
height: drop.size,
borderRadius: drop.size / 2,
backgroundImage: "linear-gradient(160deg, #FFF4E6, #FFC9A3)",
}}
/>
))}
</View>
);
}
if (kind === 4) {
return (
<svg className="absolute inset-0" width={PANEL.width} height={PANEL.height}>
{SEEDS.map((seed) => (
<circle key={seed.key} cx={seed.x} cy={seed.y} r={seed.r} fill={seed.color} />
))}
</svg>
);
}
return (
<svg className="absolute" style={{ left: 22, top: 128 }} width={256} height={210}>
{CLIPS.map((clip) => (
<rect
key={clip.key}
x={clip.x}
y={clip.row * 50}
width={clip.w}
height={38}
rx={8}
fill={clip.color}
/>
))}
<line x1={150} y1={-6} x2={150} y2={204} stroke={CREAM} strokeWidth={2} />
<circle cx={150} cy={-2} r={6} fill={CREAM} />
</svg>
);
}
// How far the ring has turned: slowly, from card 04 at the front to card 01, so that a card
// crosses the picture by a few pixels a frame.
function spin(seconds) {
return interpolate(seconds, [0.2, 4.4], [-3 * STEP, 0], { easing: "easeInOutSine" });
}
function Panel({ panel }) {
const { seconds } = useCurrentTime();
const kind = KINDS[panel.kind];
const turn = panel.index * STEP + spin(seconds);
// 1 where the face looks at the viewer, -1 where its back does.
const facing = Math.cos((turn * Math.PI) / 180);
const shade = interpolate(facing, [0, 1], [0.6, 0]);
// The card the ring stops on steps out of it.
const lift = panel.index === 0 ? spring(seconds - 4.3, { duration: 0.6, bounce: 0.25 }) : 0;
return (
<View
className="absolute"
style={{
left: CENTER.x - PANEL.width / 2,
top: CENTER.y - PANEL.height / 2,
width: PANEL.width,
height: PANEL.height,
transformStyle: "preserve-3d",
transform: `rotateY(${turn}deg) translateZ(${RING + 50 * lift}px)`,
}}
>
<View
key="front"
className="absolute inset-0 overflow-hidden"
style={{
borderRadius: 22,
backgroundImage: kind.ground,
backfaceVisibility: "hidden",
}}
>
<Art kind={panel.kind} />
<Text
className="absolute"
style={{
left: 22,
top: 22,
fontFamily: "GeistMono",
fontSize: 14,
letterSpacing: 3,
color: kind.ink,
}}
>
{kind.name}
</Text>
<Text
className="absolute"
style={{
right: 22,
bottom: 20,
fontFamily: "GeistMono",
fontSize: 14,
letterSpacing: 3,
color: kind.ink,
opacity: 0.7,
}}
>
{panel.number} / {COUNT}
</Text>
<View
key="shade"
className="absolute inset-0"
style={{ backgroundColor: NIGHT, opacity: shade }}
/>
</View>
<View
key="back"
className="absolute inset-0 overflow-hidden"
style={{
borderRadius: 22,
backgroundImage: kind.ground,
border: "1.5px solid #F4EEE433",
backfaceVisibility: "hidden",
transform: "rotateY(180deg)",
}}
>
<View
key="shade"
className="absolute inset-0"
style={{
backgroundColor: NIGHT,
opacity: interpolate(facing, [-1, 0], [0.74, 0.86]),
}}
/>
</View>
</View>
);
}
// A card's reflection in the floor: its colour only, mirrored about its foot and fading away.
// A gradient, not a mask, and the backs are dimmed, not blurred: sixteen of either is most of
// what a frame costs.
function Reflection({ panel }) {
const { seconds } = useCurrentTime();
const kind = KINDS[panel.kind];
const turn = panel.index * STEP + spin(seconds);
const facing = Math.cos((turn * Math.PI) / 180);
return (
<View
className="absolute"
style={{
left: CENTER.x - PANEL.width / 2,
top: CENTER.y - PANEL.height / 2,
width: PANEL.width,
height: PANEL.height,
borderRadius: 22,
backgroundImage: `linear-gradient(to top, ${kind.tint} 0%, ${kind.tint}00 48%)`,
opacity: interpolate(facing, [-1, 1], [0.04, 0.22]),
transform: `rotateY(${turn}deg) translateZ(${RING}px) translateY(${PANEL.height + 14}px) scaleY(-1)`,
}}
/>
);
}
export default function Carousel() {
const { seconds } = useCurrentTime();
// The camera: close on one card, then back and a little above.
const push = interpolate(seconds, [0.2, 3.0], [1040, 0], { easing: "easeInOutSine" });
const tilt = interpolate(seconds, [0.4, 3.2], [0, -11], { easing: "easeInOutSine" });
const meta = interpolate(seconds, [1.9, 2.7], [0, 1], { easing: "easeOutCubic" });
const title = interpolate(seconds, [2.9, 3.8], [0, 1], { easing: "easeOutCubic" });
const pool = interpolate(seconds, [1.0, 2.8], [0, 1], { easing: "easeOutCubic" });
return (
<View className="relative h-full w-full" style={{ backgroundColor: NIGHT }}>
<View
key="glow"
className="absolute inset-0"
style={{
backgroundImage:
"radial-gradient(ellipse 1100px 560px at 960px 400px, #3A1D5C73 0%, #0B0A0D00 100%)",
}}
/>
<View
key="pool"
className="absolute"
style={{
left: 60,
top: 600,
width: 1800,
height: 420,
opacity: pool,
backgroundImage: "radial-gradient(ellipse at center, #6B3BFF38 0%, #0B0A0D00 66%)",
}}
/>
<View
key="stage"
className="absolute"
style={{
left: 0,
top: 0,
width: 1920,
height: 1080,
perspective: PERSPECTIVE,
perspectiveOrigin: "960px 392px",
}}
>
<View
key="ring"
className="absolute"
style={{
left: 0,
top: 0,
width: 1920,
height: 1080,
transformStyle: "preserve-3d",
transformOrigin: `${CENTER.x}px ${CENTER.y}px`,
transform: `translateZ(${push}px) rotateX(${tilt}deg)`,
}}
>
{PANELS.map((panel) => (
<Reflection key={`mirror-${panel.index}`} panel={panel} />
))}
{PANELS.map((panel) => (
<Panel key={panel.key} panel={panel} />
))}
</View>
</View>
<View
key="fade"
className="absolute inset-0"
style={{
opacity: pool,
backgroundImage: "linear-gradient(180deg, #0B0A0D00 80%, #0B0A0DCC 100%)",
}}
/>
<View
key="head"
className="absolute flex justify-between"
style={{ left: 96, right: 96, top: 72, opacity: meta }}
>
<Text style={{ ...LABEL, color: CREAM }}>N° 05 — CAROUSEL</Text>
<Text style={{ ...LABEL, color: CREAM }}>16 CARDS · PERSPECTIVE 2600</Text>
</View>
<View
key="foot"
className="absolute flex items-end justify-between"
style={{
left: 96,
right: 96,
bottom: 64,
opacity: title,
translate: `0px ${(1 - title) * 18}px`,
}}
>
<Text
style={{
fontFamily: "Instrument",
fontSize: 96,
lineHeight: 0.95,
letterSpacing: -2,
color: CREAM,
}}
>
In the <Span style={{ fontStyle: "italic", color: ORANGE }}>round.</Span>
</Text>
<Text style={{ ...LABEL, color: CREAM }}>CSS 3D · NO MESHES</Text>
</View>
</View>
);
} 06-flip.motion.tsx 在 GitHub 上查看 ↗
// Flip: a wall of 144 tiles, each a slice of one picture. A wave turns them over along the
// diagonal to a second picture and its words, another runs out from the middle to a third, and
// the gaps between the tiles close until the wall is one sheet. CSS 3D only.
// Designed at 1920 x 1080, 30 fps, 5 s.
export const composition = { width: 1920, height: 1080, fps: 30, duration: 5 };
// The fonts are Google Fonts' files through jsDelivr, at a pinned commit, under the SIL Open Font License 1.1.
export const controls = {
resources: {
Instrument: resource({
kind: "font",
default: [
"https://…/ofl/instrumentserif/InstrumentSerif-Regular.ttf",
"https://…/ofl/instrumentserif/InstrumentSerif-Italic.ttf",
],
}),
GeistMono: resource({
kind: "font",
default:
"https://…/ofl/geistmono/GeistMono%5Bwght%5D.ttf",
}),
},
};
const NIGHT = "#0B0A0D";
const CREAM = "#F4EEE4";
const INK = "#16140F";
// The small mono captions at the corners.
const LABEL = { fontFamily: "GeistMono", fontSize: 20, letterSpacing: 4 };
const TILE = 120;
const COLUMNS = 16;
const ROWS = 9;
const GAP = 10;
// The three pictures, each the size of the frame: a tile shows the part of one behind it.
const SLATE = "linear-gradient(160deg, #1D1826 0%, #100E15 100%)";
const COOL =
"radial-gradient(circle 900px at 380px 240px, #2536FF 0%, #2536FF00 100%), radial-gradient(circle 1000px at 1560px 860px, #7A3BFF 0%, #7A3BFF00 100%), radial-gradient(circle 620px at 1080px 380px, #22C7A9 0%, #22C7A900 100%), linear-gradient(#0E0B2A, #0E0B2A)";
const WARM =
"radial-gradient(circle 880px at 1500px 220px, #FFC46B 0%, #FFC46B00 100%), radial-gradient(circle 1000px at 300px 900px, #6B3BFF 0%, #6B3BFF00 100%), radial-gradient(circle 760px at 900px 560px, #F2416B 0%, #F2416B00 100%), linear-gradient(#FF7A2E, #FF7A2E)";
const TILES = Array.from({ length: COLUMNS * ROWS }, (_, i) => {
const column = i % COLUMNS;
const row = Math.floor(i / COLUMNS);
const dx = column - (COLUMNS - 1) / 2;
const dy = row - (ROWS - 1) / 2;
return {
key: `tile-${i}`,
x: column * TILE,
y: row * TILE,
// When each wave reaches it, from 0 to 1: the first along the diagonal, the second outward.
first: (column + row) / (COLUMNS + ROWS - 2),
second: Math.hypot(dx, dy) / Math.hypot((COLUMNS - 1) / 2, (ROWS - 1) / 2),
// Whether the words cross it: the others carry none, which is most of what a frame costs.
worded: row >= 2 && row <= 6 && column >= 2 && column <= 13,
};
});
// The words of a picture, set once over the whole frame.
function Words({ children, italic, color, shown = true }) {
return (
<Text
className="absolute"
style={{
left: 0,
top: 250,
width: 1920,
textAlign: "center",
fontFamily: "Instrument",
fontStyle: italic ? "italic" : "normal",
fontSize: 520,
lineHeight: 1,
letterSpacing: -14,
color,
opacity: shown ? 1 : 0,
}}
>
{children}
</Text>
);
}
// A face of a tile: its part of a picture and of the picture's words, darker as it turns away.
function Face({ picture, x, y, shade, back, children }) {
return (
<View
className={children ? "absolute inset-0 overflow-hidden" : "absolute inset-0"}
style={{
backgroundImage: picture,
backgroundSize: "1920px 1080px",
backgroundPosition: `${-x}px ${-y}px`,
backfaceVisibility: "hidden",
transform: back ? "rotateY(180deg)" : "none",
}}
>
{children ? (
<View className="absolute" style={{ left: -x, top: -y, width: 1920, height: 1080 }}>
{children}
</View>
) : null}
<View className="absolute inset-0" style={{ backgroundColor: NIGHT, opacity: shade }} />
</View>
);
}
function Tile({ tile }) {
const { seconds } = useCurrentTime();
const first = interpolate(seconds, [0.5 + tile.first * 1.3, 1.2 + tile.first * 1.3], [0, 1], {
easing: "easeInOutCubic",
});
const second = interpolate(seconds, [2.7 + tile.second * 1.0, 3.4 + tile.second * 1.0], [0, 1], {
easing: "easeInOutCubic",
});
const turn = 180 * (first + second);
// 0 flat to the viewer, 1 edge on.
const edge = 1 - Math.abs(Math.cos((turn * Math.PI) / 180));
const lift = 90 * Math.sin(Math.PI * first) + 90 * Math.sin(Math.PI * second);
// The gaps close once every tile shows the last picture.
const close = interpolate(seconds, [4.15, 4.7], [0, 1], { easing: "easeInOutCubic" });
const size = (TILE - GAP + GAP * close) / TILE;
// The front is the first picture until it is turned away, then the last.
const late = seconds >= 2.5;
return (
<View
className="absolute"
style={{
left: tile.x,
top: tile.y,
width: TILE,
height: TILE,
transformStyle: "preserve-3d",
transform: `translateZ(${lift}px) rotateY(${turn}deg) scale(${size})`,
}}
>
<Face key="front" picture={late ? WARM : SLATE} x={tile.x} y={tile.y} shade={0.6 * edge}>
{tile.worded ? (
<Words italic color={INK} shown={late}>
over.
</Words>
) : null}
</Face>
<Face key="back" picture={COOL} x={tile.x} y={tile.y} shade={0.6 * edge} back>
{tile.worded ? <Words color={CREAM}>Turn it</Words> : null}
</Face>
</View>
);
}
export default function Flip() {
const { seconds } = useCurrentTime();
const meta = interpolate(seconds, [0.3, 1.0], [0, 1], { easing: "easeOutCubic" });
// One sheet over the wall once its gaps have closed, so no seam is left between tiles.
const sheet = interpolate(seconds, [4.62, 4.78], [0, 1]);
// The captions go dark as the wall turns light.
const ink = interpolate(seconds, [3.4, 4.2], [CREAM, INK]);
return (
<View className="relative h-full w-full" style={{ backgroundColor: NIGHT }}>
<View
key="wall"
className="absolute"
style={{
left: 0,
top: 0,
width: 1920,
height: 1080,
perspective: 1800,
perspectiveOrigin: "960px 540px",
}}
>
{TILES.map((tile) => (
<Tile key={tile.key} tile={tile} />
))}
</View>
<View
key="sheet"
className="absolute inset-0"
style={{ opacity: sheet, backgroundImage: WARM }}
>
<Words italic color={INK}>
over.
</Words>
</View>
<View
key="head"
className="absolute flex justify-between"
style={{ left: 96, right: 96, top: 72, opacity: meta }}
>
<Text style={{ ...LABEL, color: ink }}>N° 06 — FLIP</Text>
<Text style={{ ...LABEL, color: ink }}>144 TILES · THREE PICTURES</Text>
</View>
<View
key="foot"
className="absolute flex justify-between"
style={{ left: 96, right: 96, bottom: 64, opacity: meta }}
>
<Text style={{ ...LABEL, color: ink }}>ONE WALL, TURNED TWICE</Text>
<Text style={{ ...LABEL, color: ink }}>CSS 3D · NO MESHES</Text>
</View>
</View>
);
} 07-ridge.motion.tsx 在 GitHub 上查看 ↗
// Ridge: sixty-four white lines on black, each one row of the same noise. Where the noise is
// high a line lifts and hides the lines behind it, and the rows read as a range of hills that
// never stops moving. One SVG path a line.
// Designed at 1920 x 1080, 30 fps, 5 s.
export const composition = { width: 1920, height: 1080, fps: 30, duration: 5 };
// The fonts are Google Fonts' files through jsDelivr, at a pinned commit, under the SIL Open Font License 1.1.
export const controls = {
resources: {
Instrument: resource({
kind: "font",
default: [
"https://…/ofl/instrumentserif/InstrumentSerif-Regular.ttf",
"https://…/ofl/instrumentserif/InstrumentSerif-Italic.ttf",
],
}),
GeistMono: resource({
kind: "font",
default:
"https://…/ofl/geistmono/GeistMono%5Bwght%5D.ttf",
}),
},
};
const BLACK = "#050505";
const WHITE = "#F5F3EE";
// The small mono captions at the corners.
const LABEL = { fontFamily: "GeistMono", fontSize: 20, letterSpacing: 4 };
const COUNT = 64;
const STEPS = 120;
const CENTER = 1180;
const TOP = 250;
const PITCH = 10.4;
const LINES = Array.from({ length: COUNT }, (_, i) => ({
key: `line-${i}`,
index: i,
y: TOP + i * PITCH,
// The plane recedes: the lines at the back are shorter.
half: 430 + 190 * (i / (COUNT - 1)),
}));
const POINTS = Array.from({ length: STEPS + 1 }, (_, i) => i / STEPS);
// Where the hills stand along a line: two peaks, and flat ground at both ends.
function range(u) {
return Math.exp(-((u - 0.4) ** 2) / 0.016) + 0.72 * Math.exp(-((u - 0.63) ** 2) / 0.009);
}
export default function Ridge() {
const { seconds } = useCurrentTime();
const meta = interpolate(seconds, [0.5, 1.3], [0, 1], { easing: "easeOutCubic" });
const title = interpolate(seconds, [1.0, 2.0], [0, 1], { easing: "easeOutCubic" });
return (
<View className="relative h-full w-full" style={{ backgroundColor: BLACK }}>
<svg key="lines" className="absolute inset-0" width={1920} height={1080}>
{LINES.map((line) => {
// The lines arrive flat, back to front, and the hills rise out of them.
const shown = interpolate(
seconds,
[0.1 + line.index * 0.012, 0.5 + line.index * 0.012],
[0, 1],
);
const rise = interpolate(
seconds,
[0.5 + line.index * 0.014, 2.3 + line.index * 0.014],
[0, 1],
{ easing: "easeOutExpo" },
);
let d = "";
for (const u of POINTS) {
const n = noise2d(7, u * 11 + line.index * 0.29, line.index * 0.16 - seconds * 0.55);
const ripple = noise2d(3, u * 40, line.index * 0.9 + seconds * 0.8) - 0.5;
const y = line.y - rise * range(u) * (20 + 250 * n * n) - 5 * ripple;
d += `${u === 0 ? "M" : "L"}${CENTER - line.half + 2 * line.half * u} ${y}`;
}
return (
<path
key={line.key}
d={d}
fill={BLACK}
stroke={WHITE}
strokeWidth={1.8}
strokeLinejoin="round"
opacity={shown}
/>
);
})}
</svg>
<View
key="grain"
className="absolute inset-0"
style={{ filter: `film-grain(${Math.floor(seconds * 24)} 0.1 1.5px)` }}
/>
<View
key="head"
className="absolute flex justify-between"
style={{ left: 96, right: 96, top: 72, opacity: meta }}
>
<Text style={{ ...LABEL, color: WHITE }}>N° 07 — RIDGE</Text>
<Text style={{ ...LABEL, color: WHITE }}>64 LINES · ONE NOISE</Text>
</View>
<View
key="title"
className="absolute flex flex-col"
style={{
left: 96,
top: 356,
opacity: title,
translate: `0px ${(1 - title) * 24}px`,
}}
>
<Text
style={{
fontFamily: "Instrument",
fontSize: 148,
lineHeight: 0.95,
letterSpacing: -3,
color: WHITE,
}}
>
Hills, from
</Text>
<Text
style={{
fontFamily: "Instrument",
fontStyle: "italic",
fontSize: 148,
lineHeight: 0.95,
letterSpacing: -3,
color: WHITE,
}}
>
noise.
</Text>
<View style={{ marginTop: 56, width: 420, height: 1.5, backgroundColor: "#F5F3EE4D" }} />
<Text style={{ ...LABEL, marginTop: 28, color: "#F5F3EE99" }}>ROW OF THE NOISE</Text>
<Text
style={{
marginTop: 10,
fontFamily: "GeistMono",
fontSize: 64,
fontWeight: 300,
letterSpacing: -1,
color: WHITE,
fontVariantNumeric: "tabular-nums",
}}
>
{formatNumber(seconds * 0.55, { decimals: 3 })}
</Text>
</View>
<View
key="foot"
className="absolute flex justify-between"
style={{ left: 96, right: 96, bottom: 64, opacity: meta }}
>
<Text style={{ ...LABEL, color: WHITE }}>EACH LINE HIDES THE ONES BEHIND</Text>
<Text style={{ ...LABEL, color: WHITE }}>SVG · 64 PATHS</Text>
</View>
</View>
);
} 08-strata.motion.tsx 在 GitHub 上查看 ↗
// Strata: a year of visits as five streams stacked about one centre line. A reading line
// crosses the year and the total counts with it; then the stack comes apart, and each stream
// stands on its own. Every edge is one function, sampled a hundred times.
// Designed at 1920 x 1080, 30 fps, 5 s.
export const composition = { width: 1920, height: 1080, fps: 30, duration: 5 };
// The fonts are Google Fonts' files through jsDelivr, at a pinned commit, under the SIL Open Font License 1.1.
export const controls = {
resources: {
Instrument: resource({
kind: "font",
default: [
"https://…/ofl/instrumentserif/InstrumentSerif-Regular.ttf",
"https://…/ofl/instrumentserif/InstrumentSerif-Italic.ttf",
],
}),
GeistMono: resource({
kind: "font",
default:
"https://…/ofl/geistmono/GeistMono%5Bwght%5D.ttf",
}),
},
};
const PAPER = "#F1ECE2";
const INK = "#16140F";
// The small mono captions at the corners.
const LABEL = { fontFamily: "GeistMono", fontSize: 20, letterSpacing: 4 };
const PLOT = { left: 96, width: 1728, middle: 600 };
const STEPS = 100;
const POINTS = Array.from({ length: STEPS + 1 }, (_, i) => i / STEPS);
const STREAMS = [
{ key: "search", name: "SEARCH", color: "#16140F", seed: 11, share: 1.0 },
{ key: "direct", name: "DIRECT", color: "#2340F5", seed: 23, share: 0.8 },
{ key: "social", name: "SOCIAL", color: "#7A3BFF", seed: 37, share: 0.7 },
{ key: "mail", name: "EMAIL", color: "#F03A17", seed: 41, share: 0.55 },
{ key: "other", name: "REFERRAL", color: "#FF9F45", seed: 53, share: 0.45 },
];
const QUARTERS = ["JAN", "APR", "JUL", "OCT", "DEC"].map((name, i) => ({ name, u: i / 4 }));
// A visit is this many pixels of a stream's height.
const VISITS = 31;
// How thick a stream is at `u` of the year: it grows through the year. The data does not
// change with the time, so the total a day reads is the same on every frame.
function thickness(stream, u) {
const grown = 0.42 + 0.58 * u ** 1.2;
const n = noise2d(stream.seed, u * 7.5, 0.5);
return stream.share * grown * (16 + 330 * n * n);
}
export default function Strata() {
const { seconds } = useCurrentTime();
const meta = interpolate(seconds, [0.2, 1.0], [0, 1], { easing: "easeOutCubic" });
// The reading line crosses the year.
const read = interpolate(seconds, [0.4, 3.1], [0, 1], { easing: "easeInOutCubic" });
// Then the stack comes apart.
const apart = interpolate(seconds, [3.4, 4.3], [0, 1], { easing: "easeInOutCubic" });
const gap = 34 * apart;
const title = interpolate(seconds, [3.5, 4.3], [0, 1], { easing: "easeOutCubic" });
// Each stream's two edges, from the top of the stack down.
const whole = (u) => STREAMS.reduce((sum, s) => sum + thickness(s, u), 0);
const paths = STREAMS.map((stream, index) => {
let upper = "";
let lower = "";
for (const u of POINTS) {
// The centre line wanders, so the stack reads as a current, not a wedge.
const middle = PLOT.middle + 70 * (noise2d(5, u * 2.6, 0.5) - 0.5);
let top = middle - (whole(u) + gap * (STREAMS.length - 1)) / 2;
for (let k = 0; k < index; k++) top += thickness(STREAMS[k], u) + gap;
const x = PLOT.left + PLOT.width * u;
upper += `${u === 0 ? "M" : "L"}${x} ${top}`;
lower = `L${x} ${top + thickness(stream, u)}` + lower;
}
return { stream, d: `${upper}${lower}Z` };
});
const x = PLOT.left + PLOT.width * read;
const total = whole(read);
return (
<View className="relative h-full w-full" style={{ backgroundColor: PAPER }}>
<svg key="plot" className="absolute inset-0" width={1920} height={1080}>
{QUARTERS.map((quarter) => (
<line
key={quarter.name}
x1={PLOT.left + PLOT.width * quarter.u}
y1={300}
x2={PLOT.left + PLOT.width * quarter.u}
y2={900}
stroke="#16140F1F"
strokeWidth={1.5}
/>
))}
</svg>
<View
key="streams"
className="absolute inset-0"
style={{ clipPath: `inset(0px ${1920 - x}px 0px 0px)` }}
>
<svg className="absolute inset-0" width={1920} height={1080}>
{paths.map((path) => (
<path key={path.stream.key} d={path.d} fill={path.stream.color} />
))}
</svg>
</View>
<svg key="reader" className="absolute inset-0" width={1920} height={1080}>
<line x1={x} y1={300} x2={x} y2={900} stroke={INK} strokeWidth={2} opacity={1 - apart} />
<circle cx={x} cy={300} r={7} fill={INK} opacity={1 - apart} />
</svg>
{QUARTERS.map((quarter) => (
<Text
key={quarter.name}
className="absolute"
style={{
...LABEL,
left: PLOT.left + PLOT.width * quarter.u - 60,
top: 916,
width: 120,
textAlign: quarter.u === 0 ? "left" : quarter.u === 1 ? "right" : "center",
paddingLeft: quarter.u === 0 ? 60 : 0,
paddingRight: quarter.u === 1 ? 60 : 0,
color: "#16140F99",
opacity: meta,
}}
>
{quarter.name}
</Text>
))}
<View
key="head"
className="absolute flex justify-between"
style={{ left: 96, right: 96, top: 72, opacity: meta }}
>
<Text style={{ ...LABEL, color: INK }}>N° 08 — STRATA</Text>
<View className="flex" style={{ gap: 36 }}>
{STREAMS.map((stream) => (
<View key={stream.key} className="flex items-center" style={{ gap: 12 }}>
<View
style={{ width: 14, height: 14, borderRadius: 7, backgroundColor: stream.color }}
/>
<Text style={{ ...LABEL, color: INK }}>{stream.name}</Text>
</View>
))}
</View>
</View>
<View
key="total"
className="absolute flex items-baseline"
style={{ left: 96, top: 128, gap: 28, opacity: meta }}
>
<Text
style={{
fontFamily: "Instrument",
fontSize: 150,
lineHeight: 1,
letterSpacing: -4,
color: INK,
fontVariantNumeric: "tabular-nums",
}}
>
{formatNumber(total * VISITS, { decimals: 0, grouping: true })}
</Text>
<Text style={{ ...LABEL, color: "#16140F99" }}>
VISITS A DAY · DAY {padNumber(1 + 364 * read, { width: 3 })}
</Text>
</View>
<View
key="foot"
className="absolute flex items-end justify-between"
style={{ left: 96, right: 96, bottom: 56 }}
>
<Text
style={{
fontFamily: "Instrument",
fontSize: 76,
lineHeight: 0.95,
letterSpacing: -2,
color: INK,
opacity: title,
translate: `0px ${(1 - title) * 18}px`,
}}
>
A year, <Span style={{ fontStyle: "italic", color: "#F03A17" }}>in layers.</Span>
</Text>
<Text style={{ ...LABEL, color: INK, opacity: meta }}>5 STREAMS · 365 DAYS</Text>
</View>
</View>
);
} 09-glitch.motion.tsx 在 GitHub 上查看 ↗
// Glitch: a word that will not hold. It arrives torn into bands that slide apart, its colours
// split and its edges boil; then the picture locks and the word reads SIGNAL. Valle's own
// filters, on one layer: displacement, chromatic aberration, lens distortion and film grain.
// Designed at 1920 x 1080, 30 fps, 5 s.
export const composition = { width: 1920, height: 1080, fps: 30, duration: 5 };
// The fonts are Google Fonts' files through jsDelivr, at a pinned commit, under the SIL Open Font License 1.1.
export const controls = {
resources: {
Anton: resource({
kind: "font",
default:
"https://…/ofl/anton/Anton-Regular.ttf",
}),
GeistMono: resource({
kind: "font",
default:
"https://…/ofl/geistmono/GeistMono%5Bwght%5D.ttf",
}),
},
};
const BLACK = "#060608";
const ACID = "#C8FF3E";
const PINK = "#FF3E8A";
// The small mono captions at the corners.
const LABEL = { fontFamily: "GeistMono", fontSize: 20, letterSpacing: 4 };
// The word is drawn in bands, each free to slide sideways.
const BANDS = 18;
const WORD = { top: 250, height: 580 };
const BAND = WORD.height / BANDS;
const SLICES = Array.from({ length: BANDS }, (_, i) => ({ key: `band-${i}`, index: i }));
// When the picture locks.
const LOCK = 2.9;
// How badly the picture tears, from 0 to 1: on arrival, in two bursts, at the lock, and one
// last flicker after it.
function trouble(seconds) {
const burst = (at, length) =>
interpolate(seconds, [at, at + 0.04, at + length], [0, 1, 0], { easing: "easeOutCubic" });
return Math.min(
1,
interpolate(seconds, [0, 0.9], [1, 0.12], { easing: "easeOutCubic" }) *
(seconds < LOCK ? 1 : 0) +
burst(1.45, 0.4) +
burst(2.2, 0.3) +
1.2 * burst(LOCK - 0.25, 0.5) +
0.5 * burst(3.9, 0.14),
);
}
function Word({ children, color, shown }) {
const { seconds } = useCurrentTime();
const amount = trouble(seconds);
// The tearing changes fifteen times a second, not every frame.
const beat = Math.floor(seconds * 15);
return (
<View key="word" className="absolute inset-0" style={{ opacity: shown }}>
{SLICES.map((slice) => {
const pull = 2 * noise2d(9, slice.index * 3.7, beat * 1.31) - 1;
// Most bands hold; the few the noise pulls hardest go far.
const far = Math.max(0, Math.abs(pull) - 0.18);
const shift = amount * 1500 * far * (pull < 0 ? -1 : 1);
return (
<View
key={slice.key}
className="absolute overflow-hidden"
style={{
left: 0,
top: WORD.top + slice.index * BAND,
width: 1920,
height: BAND + 0.5,
translate: `${shift}px 0px`,
}}
>
<Text
className="absolute"
style={{
left: 0,
top: -slice.index * BAND,
width: 1920,
height: WORD.height,
textAlign: "center",
fontFamily: "Anton",
fontSize: 520,
lineHeight: `${WORD.height}px`,
letterSpacing: 6,
color,
}}
>
{children}
</Text>
</View>
);
})}
</View>
);
}
export default function Glitch() {
const { seconds } = useCurrentTime();
const amount = trouble(seconds);
const beat = Math.floor(seconds * 15);
const locked = seconds >= LOCK ? 1 : 0;
const meta = interpolate(seconds, [0.3, 0.9], [0, 1]);
const settled = interpolate(seconds, [LOCK + 0.1, LOCK + 0.6], [0, 1], {
easing: "easeOutCubic",
});
const frames = Math.floor(seconds * 30);
return (
<View className="relative h-full w-full" style={{ backgroundColor: BLACK }}>
<View
key="screen"
className="absolute inset-0"
style={{
filter: `displacement(${beat} 0.002 0.05 ${5 * (1 - locked) + 26 * amount}px 2 turbulence) chromatic-aberration(${2 + 3 * (1 - locked) + 90 * amount}px) lens-distortion(0.06 0) film-grain(${frames} 0.16 2px)`,
}}
>
<View
key="glow"
className="absolute inset-0"
style={{
backgroundImage: `radial-gradient(ellipse 1100px 560px at 960px 540px, ${
locked ? "#C8FF3E24" : "#FF3E8A24"
} 0%, #06060800 100%)`,
}}
/>
<Word color={PINK} shown={1 - locked}>
NOISE
</Word>
<Word color={ACID} shown={locked}>
SIGNAL
</Word>
<View
key="bar"
className="absolute"
style={{
left: 0,
top: 0,
width: 1920,
height: 90,
backgroundColor: "#FFFFFF",
opacity: 0.1 + 0.25 * amount,
translate: `0px ${mod(seconds * 520, 1260) - 90}px`,
}}
/>
</View>
<View
key="lines"
className="absolute inset-0"
style={{
backgroundImage: "linear-gradient(#00000000 50%, #00000066 50%)",
backgroundSize: "100% 6px",
}}
/>
<View
key="vignette"
className="absolute inset-0"
style={{
backgroundImage:
"radial-gradient(ellipse 1300px 760px at 960px 540px, #00000000 55%, #000000B3 100%)",
}}
/>
<View
key="head"
className="absolute flex justify-between"
style={{ left: 96, right: 96, top: 72, opacity: meta }}
>
<Text style={{ ...LABEL, color: "#F4F4F0" }}>N° 09 — GLITCH</Text>
<Text style={{ ...LABEL, color: "#F4F4F0", fontVariantNumeric: "tabular-nums" }}>
CH 09 · 00:00:{padNumber(Math.floor(seconds), { width: 2 })}:
{padNumber(frames - 30 * Math.floor(seconds), { width: 2 })}
</Text>
</View>
<View
key="foot"
className="absolute flex items-center justify-between"
style={{ left: 96, right: 96, bottom: 64, opacity: meta }}
>
<View className="flex items-center" style={{ gap: 16 }}>
<View
style={{
width: 16,
height: 16,
borderRadius: 8,
backgroundColor: locked ? ACID : PINK,
opacity: locked ? 1 : 0.35 + 0.65 * (beat - 2 * Math.floor(beat / 2)),
}}
/>
<Text style={{ ...LABEL, color: "#F4F4F0" }}>
TEAR {padNumber(100 * amount, { width: 3 })}
</Text>
<Text style={{ ...LABEL, color: ACID, opacity: settled }}>LOCKED</Text>
</View>
<Text style={{ ...LABEL, color: "#F4F4F0" }}>FOUR FILTERS · ONE LAYER</Text>
</View>
</View>
);
} 10-dawn.motion.tsx 在 GitHub 上查看 ↗
// Dawn: a valley cut from six sheets of paper. The sheets rise into place, the sky turns from
// night to morning behind them, the stars go out and the sun comes up over the far ridge.
// Every ridge is one line of noise, drawn once; only colours and positions follow the time.
// Designed at 1920 x 1080, 30 fps, 5 s.
export const composition = { width: 1920, height: 1080, fps: 30, duration: 5 };
// The fonts are Google Fonts' files through jsDelivr, at a pinned commit, under the SIL Open Font License 1.1.
export const controls = {
resources: {
Instrument: resource({
kind: "font",
default: [
"https://…/ofl/instrumentserif/InstrumentSerif-Regular.ttf",
"https://…/ofl/instrumentserif/InstrumentSerif-Italic.ttf",
],
}),
GeistMono: resource({
kind: "font",
default:
"https://…/ofl/geistmono/GeistMono%5Bwght%5D.ttf",
}),
},
};
const CREAM = "#FFF6E9";
// The small mono captions at the corners.
const LABEL = { fontFamily: "GeistMono", fontSize: 20, letterSpacing: 4 };
const NIGHT_SKY = "linear-gradient(180deg, #0B0D2B 0%, #1F1B4D 55%, #40306B 100%)";
const DAY_SKY = "linear-gradient(180deg, #5B6FD6 0%, #F2A5A0 46%, #FFD9A0 78%, #FFEFC9 100%)";
const SUN = { x: 1240, from: 760, to: 372, size: 190 };
// The sheets, far to near: where each ridge stands, how tall its hills are and how often they
// come, and its colour by night and by day.
const SHEETS = [
{ base: 650, tall: 250, often: 3.4, seed: 3, night: "#3A3470", day: "#F6C3A8" },
{ base: 705, tall: 240, often: 4.6, seed: 8, night: "#302B63", day: "#EC9A8E" },
{ base: 760, tall: 210, often: 3.0, seed: 15, night: "#262256", day: "#CF6F84" },
{ base: 835, tall: 200, often: 3.8, seed: 21, night: "#1D1A47", day: "#99527F" },
{ base: 915, tall: 170, often: 3.2, seed: 34, night: "#151338", day: "#5E3A70" },
{ base: 1000, tall: 130, often: 4.6, seed: 55, night: "#0D0C27", day: "#33254F" },
].map((sheet, index) => {
// The ridge, and on the near sheets the pines along it.
// The far sheets are peaks, where the noise crosses its middle; the near ones are hills.
const height = (x) => {
const n = noise1d(sheet.seed, (x / 1920) * sheet.often);
// They stand to the right, under the sun, and leave the sky on the left to the title.
const right = Math.min(1, Math.max(0, (x - 420) / 900));
const stand = 0.3 + 0.7 * right * right * (3 - 2 * right);
const shape = index < 2 ? stand * (1 - Math.abs(2 * n - 1)) ** 1.6 : n;
const detail = noise1d(sheet.seed + 1, (x / 1920) * sheet.often * 3.3);
return sheet.base - sheet.tall * shape - 0.2 * sheet.tall * detail;
};
let d = `M-40 1300L-40 ${height(-40)}`;
for (let x = -20; x <= 1960; x += 20) d += `L${x} ${height(x)}`;
d += "L1960 1300Z";
let pines = "";
if (index >= 3) {
const sizes = seededRandom(sheet.seed, 60, [0.55, 1]);
const places = seededRandom(sheet.seed + 7, 60, [0, 1920]);
for (let i = 0; i < (index === 3 ? 26 : 44); i++) {
const tall = (index - 2) * 30 * sizes[i];
const x = places[i];
const y = height(x) + 6;
pines += `M${x - tall * 0.3} ${y}L${x} ${y - tall}L${x + tall * 0.3} ${y}Z`;
}
}
return { ...sheet, key: `sheet-${index}`, index, d: d + pines };
});
const STARS = seededRandom(4, 90).map((u, i) => ({
key: `star-${i}`,
x: 1920 * u,
y: 560 * seededRandom(5, 90)[i],
r: 1 + 1.6 * seededRandom(6, 90)[i],
twinkle: 6.3 * seededRandom(7, 90)[i],
}));
const BIRDS = [
{ key: "a", x: 700, y: 290, size: 1 },
{ key: "b", x: 770, y: 330, size: 0.8 },
{ key: "c", x: 650, y: 342, size: 0.7 },
];
export default function Dawn() {
const { seconds } = useCurrentTime();
// Night to morning.
const day = interpolate(seconds, [0.9, 3.9], [0, 1], { easing: "easeInOutSine" });
const sun = interpolate(seconds, [1.0, 4.2], [SUN.from, SUN.to], { easing: "easeOutCubic" });
const meta = interpolate(seconds, [0.6, 1.4], [0, 1], { easing: "easeOutCubic" });
const title = interpolate(seconds, [2.9, 3.8], [0, 1], { easing: "easeOutCubic" });
const ink = interpolate(day, [0, 1], [CREAM, "#2A1B3D"]);
return (
<View className="relative h-full w-full" style={{ backgroundImage: NIGHT_SKY }}>
<View
key="day"
className="absolute inset-0"
style={{ opacity: day, backgroundImage: DAY_SKY }}
/>
<svg key="stars" className="absolute inset-0" width={1920} height={1080}>
{STARS.map((star) => (
<circle
key={star.key}
cx={star.x}
cy={star.y}
r={star.r}
fill={CREAM}
opacity={(1 - day) * (0.55 + 0.45 * Math.sin(seconds * 3 + star.twinkle))}
/>
))}
</svg>
<View
key="halo"
className="absolute"
style={{
left: SUN.x - 700,
top: -700,
width: 1400,
height: 1400,
opacity: day,
translate: `0px ${sun}px`,
backgroundImage: "radial-gradient(circle, #FFF1C2B3 0%, #FFD08A40 34%, #FFD08A00 68%)",
}}
/>
<View
key="sun"
className="absolute"
style={{
left: SUN.x - SUN.size / 2,
top: -SUN.size / 2,
width: SUN.size,
height: SUN.size,
borderRadius: SUN.size / 2,
translate: `0px ${sun}px`,
backgroundImage:
"radial-gradient(circle at 40% 36%, #FFFDF2 0%, #FFE9A8 70%, #FFD27A 100%)",
}}
/>
<svg key="birds" className="absolute inset-0" width={1920} height={1080}>
{BIRDS.map((bird) => {
// Each wing beats a little out of step with the others.
const flap = 9 * Math.sin(seconds * 7 + bird.x);
const x = bird.x + seconds * 26;
const y = bird.y - seconds * 9 + 5 * Math.sin(seconds * 2 + bird.y);
const w = 22 * bird.size;
return (
<path
key={bird.key}
d={`M${x - w} ${y - flap * bird.size}Q${x - w / 2} ${y - 7 * bird.size} ${x} ${y}Q${x + w / 2} ${y - 7 * bird.size} ${x + w} ${y - flap * bird.size}`}
fill="none"
stroke="#2A1B3D"
strokeWidth={3 * bird.size}
strokeLinecap="round"
opacity={interpolate(day, [0.35, 0.8], [0, 0.8])}
/>
);
})}
</svg>
<svg key="valley" className="absolute inset-0" width={1920} height={1080}>
<defs>
<linearGradient id="haze" gradientUnits="userSpaceOnUse" x1={0} y1={520} x2={0} y2={1080}>
<stop offset={0} stopColor="#FFFFFF00" />
<stop offset={1} stopColor="#FFFFFF38" />
</linearGradient>
</defs>
{SHEETS.map((sheet) => {
// The sheets come up from below, the far ones first, and the near ones move the most
// as the view settles.
const up = interpolate(
seconds,
[0.1 + sheet.index * 0.12, 1.5 + sheet.index * 0.12],
[1, 0],
{ easing: "easeOutExpo" },
);
const settle = interpolate(seconds, [1.2, 5], [1, 0], { easing: "easeOutCubic" });
const y = up * (520 - sheet.index * 30) + settle * sheet.index * 9;
return (
<g key={sheet.key} transform={`translate(0 ${y})`}>
<path d={sheet.d} fill="#0A081E" opacity={0.16} transform="translate(0 -9)" />
<path
d={sheet.d}
fill={interpolate(day, [0, 1], [sheet.night, sheet.day], { colorSpace: "oklch" })}
/>
<path d={sheet.d} fill="url(#haze)" opacity={day * (1 - sheet.index / 6)} />
</g>
);
})}
</svg>
<View
key="grain"
className="absolute inset-0"
style={{ filter: "film-grain(5 0.09 1.5px)" }}
/>
<View
key="head"
className="absolute flex justify-between"
style={{ left: 96, right: 96, top: 72, opacity: meta }}
>
<Text style={{ ...LABEL, color: ink }}>N° 10 — DAWN</Text>
<Text style={{ ...LABEL, color: ink }}>SIX SHEETS · ONE SUN</Text>
</View>
<View
key="title"
className="absolute flex flex-col"
style={{
left: 96,
top: 150,
opacity: title,
translate: `0px ${(1 - title) * 24}px`,
}}
>
<Text
style={{
fontFamily: "Instrument",
fontSize: 148,
lineHeight: 0.95,
letterSpacing: -3,
color: "#2A1B3D",
}}
>
Day,
</Text>
<Text
style={{
fontFamily: "Instrument",
fontStyle: "italic",
fontSize: 148,
lineHeight: 0.95,
letterSpacing: -3,
color: "#2A1B3D",
}}
>
breaking.
</Text>
</View>
<View
key="foot"
className="absolute flex justify-between"
style={{ left: 96, right: 96, bottom: 64, opacity: meta }}
>
<Text style={{ ...LABEL, color: CREAM }}>CUT FROM NOISE</Text>
<Text style={{ ...LABEL, color: CREAM }}>SVG · NO IMAGES</Text>
</View>
</View>
);
} 你在看什么
每个场景都是一个 TSX 文件:用 Tailwind 写样式的 React 风格组件,由时间的函数驱动动画。Valle 把它编译后,每一帧都是时间的纯函数,所以画第 1000 帧不需要先播放前面的 999 帧,同一个场景每次画出的像素也相同。
同一个引擎,两个地方
你电脑上的 Valle 用 Metal、Vulkan 或 Direct3D 12 把这些场景渲染成 MP4。这个页面运行的是编译成 WebAssembly 的同一个引擎,来自 @openvalle/engine 这个包:它在 worker 里用 WebGPU 绘制,也能在浏览器里导出 MP4。
用在自己的页面里
给播放器一个 canvas 和一个 Motion 场景或时间线,就能在页面里预览。应用可以原地更新时间线,也可以在预览继续播放时把 MP4 导出到文件。