0.1.5 update video and Chinese changelog

Real footage of the installed 0.1.5 apps, composited in Remotion with
shape morphs between sections; synthesized score and UI sounds. Logs
P3-17 (ElyTable keyboard zoom leaves the grid half-scrolled).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-15 09:24:06 -04:00
1 parent 2e1ba5eded
commit 8f31e53cfc
57 files changed
+8051

No files matched your search

@@ -0,0 +1,24 @@
import { AbsoluteFill, useCurrentFrame } from 'remotion';
import { COLOR, HEIGHT, WIDTH } from '../theme';
// Near-black field with a faint lift at the centre and fine film grain. The grain
// changes every other frame (30 Hz) from a seed fixed by the frame number.
export const Background: React.FC = () => {
const frame = useCurrentFrame();
const seed = Math.floor(frame / 2) % 997;
return (
<AbsoluteFill style={{ background: COLOR.bgOuter }}>
<AbsoluteFill
style={{ background: `radial-gradient(ellipse 72% 66% at 50% 47%, ${COLOR.bgInner} 0%, ${COLOR.bgOuter} 100%)` }}
/>
<AbsoluteFill style={{ background: 'radial-gradient(ellipse 90% 90% at 50% 50%, rgba(0,0,0,0) 60%, rgba(0,0,0,0.28) 100%)' }} />
<svg width={WIDTH} height={HEIGHT} style={{ position: 'absolute', inset: 0, opacity: 0.055, mixBlendMode: 'screen' }}>
<filter id="grain" x="0" y="0" width="100%" height="100%">
<feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="2" seed={seed} stitchTiles="stitch" />
<feColorMatrix type="saturate" values="0" />
</filter>
<rect width="100%" height="100%" filter="url(#grain)" />
</svg>
</AbsoluteFill>
);
};
@@ -0,0 +1,50 @@
import { interpolate, useCurrentFrame } from 'remotion';
import { COLOR, EASE, FONT, STAGE } from '../theme';
export type CaptionProps = {
text: string;
// Section-local frames: starts entering at `from`, gone by `to`.
from: number;
to: number;
// Centre of the pill in composition pixels (default: bottom centre of the stage).
x?: number;
y?: number;
};
const clamp = { extrapolateLeft: 'clamp', extrapolateRight: 'clamp' } as const;
// A glass pill with one line of explanation, over the stage.
export const Caption: React.FC<CaptionProps> = ({ text, from, to, x = STAGE.x + STAGE.w / 2, y = STAGE.y + STAGE.h - 64 }) => {
const frame = useCurrentFrame();
if (frame < from || frame >= to) return null;
const p = interpolate(frame, [from, from + 22], [0, 1], { ...clamp, easing: EASE.out });
const q = interpolate(frame, [to - 16, to], [0, 1], { ...clamp, easing: EASE.in });
const blur = (1 - p) * 6 + q * 5;
return (
<div
style={{
position: 'absolute',
left: x,
top: y,
transform: `translate(-50%, -50%) translateY(${((1 - p) * 14 - q * 8).toFixed(2)}px) scale(${(0.98 + 0.02 * p).toFixed(4)})`,
opacity: p * (1 - q),
filter: blur > 0.05 ? `blur(${blur.toFixed(2)}px)` : undefined,
padding: '13px 26px 14px',
borderRadius: 16,
background: 'rgba(22,22,24,0.66)',
backdropFilter: 'blur(18px) saturate(1.2)',
border: '1px solid rgba(255,255,255,0.09)',
boxShadow: '0 12px 40px rgba(0,0,0,0.42)',
fontFamily: FONT.sans,
fontWeight: 500,
fontSize: 26,
lineHeight: '34px',
letterSpacing: '0.03em',
color: COLOR.ink,
whiteSpace: 'nowrap',
}}
>
{text}
</div>
);
};
@@ -0,0 +1,203 @@
import { Img, interpolate, staticFile, useCurrentFrame } from 'remotion';
import { mix } from './Shape';
import { type AppId, COLOR, EASE, FONT, HEADING, STAGE, appOf } from '../theme';
export type HeadingSpec = {
title: string;
sub?: string;
// App chip at the right edge, above the stage.
app?: AppId;
// Section-local frame the title starts to enter (default: beat 1).
at?: number;
// Section-local frame it starts to leave (default: the next heading's
// entrance, or HEADING.out frames before the section ends).
until?: number;
};
const ENTER = 28;
const LEAVE = 22;
const clamp = { extrapolateLeft: 'clamp', extrapolateRight: 'clamp' } as const;
// Per-character rise, unblur and fade; leaving drifts on up and dissolves.
// The first `keepIn` characters are already on screen (shared with the previous
// heading); the first `keepOut` stay for the next one until `handoff`.
const Kinetic: React.FC<{
text: string;
local: number;
leave: number;
stagger: number;
rise: number;
keepIn?: number;
keepOut?: number;
handoff?: number;
}> = ({ text, local, leave, stagger, rise, keepIn = 0, keepOut = 0, handoff = Infinity }) => {
const chars = Array.from(text);
return (
<>
{chars.map((char, i) => {
const kept = i < keepOut;
if (kept && local >= handoff) return <span key={i} style={{ display: 'inline-block', whiteSpace: 'pre', opacity: 0 }}>{char}</span>;
const order = i - keepIn;
const p = i < keepIn ? 1 : interpolate(local - order * stagger, [0, ENTER], [0, 1], { ...clamp, easing: EASE.out });
const q = kept ? 0 : interpolate(local - leave - (i - keepOut) * stagger * 0.55, [0, LEAVE], [0, 1], { ...clamp, easing: EASE.in });
const y = (1 - p) * rise - q * rise * 0.6;
const blur = (1 - p) * 9 + q * 7;
return (
<span
key={i}
style={{
display: 'inline-block',
whiteSpace: 'pre',
opacity: p * (1 - q),
transform: `translateY(${y.toFixed(2)}px)`,
filter: blur > 0.05 ? `blur(${blur.toFixed(2)}px)` : undefined,
}}
>
{char}
</span>
);
})}
</>
);
};
// One section title above the stage's left edge, with an optional app chip.
export type HeadingTiming = {
spec: HeadingSpec;
enter: number;
leave: number;
// Characters shared with the previous / next heading of the section.
keepIn: number;
keepOut: number;
// Section-local frame the next heading takes over (null for the last).
handoff: number | null;
// Rule colour of the previous heading, which this one eases from.
fromColor: string | null;
};
export const Heading: React.FC<{ timing: HeadingTiming; color: string }> = ({ timing, color }) => {
const { spec, enter, leave, keepIn, keepOut, handoff, fromColor } = timing;
const frame = useCurrentFrame();
const local = frame - enter;
const until = handoff ?? leave + LEAVE + 40;
if (local < 0 || frame >= until) return null;
const stay = leave - enter;
const subAt = HEADING.sub;
const rule = fromColor === null ? interpolate(local, [-6, 22], [0, 1], { ...clamp, easing: EASE.out }) : 1;
const ruleOut = handoff === null ? interpolate(local - stay - 8, [0, 18], [0, 1], { ...clamp, easing: EASE.inOut }) : 0;
const ruleColor = fromColor === null ? color : mix(fromColor, color, interpolate(local, [0, 24], [0, 1], { ...clamp, easing: EASE.inOut }));
const chip = interpolate(local - 10, [0, 30], [0, 1], { ...clamp, easing: EASE.out });
const chipOut = interpolate(local - stay, [0, LEAVE], [0, 1], { ...clamp, easing: EASE.in });
const app = spec.app ? appOf(spec.app) : null;
return (
<div style={{ position: 'absolute', left: STAGE.x, top: 28, width: STAGE.w, height: 76 }}>
<div
style={{
position: 'absolute',
left: 0,
top: 6,
width: 4,
height: 64,
borderRadius: 2,
background: ruleColor,
transformOrigin: '50% 0%',
transform: `scaleY(${(rule * (1 - ruleOut)).toFixed(4)})`,
}}
/>
<div
style={{
position: 'absolute',
left: 22,
top: 0,
fontFamily: FONT.sans,
fontWeight: 600,
fontSize: 42,
lineHeight: '48px',
letterSpacing: '0.02em',
color: COLOR.ink,
whiteSpace: 'nowrap',
}}
>
<Kinetic
text={spec.title}
local={local}
leave={stay}
stagger={1.8}
rise={24}
keepIn={keepIn}
keepOut={keepOut}
handoff={handoff === null ? Infinity : handoff - enter}
/>
</div>
{spec.sub ? (
<div
style={{
position: 'absolute',
left: 23,
top: 52,
fontFamily: FONT.sans,
fontWeight: 400,
fontSize: 19,
lineHeight: '24px',
letterSpacing: '0.04em',
color: COLOR.muted,
whiteSpace: 'nowrap',
}}
>
<Kinetic text={spec.sub} local={local - subAt} leave={stay - subAt - 6} stagger={0.55} rise={12} />
</div>
) : null}
{app ? (
<div
style={{
position: 'absolute',
right: 0,
top: 18,
height: 40,
display: 'flex',
alignItems: 'center',
gap: 12,
opacity: chip * (1 - chipOut),
transform: `translateX(${((1 - chip) * 18 - chipOut * 10).toFixed(2)}px)`,
filter: chip < 1 || chipOut > 0 ? `blur(${((1 - chip) * 6 + chipOut * 5).toFixed(2)}px)` : undefined,
}}
>
<Img src={staticFile(`icons/${app.id}.svg`)} style={{ width: 40, height: 40 }} />
<span style={{ fontFamily: FONT.latin, fontWeight: 500, fontSize: 21, letterSpacing: '0.01em', color: COLOR.muted }}>
{app.name}
</span>
</div>
) : null}
</div>
);
};
const shared = (a: string, b: string) => {
const x = Array.from(a);
const y = Array.from(b);
let n = 0;
while (n < x.length && n < y.length && x[n] === y[n]) n++;
// Keep whole words only: stop after the last space of the shared run.
const cut = x.slice(0, n).lastIndexOf(' ');
return n === x.length || n === y.length ? n : cut + 1;
};
// Resolve each heading's frames within a section; `accent` colours the rule.
export const headingTimes = (specs: HeadingSpec[], duration: number, accent: (spec: HeadingSpec) => string): HeadingTiming[] =>
specs.map((spec, i) => {
const enter = spec.at ?? HEADING.in;
const prev = specs[i - 1];
const next = specs[i + 1];
const nextAt = next ? (next.at ?? HEADING.in) : null;
const leave = spec.until ?? (nextAt !== null ? nextAt - LEAVE - 6 : duration - HEADING.out);
return {
spec,
enter,
leave,
keepIn: prev ? shared(prev.title, spec.title) : 0,
keepOut: next ? shared(spec.title, next.title) : 0,
handoff: nextAt,
fromColor: prev ? accent(prev) : null,
};
});
@@ -0,0 +1,108 @@
import { Fragment } from 'react';
import { interpolate, spring, useCurrentFrame, useVideoConfig } from 'remotion';
import { COLOR, EASE, FONT, SPRING, STAGE } from '../theme';
export type KeyCapProps = {
// Keys of one chord, e.g. ['Ctrl', '1'], ['Tab'], ['右键'].
keys: string[];
// Section-local frames: pops in at `from`, gone by `to`.
from: number;
to: number;
// Section-local frames at which the chord is pressed.
press?: number[];
// Centre in composition pixels; default: bottom-right corner of the stage.
x?: number;
y?: number;
};
const MOUSE: Record<string, 'left' | 'right' | 'wheel'> = { 右键: 'right', 左键: 'left', 点击: 'left', 滚轮: 'wheel' };
const clamp = { extrapolateLeft: 'clamp', extrapolateRight: 'clamp' } as const;
const Mouse: React.FC<{ part: 'left' | 'right' | 'wheel'; lit: number }> = ({ part, lit }) => {
const on = `rgba(61,127,229,${(0.55 + 0.45 * lit).toFixed(3)})`;
return (
<svg width="18" height="26" viewBox="0 0 18 26">
<rect x="1" y="1" width="16" height="24" rx="8" fill="none" stroke={COLOR.ink} strokeOpacity="0.85" strokeWidth="1.6" />
{part === 'left' ? <path d="M9 1.8A7.2 7.2 0 0 0 1.8 9V11H9Z" fill={on} /> : null}
{part === 'right' ? <path d="M9 1.8A7.2 7.2 0 0 1 16.2 9V11H9Z" fill={on} /> : null}
<path d="M9 1.8V11M1.8 11H16.2" stroke={COLOR.ink} strokeOpacity="0.5" strokeWidth="1.2" />
<rect x="7.4" y="4.6" width="3.2" height="5" rx="1.6" fill={part === 'wheel' ? on : COLOR.ink} fillOpacity={part === 'wheel' ? 1 : 0.6} />
</svg>
);
};
// A keyboard chord or mouse button that pops in, presses on cue, and leaves.
export const KeyCap: React.FC<KeyCapProps> = ({ keys, from, to, press = [], x, y }) => {
const frame = useCurrentFrame();
const { fps } = useVideoConfig();
if (frame < from || frame >= to) return null;
const pop = spring({ frame: frame - from, fps, config: SPRING, durationInFrames: 24 });
const out = interpolate(frame, [to - 14, to], [0, 1], { ...clamp, easing: EASE.in });
// Down in 4 frames, back up over 12.
const down = press.reduce((acc, at) => {
const t = frame - at;
const v = t < 0 ? 0 : t < 4 ? EASE.out(t / 4) : 1 - EASE.inOut(Math.min(1, (t - 4) / 12));
return Math.max(acc, v);
}, 0);
const anchored = x === undefined || y === undefined;
const blur = (1 - pop) * 5 + out * 4;
return (
<div
style={{
position: 'absolute',
left: x ?? STAGE.x + STAGE.w - 36,
top: y ?? STAGE.y + STAGE.h - 36,
transform: `translate(${anchored ? '-100%, -100%' : '-50%, -50%'}) translateY(${((1 - pop) * 12 + out * 6).toFixed(2)}px) scale(${(0.88 + 0.12 * pop - 0.04 * out).toFixed(4)})`,
transformOrigin: anchored ? '100% 100%' : '50% 50%',
opacity: Math.min(1, pop * 1.4) * (1 - out),
filter: blur > 0.05 ? `blur(${blur.toFixed(2)}px)` : undefined,
display: 'flex',
alignItems: 'center',
gap: 10,
}}
>
{keys.map((key, i) => {
const mouse = MOUSE[key];
return (
<Fragment key={`${key}-${i}`}>
{i > 0 ? (
<span style={{ fontFamily: FONT.latin, fontSize: 22, fontWeight: 400, color: COLOR.faint }}>+</span>
) : null}
<div
style={{
height: 58,
minWidth: 58,
padding: '0 18px',
boxSizing: 'border-box',
borderRadius: 13,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: 10,
transform: `translateY(${(down * 3).toFixed(2)}px)`,
background: 'linear-gradient(180deg, #3b3b3e 0%, #2d2d30 100%)',
border: '1px solid rgba(255,255,255,0.12)',
boxShadow: [
`0 ${(4 - down * 3).toFixed(2)}px 0 #161618`,
`0 ${(12 - down * 6).toFixed(2)}px 28px rgba(0,0,0,0.5)`,
'inset 0 1px 0 rgba(255,255,255,0.10)',
`0 0 0 ${(down * 2).toFixed(2)}px rgba(61,127,229,${(down * 0.7).toFixed(3)})`,
].join(', '),
fontFamily: FONT.latin,
fontWeight: 600,
fontSize: 23,
letterSpacing: '0.01em',
color: COLOR.ink,
whiteSpace: 'nowrap',
}}
>
{mouse ? <Mouse part={mouse} lit={down} /> : null}
<span style={{ fontFamily: mouse ? FONT.sans : FONT.latin, fontWeight: mouse ? 500 : 600 }}>{key}</span>
</div>
</Fragment>
);
})}
</div>
);
};
@@ -0,0 +1,185 @@
import type { ReactNode } from 'react';
import { AbsoluteFill, Img, staticFile } from 'remotion';
import { ICON, STAGE, STAGE_CENTER } from '../theme';
import type { ShapeId } from './morph';
const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
export const rgba = (hex: string, alpha: number) => {
const n = parseInt(hex.slice(1), 16);
return `rgba(${(n >> 16) & 255},${(n >> 8) & 255},${n & 255},${alpha.toFixed(4)})`;
};
export const mix = (a: string, b: string, t: number) => {
const x = parseInt(a.slice(1), 16);
const y = parseInt(b.slice(1), 16);
const c = (shift: number) => Math.round(lerp((x >> shift) & 255, (y >> shift) & 255, t));
return `#${((c(16) << 16) | (c(8) << 8) | c(0)).toString(16).padStart(6, '0')}`;
};
// The highlighted table cell that the cell-editing section grows out of.
const CellArt: React.FC = () => (
<svg viewBox="0 0 192 192" width="100%" height="100%">
<rect x="16" y="51" width="160" height="90" rx="8" fill="#3E4A5C" />
<path d="M24 51H168A8 8 0 0 1 176 59V69H16V59A8 8 0 0 1 24 51Z" fill="#4E5B70" />
<g stroke="#FFFFFF" strokeOpacity="0.16" strokeWidth="1.2">
<path d="M69.3 51V141M122.7 51V141M16 69H176M16 93H176M16 117H176" />
</g>
<g fill="#FFFFFF" fillOpacity="0.55">
<rect x="24" y="57" width="26" height="6" rx="3" />
<rect x="77" y="57" width="30" height="6" rx="3" />
<rect x="130" y="57" width="22" height="6" rx="3" />
<rect x="24" y="78" width="32" height="6" rx="3" />
<rect x="130" y="78" width="28" height="6" rx="3" />
<rect x="24" y="102" width="22" height="6" rx="3" />
<rect x="130" y="102" width="34" height="6" rx="3" />
<rect x="24" y="126" width="30" height="6" rx="3" />
<rect x="77" y="126" width="24" height="6" rx="3" />
<rect x="130" y="126" width="26" height="6" rx="3" />
</g>
<rect x="77" y="78" width="26" height="6" rx="3" fill="#FFFFFF" fillOpacity="0.55" />
<rect x="68.5" y="92.5" width="55" height="25" rx="2.5" fill="#F2A900" />
<rect x="76" y="102" width="28" height="6" rx="3" fill="#FFFFFF" />
<rect x="107" y="99" width="2.4" height="12" rx="1.2" fill="#FFFFFF" />
</svg>
);
export type Details = { shape: ShapeId; opacity: number };
const Artwork: React.FC<{ details: Details; size: number; cx: number; cy: number }> = ({ details, size, cx, cy }) => {
if (details.shape === 'dot' || details.opacity <= 0.001) return null;
const style: React.CSSProperties = {
position: 'absolute',
left: cx - size / 2,
top: cy - size / 2,
width: size,
height: size,
opacity: details.opacity,
};
if (details.shape === 'cell') {
return (
<div style={style}>
<CellArt />
</div>
);
}
return <Img src={staticFile(`icons/${details.shape}.svg`)} style={style} />;
};
export type ShapeViewProps = {
d: string;
color: string;
// Ambient glow colour (default: `color`).
glowColor?: string;
cx: number;
cy: number;
k: number;
// App-colour wash over the content.
fill: number;
lift: number;
border?: number;
sweep?: number | null;
details?: Details[];
// Multiplier on shadow and glow, for shapes stacked on one another.
presence?: number;
content?: {
node: ReactNode;
opacity: number;
scale: number;
blur: number;
background: string;
};
};
// One morphing shape: glow, shadow, clipped content, colour wash, artwork, edge.
export const ShapeView: React.FC<ShapeViewProps> = ({
d,
color,
glowColor = color,
cx,
cy,
k,
fill,
lift,
border = 0,
sweep = null,
details = [],
presence = 1,
content,
}) => {
const glowW = 400 * k;
const glowH = glowW * lerp(1, 0.62, lift);
const glowAlpha = lerp(0.3, 0.09, lift) * presence;
const shadow = `drop-shadow(0 ${lerp(6, 34, lift).toFixed(2)}px ${lerp(10, 90, lift).toFixed(2)}px rgba(0,0,0,${(lerp(0.42, 0.6, lift) * presence).toFixed(3)}))`;
const size = 192 * ICON.unit * k;
const sweepX = sweep === null ? 0 : STAGE.x - 500 + sweep * (STAGE.w + 1000);
return (
<AbsoluteFill style={{ pointerEvents: 'none' }}>
<div
style={{
position: 'absolute',
left: cx - glowW / 2,
top: cy - glowH / 2 + 24 * lift,
width: glowW,
height: glowH,
background: `radial-gradient(closest-side, ${rgba(glowColor, glowAlpha)}, ${rgba(glowColor, 0)})`,
}}
/>
<AbsoluteFill style={{ filter: shadow }}>
<AbsoluteFill style={{ clipPath: `path('${d}')` }}>
{content && content.opacity > 0.001 ? (
<AbsoluteFill
style={{
opacity: content.opacity,
transform: `scale(${content.scale})`,
transformOrigin: `${STAGE_CENTER.x}px ${STAGE_CENTER.y}px`,
filter: content.blur > 0.05 ? `blur(${content.blur.toFixed(2)}px)` : undefined,
}}
>
<div
style={{
position: 'absolute',
left: STAGE.x,
top: STAGE.y,
width: STAGE.w,
height: STAGE.h,
background: content.background,
overflow: 'hidden',
}}
>
{content.node}
</div>
</AbsoluteFill>
) : null}
{fill > 0.001 ? (
<AbsoluteFill
style={{
// A soft top light that scales with the shape gives the flat colour depth.
background: `radial-gradient(circle at ${cx.toFixed(1)}px ${(cy - 80 * k).toFixed(1)}px, rgba(255,255,255,0.09), rgba(255,255,255,0) ${(230 * k).toFixed(1)}px), ${color}`,
opacity: fill,
}}
/>
) : null}
</AbsoluteFill>
</AbsoluteFill>
{details.map((detail, i) => (
<Artwork key={`${detail.shape}-${i}`} details={detail} size={size} cx={cx} cy={cy} />
))}
{border > 0.001 || sweep !== null ? (
<svg width={1920} height={1080} style={{ position: 'absolute', inset: 0 }}>
<defs>
<linearGradient id="edge-sweep" gradientUnits="userSpaceOnUse" x1={sweepX - 260} y1={0} x2={sweepX + 260} y2={0}>
<stop offset="0" stopColor="#FFFFFF" stopOpacity="0" />
<stop offset="0.5" stopColor="#FFFFFF" stopOpacity="1" />
<stop offset="1" stopColor="#FFFFFF" stopOpacity="0" />
</linearGradient>
</defs>
<path d={d} fill="none" stroke={`rgba(255,255,255,${(0.08 * border).toFixed(4)})`} strokeWidth={1} />
{sweep !== null ? (
<path d={d} fill="none" stroke="url(#edge-sweep)" strokeWidth={1.25} opacity={0.42 * Math.sin(Math.PI * sweep)} />
) : null}
</svg>
) : null}
</AbsoluteFill>
);
};
@@ -0,0 +1,75 @@
import type { ReactNode } from 'react';
import { AbsoluteFill, useCurrentFrame, useVideoConfig } from 'remotion';
import { COLOR, ENTER_END, EXIT_LEN, STAGE, STAGE_CENTER } from '../theme';
import { roundedRectPath } from './geometry';
import { Heading, type HeadingSpec, headingTimes } from './Heading';
import { type MorphState, SHAPES, STAGE_ZOOM, type ShapeId, enterState, exitState, shapePath } from './morph';
import { ShapeView, mix } from './Shape';
export type StageProps = {
// Icon the stage blooms out of on the section's downbeat.
enter?: { from: ShapeId };
// Icon the stage collapses into on the next section's downbeat.
exit?: { to: ShapeId };
heading?: HeadingSpec | HeadingSpec[];
// Panel colour behind the recording.
background?: string;
children?: ReactNode;
};
const OPEN: MorphState = {
s: 1,
k: STAGE_ZOOM,
cx: STAGE_CENTER.x,
cy: STAGE_CENTER.y,
details: 0,
fill: 0,
content: 1,
contentScale: 1,
blur: 0,
lift: 1,
border: 1,
sweep: null,
};
const OPEN_PATH = roundedRectPath(STAGE.x, STAGE.y, STAGE.w, STAGE.h, STAGE.r);
// The framed screen of a footage section. Children are laid out in stage
// coordinates (0..STAGE.w, 0..STAGE.h) and clipped to the stage's shape.
export const Stage: React.FC<StageProps> = ({ enter, exit, heading, background = COLOR.panel, children }) => {
const frame = useCurrentFrame();
const { durationInFrames } = useVideoConfig();
const entering = enter && frame < ENTER_END;
const exiting = exit && frame >= durationInFrames - EXIT_LEN;
const icon: ShapeId | null = entering ? enter.from : exiting ? exit.to : null;
const state = entering ? enterState(frame) : exiting ? exitState(frame, durationInFrames) : OPEN;
const d = icon === null ? OPEN_PATH : shapePath(icon, 'stage', state.s, state.k, state.cx, state.cy);
const openColor = SHAPES[enter?.from ?? exit?.to ?? 'dot'].color;
const color = icon === null ? openColor : SHAPES[icon].color;
// The open stage glows in its own app's colour; closing hands over gradually.
const glowColor = exiting ? mix(openColor, color, 1 - state.lift) : color;
const sectionAccent = SHAPES[enter?.from ?? exit?.to ?? 'dot'].accent;
const accent = (spec: HeadingSpec) => (spec.app ? SHAPES[spec.app].accent : sectionAccent);
const headings = heading === undefined ? [] : headingTimes(Array.isArray(heading) ? heading : [heading], durationInFrames, accent);
return (
<AbsoluteFill>
<ShapeView
d={d}
color={color}
glowColor={glowColor}
cx={state.cx}
cy={state.cy}
k={state.k}
fill={state.fill}
lift={state.lift}
border={state.border}
sweep={state.sweep}
details={icon === null ? [] : [{ shape: icon, opacity: state.details }]}
content={{ node: children, opacity: state.content, scale: state.contentScale, blur: state.blur, background }}
/>
{headings.map((timing) => (
<Heading key={`${timing.spec.title}-${timing.enter}`} timing={timing} color={accent(timing.spec)} />
))}
</AbsoluteFill>
);
};
@@ -0,0 +1,20 @@
import { cancelRender, continueRender, delayRender, staticFile } from 'remotion';
const FACES = [
{ family: 'Noto Sans SC', file: 'fonts/NotoSansSC.ttf', weight: '100 900' },
{ family: 'Inter', file: 'fonts/Inter.ttf', weight: '100 900' },
{ family: 'JetBrains Mono', file: 'fonts/JetBrainsMono.ttf', weight: '100 800' },
];
const handle = delayRender('Loading fonts', { timeoutInMilliseconds: 120000 });
Promise.all(
FACES.map(async ({ family, file, weight }) => {
const face = new FontFace(family, `url(${staticFile(file)}) format("truetype")`, { weight });
await face.load();
document.fonts.add(face);
}),
).then(
() => continueRender(handle),
(error: unknown) => cancelRender(error),
);
@@ -0,0 +1,186 @@
export type Point = [number, number];
const TAU = Math.PI * 2;
// Quarter (or any) arc sampled in y-down screen space; angles increase clockwise.
export const arc = (cx: number, cy: number, r: number, from: number, to: number, steps: number): Point[] => {
const out: Point[] = [];
for (let i = 0; i <= steps; i++) {
const a = from + ((to - from) * i) / steps;
out.push([cx + r * Math.cos(a), cy + r * Math.sin(a)]);
}
return out;
};
export const roundedRect = (x: number, y: number, w: number, h: number, r: number, steps = 10): Point[] => [
...arc(x + w - r, y + r, r, -TAU / 4, 0, steps),
...arc(x + w - r, y + h - r, r, 0, TAU / 4, steps),
...arc(x + r, y + h - r, r, TAU / 4, TAU / 2, steps),
...arc(x + r, y + r, r, TAU / 2, (TAU * 3) / 4, steps),
];
export const circle = (r: number, steps = 96): Point[] =>
Array.from({ length: steps }, (_, i): Point => [r * Math.cos((TAU * i) / steps - TAU / 4), r * Math.sin((TAU * i) / steps - TAU / 4)]);
// Exact rounded rectangle as an SVG path (arcs), for the open stage.
export const roundedRectPath = (x: number, y: number, w: number, h: number, r: number) =>
`M${x + r} ${y}H${x + w - r}A${r} ${r} 0 0 1 ${x + w} ${y + r}V${y + h - r}A${r} ${r} 0 0 1 ${x + w - r} ${y + h}` +
`H${x + r}A${r} ${r} 0 0 1 ${x} ${y + h - r}V${y + r}A${r} ${r} 0 0 1 ${x + r} ${y}Z`;
export const toPath = (points: Point[], scale: number, cx: number, cy: number) => {
let d = '';
for (let i = 0; i < points.length; i++) {
const [x, y] = points[i];
d += `${i === 0 ? 'M' : 'L'}${(cx + x * scale).toFixed(2)} ${(cy + y * scale).toFixed(2)}`;
}
return `${d}Z`;
};
// ---- Signed-distance silhouettes ------------------------------------------
export type Sdf = (x: number, y: number) => number;
export const sdfCircle = (cx: number, cy: number, r: number): Sdf => (x, y) => Math.hypot(x - cx, y - cy) - r;
export const sdfCapsule = (ax: number, ay: number, bx: number, by: number, r: number): Sdf => {
const dx = bx - ax;
const dy = by - ay;
const len2 = dx * dx + dy * dy;
return (x, y) => {
const t = Math.max(0, Math.min(1, ((x - ax) * dx + (y - ay) * dy) / len2));
return Math.hypot(x - ax - t * dx, y - ay - t * dy) - r;
};
};
export const sdfRoundedBox = (x: number, y: number, w: number, h: number, r: number): Sdf => {
const cx = x + w / 2;
const cy = y + h / 2;
return (px, py) => {
const qx = Math.abs(px - cx) - w / 2 + r;
const qy = Math.abs(py - cy) - h / 2 + r;
return Math.hypot(Math.max(qx, 0), Math.max(qy, 0)) + Math.min(Math.max(qx, qy), 0) - r;
};
};
// A cubic Bézier stroke as a chain of capsules.
export const sdfCubicStroke = (p: [Point, Point, Point, Point], r: number, segments = 32): Sdf => {
const at = (t: number): Point => {
const u = 1 - t;
return [
u * u * u * p[0][0] + 3 * u * u * t * p[1][0] + 3 * u * t * t * p[2][0] + t * t * t * p[3][0],
u * u * u * p[0][1] + 3 * u * u * t * p[1][1] + 3 * u * t * t * p[2][1] + t * t * t * p[3][1],
];
};
const parts: Sdf[] = [];
for (let i = 0; i < segments; i++) {
const a = at(i / segments);
const b = at((i + 1) / segments);
parts.push(sdfCapsule(a[0], a[1], b[0], b[1], r));
}
return union(parts);
};
export const union = (parts: Sdf[]): Sdf => (x, y) => {
let d = Infinity;
for (const part of parts) d = Math.min(d, part(x, y));
return d;
};
// Marching squares on the zero level set; returns the longest closed loop.
export const contour = (sdf: Sdf, x0: number, y0: number, x1: number, y1: number, step: number): Point[] => {
const nx = Math.ceil((x1 - x0) / step) + 1;
const ny = Math.ceil((y1 - y0) / step) + 1;
const v = new Float64Array(nx * ny);
for (let j = 0; j < ny; j++) for (let i = 0; i < nx; i++) v[j * nx + i] = sdf(x0 + i * step, y0 + j * step);
const at = (i: number, j: number) => v[j * nx + i];
const points = new Map<string, Point>();
const links = new Map<string, string[]>();
const edgePoint = (key: string, ax: number, ay: number, bx: number, by: number, va: number, vb: number) => {
if (!points.has(key)) {
const t = va / (va - vb);
points.set(key, [x0 + (ax + (bx - ax) * t) * step, y0 + (ay + (by - ay) * t) * step]);
}
return key;
};
const link = (a: string, b: string) => {
links.set(a, [...(links.get(a) ?? []), b]);
links.set(b, [...(links.get(b) ?? []), a]);
};
for (let j = 0; j < ny - 1; j++) {
for (let i = 0; i < nx - 1; i++) {
const a = at(i, j);
const b = at(i + 1, j);
const c = at(i + 1, j + 1);
const d = at(i, j + 1);
const top = a < 0 !== b < 0 ? edgePoint(`h${i},${j}`, i, j, i + 1, j, a, b) : null;
const right = b < 0 !== c < 0 ? edgePoint(`v${i + 1},${j}`, i + 1, j, i + 1, j + 1, b, c) : null;
const bottom = d < 0 !== c < 0 ? edgePoint(`h${i},${j + 1}`, i, j + 1, i + 1, j + 1, d, c) : null;
const left = a < 0 !== d < 0 ? edgePoint(`v${i},${j}`, i, j, i, j + 1, a, d) : null;
const crossed = [top, right, bottom, left].filter((e): e is string => e !== null);
if (crossed.length === 2) link(crossed[0], crossed[1]);
else if (crossed.length === 4) {
const centreInside = (a + b + c + d) / 4 < 0;
const aInside = a < 0;
if (aInside === centreInside) {
link(top!, right!);
link(bottom!, left!);
} else {
link(top!, left!);
link(right!, bottom!);
}
}
}
}
const seen = new Set<string>();
let best: Point[] = [];
for (const start of links.keys()) {
if (seen.has(start)) continue;
const loop: Point[] = [];
let prev = '';
let cur = start;
while (!seen.has(cur)) {
seen.add(cur);
loop.push(points.get(cur)!);
const next = links.get(cur)!.find((n) => n !== prev && !seen.has(n));
if (!next) break;
prev = cur;
cur = next;
}
if (loop.length > best.length) best = loop;
}
return simplify(best, step * 0.12);
};
// Ramer–Douglas–Peucker on a closed ring.
const simplify = (ring: Point[], tolerance: number): Point[] => {
const keep = new Uint8Array(ring.length);
const walk = (a: number, b: number) => {
let worst = -1;
let dist = tolerance;
const [ax, ay] = ring[a];
const [bx, by] = ring[b];
const len = Math.hypot(bx - ax, by - ay) || 1;
for (let i = a + 1; i < b; i++) {
const d = Math.abs((bx - ax) * (ay - ring[i][1]) - (ax - ring[i][0]) * (by - ay)) / len;
if (d > dist) {
dist = d;
worst = i;
}
}
if (worst >= 0) {
keep[worst] = 1;
walk(a, worst);
walk(worst, b);
}
};
const half = Math.floor(ring.length / 2);
keep[0] = 1;
keep[half] = 1;
walk(0, half);
walk(half, ring.length - 1);
keep[ring.length - 1] = 1;
return ring.filter((_, i) => keep[i] === 1);
};
+259
View File
@@ -0,0 +1,259 @@
import { interpolate as flubber } from 'flubber';
import { interpolate } from 'remotion';
import { type AppId, EASE, ICON, MORPH, STAGE, STAGE_CENTER } from '../theme';
import {
type Point,
circle,
contour,
roundedRect,
sdfCapsule,
sdfCircle,
sdfCubicStroke,
sdfRoundedBox,
toPath,
union,
arc,
} from './geometry';
export type ShapeId = AppId | 'dot' | 'cell';
// Silhouettes in Papirus grid units, centred on the grid centre (96, 96).
const centre = (points: Point[]): Point[] => points.map(([x, y]) => [x - 96, y - 96]);
const Q = Math.PI / 2;
const page = centre([
[40, 16],
[112, 16],
[160, 64],
...arc(152, 168, 8, 0, Q, 8),
...arc(40, 168, 8, Q, 2 * Q, 8),
...arc(40, 24, 8, 2 * Q, 3 * Q, 8),
]);
const board = centre(
contour(
union([sdfRoundedBox(16, 28, 160, 112, 10), sdfCapsule(96, 136, 64, 176, 6), sdfCapsule(96, 136, 128, 176, 6)]),
0,
0,
192,
192,
0.5,
),
);
const branch = centre(
contour(
union([
sdfCapsule(64, 44, 64, 148, 10),
sdfCubicStroke(
[
[64, 128],
[64, 92],
[128, 104],
[128, 72],
],
10,
),
sdfCircle(64, 40, 24),
sdfCircle(128, 64, 24),
sdfCircle(64, 152, 24),
]),
0,
0,
192,
192,
0.5,
),
);
// `color` fills the silhouette; `accent` marks the section heading.
export const SHAPES: Record<ShapeId, { points: Point[]; color: string; accent: string }> = {
'ely-doc': { points: page, color: '#3D7FE5', accent: '#3D7FE5' },
'ely-table': { points: page, color: '#2E9E5B', accent: '#2E9E5B' },
'ely-pdf': { points: page, color: '#E0344F', accent: '#E0344F' },
'ely-show': { points: board, color: '#F07B2A', accent: '#F07B2A' },
'ely-tree': { points: branch, color: '#7E57C2', accent: '#7E57C2' },
'ely-mark': { points: centre(roundedRect(28, 24, 136, 152, 10)), color: '#3E4A5C', accent: '#F2A900' },
cell: { points: centre(roundedRect(16, 51, 160, 90, 8)), color: '#3E4A5C', accent: '#F2A900' },
dot: { points: circle(15), color: '#3D7FE5', accent: '#3D7FE5' },
};
// The open stage, shrunk to icon size so shape and size can morph separately.
const PROXY_W = 168;
const PROXY_H = (PROXY_W * STAGE.h) / STAGE.w;
const PROXY_R = (STAGE.r * PROXY_W) / STAGE.w;
const proxy = roundedRect(-PROXY_W / 2, -PROXY_H / 2, PROXY_W, PROXY_H, PROXY_R, 10);
// Zoom at which the proxy is exactly the stage.
export const STAGE_ZOOM = STAGE.w / (PROXY_W * ICON.unit);
// Rings are resampled into four runs between corresponding anchors (the
// shape's outer corners), so corners travel to corners and nothing shears.
const RUN = 128;
const ANCHORS: Partial<Record<ShapeId, Point[]>> = {
// The board's corners, not the stand's feet.
'ely-show': centre([
[16, 28],
[176, 28],
[176, 140],
[16, 140],
]),
};
const resample = (line: Point[], count: number): Point[] => {
const lengths = [0];
for (let i = 1; i < line.length; i++) lengths.push(lengths[i - 1] + Math.hypot(line[i][0] - line[i - 1][0], line[i][1] - line[i - 1][1]));
const total = lengths[lengths.length - 1];
const out: Point[] = [];
let j = 1;
for (let i = 0; i < count; i++) {
const at = (total * i) / count;
while (j < line.length - 1 && lengths[j] < at) j++;
const span = lengths[j] - lengths[j - 1] || 1;
const u = (at - lengths[j - 1]) / span;
out.push([line[j - 1][0] + (line[j][0] - line[j - 1][0]) * u, line[j - 1][1] + (line[j][1] - line[j - 1][1]) * u]);
}
return out;
};
const prepared = new Map<string, Point[]>();
const prepare = (id: ShapeId | 'stage'): Point[] => {
const found = prepared.get(id);
if (found) return found;
let ring = id === 'stage' ? proxy : SHAPES[id].points;
let area = 0;
for (let i = 0; i < ring.length; i++) {
const [ax, ay] = ring[i];
const [bx, by] = ring[(i + 1) % ring.length];
area += ax * by - bx * ay;
}
// Clockwise on screen.
if (area < 0) ring = [...ring].reverse();
const xs = ring.map((p) => p[0]);
const ys = ring.map((p) => p[1]);
const [x0, x1, y0, y1] = [Math.min(...xs), Math.max(...xs), Math.min(...ys), Math.max(...ys)];
const anchors = (id !== 'stage' && ANCHORS[id]) || [
[x0, y0],
[x1, y0],
[x1, y1],
[x0, y1],
];
const nearest = ([ax, ay]: Point) => ring.reduce((best, p, i) => (Math.hypot(p[0] - ax, p[1] - ay) < Math.hypot(ring[best][0] - ax, ring[best][1] - ay) ? i : best), 0);
const first = nearest(anchors[0]);
ring = [...ring.slice(first), ...ring.slice(0, first)];
const cuts = [0, ...anchors.slice(1).map(nearest), ring.length];
if (!cuts.every((c, i) => i === 0 || c > cuts[i - 1])) throw new Error(`Anchors of ${id} are out of order`);
const out: Point[] = [];
for (let k = 0; k < 4; k++) out.push(...resample([...ring.slice(cuts[k], cuts[k + 1]), ring[cuts[k + 1] % ring.length]], RUN));
prepared.set(id, out);
return out;
};
type Ring = (t: number) => Point[];
const cache = new Map<string, Ring>();
const ring = (from: ShapeId | 'stage', to: ShapeId | 'stage'): Ring => {
const key = `${from}>${to}`;
let found = cache.get(key);
if (!found) {
// Equal, aligned rings: flubber neither bisects nor needs to rotate them.
found = flubber(prepare(from), prepare(to), { string: false, maxSegmentLength: 0 });
cache.set(key, found);
}
return found;
};
// Path of `from` turned `t` of the way into `to`, drawn at zoom `k` around (cx, cy).
export const shapePath = (from: ShapeId | 'stage', to: ShapeId | 'stage', t: number, k: number, cx: number, cy: number) => {
const points = from === to ? prepare(from) : ring(from, to)(t);
return toPath(points, ICON.unit * k, cx, cy);
};
// ---- Boundary choreography ------------------------------------------------
export type MorphState = {
// 0: icon silhouette, 1: stage rectangle.
s: number;
// Zoom of the shape (1 = icon size, STAGE_ZOOM = stage size).
k: number;
cx: number;
cy: number;
// Opacity of the full-colour icon artwork over the silhouette.
details: number;
// Opacity of the app-colour wash over the stage content.
fill: number;
content: number;
contentScale: number;
blur: number;
// 0: icon shadow, 1: stage shadow.
lift: number;
border: number;
// 0..1 travel of the light sweep along the stage edge; null when idle.
sweep: number | null;
};
const clamp = (v: number) => Math.min(1, Math.max(0, v));
const smooth = (v: number, a: number, b: number) => {
const x = clamp((v - a) / (b - a));
return x * x * (3 - 2 * x);
};
const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
// The downbeat swell: the icon breathes in on the cut.
export const boundaryPulse = (d: number) => 0.04 * Math.exp(-((d / 6.5) ** 2));
// Icon resting on a cut, `d` frames from it (negative: before it).
export const restState = (d: number): MorphState => ({
s: 0,
k: 1 + boundaryPulse(d),
cx: ICON.x,
cy: ICON.y,
details: 1 - smooth(Math.abs(d), 10, MORPH.hold),
fill: 1,
content: 0,
contentScale: 0.72,
blur: 14,
lift: 0,
border: 0,
sweep: null,
});
// `o` is how open the stage is (0 icon, 1 stage), in each direction's own time.
const openState = (shape: number, zoom: number, o: number, sweep: number | null): MorphState => ({
s: shape,
k: Math.exp(Math.log(STAGE_ZOOM) * zoom),
cx: lerp(ICON.x, STAGE_CENTER.x, zoom),
cy: lerp(ICON.y, STAGE_CENTER.y, zoom),
details: 0,
fill: 1 - smooth(o, 0.32, 0.82),
content: smooth(o, 0.22, 0.7),
contentScale: lerp(0.72, 1, EASE.out(o)),
blur: 14 * (1 - o) ** 2,
lift: o,
border: smooth(o, 0.8, 1),
sweep,
});
// Section-local frame `f` of an entering stage.
export const enterState = (f: number): MorphState => {
if (f < MORPH.hold) return restState(f);
const o = clamp((f - MORPH.hold) / MORPH.morph);
const shape = EASE.inOut(clamp(o / 0.6));
const zoom = EASE.bloom(o);
const sweep = o > 0.55 ? clamp((o - 0.55) / 0.45) : null;
return openState(shape, zoom, zoom, sweep);
};
// Section-local frame `f` of a stage in a section `duration` frames long.
export const exitState = (f: number, duration: number): MorphState => {
const d = f - duration;
if (d >= -MORPH.hold) return restState(d);
const q = clamp((d + MORPH.hold + MORPH.morph) / MORPH.morph);
const zoom = 1 - EASE.land(q);
const shape = 1 - EASE.inOut(clamp((q - 0.22) / 0.78));
return openState(shape, zoom, zoom, null);
};
export const isOpen = (state: MorphState) => state.s >= 1 && state.k >= STAGE_ZOOM - 1e-6;
export const fade = (f: number, from: number, to: number, ease = EASE.out) =>
interpolate(f, [from, to], [0, 1], { extrapolateLeft: 'clamp', extrapolateRight: 'clamp', easing: ease });