import { AbsoluteFill, interpolate, useCurrentFrame } from 'remotion';
import { APPS, BEAT, COLOR, EASE, FONT, ICON } from '../theme';
import { SHAPES, boundaryPulse, shapePath } from '../design/morph';
import { ShapeView, mix, rgba } from '../design/Shape';
const clamp = { extrapolateLeft: 'clamp', extrapolateRight: 'clamp' } as const;
const ramp = (f: number, a: number, b: number, ease = EASE.out) => interpolate(f, [a, b], [0, 1], { ...clamp, easing: ease });
const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
// Row after the bloom, and the tighter row it gathers into above the wordmark.
const ROW = { gap: 212, y: 470, k: 0.62 };
const GATHER = { gap: 128, y: 384, k: 0.38, at: 5 * BEAT };
const BLOOM = { at: BEAT, every: BEAT / 2, dur: 26 };
const SPLIT = { at: 16, dur: 40 };
const FADE = { from: 390, to: 446 };
const Ring: React.FC<{ start: number; reach: number; width: number }> = ({ start, reach, width }) => {
const f = useCurrentFrame();
const p = ramp(f, start, start + 64);
if (p <= 0 || p >= 1) return null;
return (
);
};
const AppIcon: React.FC<{ index: number }> = ({ index }) => {
const f = useCurrentFrame();
const app = APPS[index];
const offset = index - (APPS.length - 1) / 2;
const travel = Math.min(1, Math.max(0, (f - SPLIT.at) / SPLIT.dur));
const bloomAt = BLOOM.at + index * BLOOM.every;
const t = EASE.inOut(Math.min(1, Math.max(0, (f - bloomAt) / BLOOM.dur)));
const land = bloomAt + BLOOM.dur;
const gather = ramp(f, GATHER.at + index * 2, GATHER.at + index * 2 + 44, EASE.inOut);
// Split: the dots rise first, then fan out, like a fountain.
// Both start from rest; the rise leads the spread.
const splitX = lerp(ICON.x, ICON.x + offset * ROW.gap, EASE.inOut(Math.max(0, (travel - 0.15) / 0.85)));
const splitY = lerp(ICON.y, ROW.y, EASE.inOut(Math.min(1, travel / 0.7)));
const cx = lerp(splitX, ICON.x + offset * GATHER.gap, gather);
const cy = lerp(splitY, GATHER.y, gather);
const swell = 0.035 * Math.exp(-(((f - land) / 6) ** 2));
const base = lerp(lerp(1 + boundaryPulse(f), ROW.k, EASE.inOut(travel)), GATHER.k, gather);
const k = base * (1 - 0.08 * Math.sin(Math.PI * t)) * (1 + swell);
const d = t >= 1 ? shapePath(app.id, 'stage', 0, k, cx, cy) : shapePath('dot', app.id, t, k, cx, cy);
const color = mix(SHAPES.dot.color, app.color, Math.max(EASE.inOut(travel) * 0.6, t));
return (
);
};
const Line: React.FC<{ text: string; start: number; stagger: number; style: React.CSSProperties }> = ({ text, start, stagger, style }) => {
const f = useCurrentFrame();
return (
{Array.from(text).map((char, i) => {
const p = ramp(f, start + i * stagger, start + i * stagger + 30);
const b = (1 - p) * 8;
return (
0.05 ? `blur(${b.toFixed(2)}px)` : undefined,
}}
>
{char}
);
})}
);
};
export const Outro: React.FC = () => {
const f = useCurrentFrame();
const fade = 1 - ramp(f, FADE.from, FADE.to, EASE.inOut);
const push = 1 + 0.022 * ramp(f, GATHER.at, FADE.to, EASE.inOut);
const glow = ramp(f, 0, 18) * (1 - ramp(f, 18, 80, EASE.inOut));
return (
{f < SPLIT.at ? (
) : (
APPS.map((app, i) => )
)}
);
};