Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "word-acts",
"title": "Word Acts",
"description": "Short acts of one word each, with changing styles, end on a gradient word.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"files": [
{
"path": "registry/remocn/word-acts/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadDisplay } from \"@remotion/google-fonts/Geist\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n AbsoluteFill,\n Easing,\n interpolate,\n spring,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: display } = loadDisplay(\"normal\", {\n weights: [\"100\", \"200\", \"300\", \"400\", \"500\"],\n subsets: [\"latin\"],\n});\n\nexport type WordAct = \"stretch\" | \"split\" | \"heavy\" | \"faster\" | \"rebuilt\";\n\nexport interface WordActBeat {\n word: string;\n act: WordAct;\n /** Frames this act stays on screen. The last act also gets `hold`. */\n frames?: number;\n}\n\nexport interface WordActsProps {\n /**\n * Each word performs its meaning. `rebuilt` draws its word from geometric\n * strokes, so it supports lowercase a–z only.\n */\n acts?: WordActBeat[];\n /** Extra frames the final word holds as a poster. */\n hold?: number;\n accent?: string;\n /** Playback multiplier. */\n speed?: number;\n theme?: \"dark\" | \"light\";\n}\n\nconst DEFAULT_FRAMES: Record<WordAct, number> = {\n stretch: 26,\n split: 26,\n heavy: 28,\n faster: 22,\n rebuilt: 42,\n};\n\nconst DEFAULT_ACTS: WordActBeat[] = [\n { word: \"stretch\", act: \"stretch\" },\n { word: \"split\", act: \"split\" },\n { word: \"heavy\", act: \"heavy\" },\n { word: \"faster\", act: \"faster\" },\n { word: \"rebuilt\", act: \"rebuilt\" },\n];\n\nconst THEMES = {\n dark: { bg: \"#0A0A0B\", fg: \"#F5F4F0\", guide: \"rgba(245,244,240,0.14)\" },\n light: { bg: \"#F5F4F0\", fg: \"#0A0A0B\", guide: \"rgba(10,10,11,0.14)\" },\n} as const;\n\n/**\n * gradients.sh \"halo\": blue through rose into amber and a warm white. The\n * neighbours mix cleanly (violet, coral) so a sweep never goes muddy.\n */\nconst HALO = [\"#fff4ec\", \"#ffb36b\", \"#e2457a\", \"#3d4dff\"] as const;\nconst inkStops = (theme: \"dark\" | \"light\") =>\n theme === \"dark\"\n ? [HALO[3], HALO[2], HALO[1], HALO[0]]\n : [HALO[3], HALO[2], HALO[1]];\n\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\n/** Geist 400–500 advance per lowercase character at display tracking, in em. */\nconst ADVANCE = 0.44;\n/** Geist with lineHeight 1: baseline and x-height middle from the top. */\nconst BASELINE = 0.855;\nconst X_MID = 0.59;\n\ninterface ActProps {\n word: string;\n t: number;\n dur: number;\n W: number;\n H: number;\n fg: string;\n accent: string;\n /** Three palette stops for the marks and the rebuilt strokes. */\n ink: string[];\n guide: string;\n fps: number;\n}\n\nconst fitSize = (word: string, target: number, maxWidth: number) =>\n Math.min(target, maxWidth / Math.max(1, word.length * ADVANCE));\n\nconst wordStyle = (size: number, weight: number): React.CSSProperties => ({\n fontFamily: display,\n fontWeight: weight,\n fontSize: size,\n lineHeight: 1,\n letterSpacing: \"-0.035em\",\n whiteSpace: \"nowrap\",\n});\n\nfunction Stretch({ word, t, W, H, fg }: ActProps) {\n const size = fitSize(word, H * 0.3, W * 0.42);\n const p = interpolate(t, [2, 17], [0, 1], { ...CLAMP, easing: EASE_IO });\n const sx = 1 + p * 0.95;\n const sy = 1 - p * 0.06;\n // The stems thin out as the word is pulled, like taffy, so the stretched\n // word never reads heavier than the 500 it starts at.\n const wght = Math.round(500 - p * 230);\n return (\n <AbsoluteFill style={{ alignItems: \"center\", justifyContent: \"center\" }}>\n <div\n style={{\n ...wordStyle(size, 500),\n fontVariationSettings: `\"wght\" ${wght}`,\n color: fg,\n transform: `scale(${sx}, ${sy})`,\n }}\n >\n {word}\n </div>\n </AbsoluteFill>\n );\n}\n\nfunction Split({ word, t, W, H, fg, ink }: ActProps) {\n const size = fitSize(word, H * 0.4, W * 0.6);\n const draw = interpolate(t, [2, 8], [0, 1], { ...CLAMP, easing: EASE_OUT });\n const open = interpolate(t, [8, 19], [0, 1], { ...CLAMP, easing: EASE_OUT });\n const lineFade = interpolate(t, [9, 15], [1, 0], CLAMP);\n const dx = open * W * 0.034;\n const dy = open * size * 0.035;\n const width = word.length * ADVANCE * size;\n const half = (top: boolean) => (\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: top ? 0 : X_MID * size,\n height: top ? X_MID * size : size * 0.6,\n overflow: \"hidden\",\n transform: `translate(${top ? -dx : dx}px, ${top ? -dy : dy}px)`,\n }}\n >\n <div\n style={{\n ...wordStyle(size, 500),\n color: fg,\n textAlign: \"center\",\n marginTop: top ? 0 : -X_MID * size,\n }}\n >\n {word}\n </div>\n </div>\n );\n return (\n <AbsoluteFill style={{ alignItems: \"center\", justifyContent: \"center\" }}>\n <div style={{ position: \"relative\", width: width * 1.3, height: size }}>\n {half(true)}\n {half(false)}\n <div\n style={{\n position: \"absolute\",\n left: 0,\n top: X_MID * size - H * 0.003,\n height: Math.max(2, H * 0.006),\n width: `${draw * 100}%`,\n backgroundImage: `linear-gradient(90deg, ${ink.join(\", \")})`,\n opacity: lineFade,\n }}\n />\n </div>\n </AbsoluteFill>\n );\n}\n\nfunction Heavy({ word, t, W, H, fg, ink, fps }: ActProps) {\n const size = fitSize(word, H * 0.36, W * 0.58);\n const LAND = 9;\n const fall = interpolate(t, [0, LAND], [0, 1], {\n ...CLAMP,\n easing: Easing.bezier(0.55, 0, 1, 0.45),\n });\n const restTop = H * 0.5 - size * 0.55;\n const startTop = -size * 0.62;\n const impact = spring({\n frame: t - LAND,\n fps,\n config: { damping: 9, stiffness: 260, mass: 0.7 },\n });\n // impact: 0 → 1 with a small ring; squash peaks right at contact.\n const ring = t < LAND ? 0 : 1 - impact;\n const squash = Math.max(-0.05, ring) * 0.16;\n const sy = 1 - squash;\n const sx = 1 + squash * 0.45;\n const top = startTop + (restTop - startTop) * fall;\n const ruleDip = t < LAND ? 0 : ring * H * 0.018;\n const ruleWidth = word.length * ADVANCE * size * 1.12;\n const baseline = restTop + BASELINE * size;\n return (\n <AbsoluteFill>\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top,\n textAlign: \"center\",\n ...wordStyle(size, 500),\n // Weight builds with the fall, hairline to 500; the face is variable.\n fontVariationSettings: `\"wght\" ${Math.round(100 + fall * 400)}`,\n color: fg,\n transform: `scale(${sx}, ${sy})`,\n transformOrigin: `50% ${BASELINE * 100}%`,\n }}\n >\n {word}\n </div>\n <div\n style={{\n position: \"absolute\",\n left: (W - ruleWidth) / 2,\n width: ruleWidth,\n top: baseline + size * 0.27 + ruleDip,\n height: Math.max(3, H * 0.006),\n backgroundImage: `linear-gradient(90deg, ${ink.join(\", \")})`,\n }}\n />\n </AbsoluteFill>\n );\n}\n\nfunction Faster({ word, t, W, H, fg, ink }: ActProps) {\n const size = fitSize(word, H * 0.34, W * 0.6);\n const SNAP = 7;\n const overshoot = -W * 0.018;\n const posAt = (f: number) => {\n if (f < SNAP) {\n const run = interpolate(f, [0, SNAP], [0, 1], {\n ...CLAMP,\n easing: Easing.bezier(0.1, 0.6, 0.2, 1),\n });\n return W * 0.95 * (1 - run) + overshoot * run;\n }\n const settle = interpolate(f, [SNAP, SNAP + 5], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n return overshoot * (1 - settle);\n };\n const x = posAt(t);\n const v = Math.min(1, Math.max(0, posAt(t - 1) - x) / (W * 0.12));\n // Leans into the rush, then rocks back past upright as it snaps.\n const rock = interpolate(t, [SNAP, SNAP + 2, SNAP + 6], [0, 4, 0], CLAMP);\n const skew = -14 * v + rock;\n const width = word.length * ADVANCE * size;\n const lines = [0.42, 0.56, 0.68, 0.8];\n return (\n <AbsoluteFill style={{ alignItems: \"center\", justifyContent: \"center\" }}>\n <div\n style={{\n position: \"relative\",\n transform: `translateX(${x}px)`,\n }}\n >\n <div\n style={{\n ...wordStyle(size, 500),\n color: fg,\n transform: `skewX(${skew}deg)`,\n }}\n >\n {word}\n </div>\n {lines.map((y, i) => {\n const len = v * W * (0.22 + ((i * 37) % 11) / 45);\n return (\n <div\n key={y}\n style={{\n position: \"absolute\",\n left: width * 0.96 + (i % 2) * size * 0.1,\n top: y * size,\n width: len,\n height: Math.max(2, size * 0.026),\n borderRadius: H,\n backgroundImage:\n i === 1\n ? `linear-gradient(90deg, ${ink[0]}, ${ink[1]} 70%, transparent)`\n : `linear-gradient(90deg, ${fg}, transparent)`,\n opacity: v > 0.03 ? 1 : 0,\n }}\n />\n );\n })}\n </div>\n </AbsoluteFill>\n );\n}\n\n/* ---------- rebuilt: a geometric stroke alphabet ---------- */\n\ntype Stroke =\n | { k: \"l\"; x1: number; y1: number; x2: number; y2: number }\n | { k: \"a\"; cx: number; cy: number; r: number; a0: number; a1: number }\n | { k: \"p\"; pts: [number, number][] }\n | { k: \"d\"; cx: number; cy: number; r: number };\n\nconst L = (x1: number, y1: number, x2: number, y2: number): Stroke => ({\n k: \"l\",\n x1,\n y1,\n x2,\n y2,\n});\nconst A = (\n cx: number,\n cy: number,\n r: number,\n a0: number,\n a1: number,\n): Stroke => ({\n k: \"a\",\n cx,\n cy,\n r,\n a0,\n a1,\n});\nconst P = (...pts: [number, number][]): Stroke => ({ k: \"p\", pts });\nconst D = (cx: number, cy: number, r: number): Stroke => ({\n k: \"d\",\n cx,\n cy,\n r,\n});\n\nconst O = A(25, -25, 19, 0, 360);\nconst SW = 8;\nconst XH = 50;\nconst ASC = 78;\nconst GAP = 8;\n\nconst GLYPHS: Record<string, { w: number; s: Stroke[] }> = {\n a: { w: 50, s: [O, L(44, -50, 44, 0)] },\n b: { w: 50, s: [L(6, -ASC, 6, 0), O] },\n c: { w: 46, s: [A(25, -25, 19, -45, -315)] },\n d: { w: 50, s: [O, L(44, -ASC, 44, 0)] },\n e: { w: 50, s: [L(6, -25, 44, -25), A(25, -25, 19, 0, -318)] },\n f: {\n w: 32,\n s: [L(14, -59, 14, 0), A(27, -59, 13, 180, 320), L(0, -44, 30, -44)],\n },\n g: { w: 50, s: [O, L(44, -50, 44, 8), A(25, 8, 19, 0, 150)] },\n h: {\n w: 50,\n s: [L(6, -ASC, 6, 0), A(25, -25, 19, 180, 360), L(44, -25, 44, 0)],\n },\n i: { w: 12, s: [L(6, -50, 6, 0), D(6, -67, 7.5)] },\n j: { w: 16, s: [L(10, -50, 10, 10), A(-6, 10, 16, 0, 140), D(10, -67, 7.5)] },\n k: { w: 44, s: [L(6, -ASC, 6, 0), L(42, -50, 6, -16), L(20, -29, 44, 0)] },\n l: { w: 12, s: [L(6, -ASC, 6, 0)] },\n m: {\n w: 80,\n s: [\n L(6, -50, 6, 0),\n A(23, -27, 17, 180, 360),\n L(40, -27, 40, 0),\n A(57, -27, 17, 180, 360),\n L(74, -27, 74, 0),\n ],\n },\n n: {\n w: 50,\n s: [L(6, -50, 6, 0), A(25, -25, 19, 180, 360), L(44, -25, 44, 0)],\n },\n o: { w: 50, s: [O] },\n p: { w: 50, s: [L(6, -50, 6, 26), O] },\n q: { w: 50, s: [O, L(44, -50, 44, 26)] },\n r: { w: 34, s: [L(6, -50, 6, 0), A(25, -25, 19, 180, 290)] },\n s: { w: 44, s: [A(23, -37, 11, -25, -270), A(23, -14, 11, -90, 155)] },\n t: { w: 30, s: [L(14, -70, 14, 0), L(0, -44, 30, -44)] },\n u: {\n w: 50,\n s: [L(6, -50, 6, -25), A(25, -25, 19, 180, 0), L(44, -50, 44, 0)],\n },\n v: { w: 46, s: [P([3, -50], [23, -10], [43, -50])] },\n w: { w: 66, s: [P([2, -50], [18, -10], [33, -46], [48, -10], [64, -50])] },\n x: { w: 46, s: [L(4, -50, 42, 0), L(42, -50, 4, 0)] },\n y: { w: 46, s: [L(3, -50, 23, -4), L(43, -50, 12, 26)] },\n z: { w: 46, s: [P([4, -44], [40, -44], [6, -6], [42, -6])] },\n};\n\nconst pt = (cx: number, cy: number, r: number, deg: number) => {\n const a = (deg * Math.PI) / 180;\n return [cx + r * Math.cos(a), cy + r * Math.sin(a)] as const;\n};\n\nfunction arcPath(cx: number, cy: number, r: number, a0: number, a1: number) {\n const delta = a1 - a0;\n if (Math.abs(delta) >= 360) {\n const [x0, y0] = pt(cx, cy, r, a0);\n const [xm, ym] = pt(cx, cy, r, a0 + 180);\n return `M${x0} ${y0}A${r} ${r} 0 1 1 ${xm} ${ym}A${r} ${r} 0 1 1 ${x0} ${y0}`;\n }\n const [x0, y0] = pt(cx, cy, r, a0);\n const [x1, y1] = pt(cx, cy, r, a1);\n const large = Math.abs(delta) > 180 ? 1 : 0;\n const sweep = delta > 0 ? 1 : 0;\n return `M${x0} ${y0}A${r} ${r} 0 ${large} ${sweep} ${x1} ${y1}`;\n}\n\nfunction strokeCenter(s: Stroke): [number, number] {\n switch (s.k) {\n case \"l\":\n return [(s.x1 + s.x2) / 2, (s.y1 + s.y2) / 2];\n case \"d\":\n return [s.cx, s.cy];\n case \"p\": {\n const xs = s.pts.map((p) => p[0]);\n const ys = s.pts.map((p) => p[1]);\n return [\n (Math.min(...xs) + Math.max(...xs)) / 2,\n (Math.min(...ys) + Math.max(...ys)) / 2,\n ];\n }\n case \"a\": {\n if (Math.abs(s.a1 - s.a0) >= 360) return [s.cx, s.cy];\n const [x, y] = pt(s.cx, s.cy, s.r * 0.6, (s.a0 + s.a1) / 2);\n return [x, y];\n }\n }\n}\n\nconst hash = (n: number) => {\n const x = Math.sin(n * 127.1 + 311.7) * 43758.5453;\n return x - Math.floor(x);\n};\n\nfunction Rebuilt({ word, t, W, H, ink, guide }: ActProps) {\n const gradId = `wa-ink-${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n const letters = word.toLowerCase().split(\"\");\n let cursor = 0;\n const placed: { s: Stroke; ox: number }[] = [];\n for (const ch of letters) {\n const g = GLYPHS[ch];\n if (!g) {\n cursor += 26 + GAP;\n continue;\n }\n for (const s of g.s) placed.push({ s, ox: cursor });\n cursor += g.w + GAP;\n }\n const total = Math.max(1, cursor - GAP);\n const unit = Math.min((W * 0.6) / total, (H * 0.46) / (ASC + 26));\n const midX = total / 2;\n const midY = -XH / 2;\n\n const n = placed.length;\n const OUT0 = 5;\n const OUT1 = 16;\n const IN0 = 22;\n const IN1 = 36;\n const guides = Math.min(\n interpolate(t, [OUT0, OUT1], [0, 1], CLAMP),\n interpolate(t, [IN1 - 4, IN1 + 6], [1, 0], CLAMP),\n );\n\n return (\n <AbsoluteFill style={{ alignItems: \"center\", justifyContent: \"center\" }}>\n <svg\n width={W}\n height={H}\n viewBox={`${-W / 2 / unit + midX} ${-H / 2 / unit + midY} ${W / unit} ${H / unit}`}\n style={{ position: \"absolute\", inset: 0 }}\n aria-hidden\n >\n <defs>\n {/* The palette is fixed to the word's footprint: scattered strokes\n carry the colour of where they belong, and the poster reads as\n one sweep from blue to warm. */}\n {placed.map(({ ox }, i) => (\n // Each stroke is drawn in its glyph's local space, so its\n // gradient is shifted back by the glyph's home offset.\n <linearGradient\n key={i}\n id={`${gradId}-${i}`}\n gradientUnits=\"userSpaceOnUse\"\n x1={-ox}\n y1={-ASC}\n x2={total - ox}\n y2={0}\n >\n {ink.map((c, k) => (\n <stop key={c} offset={k / (ink.length - 1)} stopColor={c} />\n ))}\n </linearGradient>\n ))}\n </defs>\n {[0, -XH, -ASC].map((y) => (\n <line\n key={y}\n x1={midX - W / unit}\n x2={midX + W / unit}\n y1={y}\n y2={y}\n stroke={guide}\n strokeWidth={1 / unit}\n opacity={guides}\n />\n ))}\n {placed.map(({ s, ox }, i) => {\n const [cx, cy] = strokeCenter(s);\n const gx = cx + ox;\n const order = i / Math.max(1, n - 1);\n const out = interpolate(\n t,\n [OUT0 + order * 3, OUT1 + order * 3],\n [0, 1],\n { ...CLAMP, easing: EASE_IO },\n );\n const back = interpolate(\n t,\n [IN0 + order * 5, IN1 + order * 5 - 4],\n [0, 1],\n { ...CLAMP, easing: Easing.bezier(0.2, 1.25, 0.4, 1) },\n );\n const e = out * (1 - back);\n const ex = (gx - midX) * 0.26 + (hash(i + 1) - 0.5) * 18;\n const ey = (cy - midY) * 0.7 + (hash(i + 7) - 0.5) * 56;\n const rot = (hash(i + 13) - 0.5) * 70;\n const transform = `translate(${ox + ex * e} ${ey * e}) rotate(${rot * e} ${cx} ${cy})`;\n if (s.k === \"d\") {\n return (\n <g key={i} transform={transform}>\n <circle\n cx={s.cx}\n cy={s.cy}\n r={s.r * 0.8}\n fill={`url(#${gradId}-${i})`}\n />\n </g>\n );\n }\n const d =\n s.k === \"l\"\n ? `M${s.x1} ${s.y1}L${s.x2} ${s.y2}`\n : s.k === \"a\"\n ? arcPath(s.cx, s.cy, s.r, s.a0, s.a1)\n : `M${s.pts.map((p) => p.join(\" \")).join(\"L\")}`;\n return (\n <g key={i} transform={transform}>\n <path\n d={d}\n fill=\"none\"\n stroke={`url(#${gradId}-${i})`}\n strokeWidth={SW}\n strokeLinecap=\"butt\"\n strokeLinejoin=\"miter\"\n />\n </g>\n );\n })}\n </svg>\n </AbsoluteFill>\n );\n}\n\nconst ACTS: Record<WordAct, (p: ActProps) => React.ReactElement> = {\n stretch: Stretch,\n split: Split,\n heavy: Heavy,\n faster: Faster,\n rebuilt: Rebuilt,\n};\n\nexport function WordActs({\n acts = DEFAULT_ACTS,\n hold = 32,\n accent = \"#3B5BFD\",\n speed = 1,\n theme = \"dark\",\n}: WordActsProps) {\n const frame = useCurrentFrame() * speed;\n const { width: W, height: H, fps } = useVideoConfig();\n const c = THEMES[theme];\n\n let start = 0;\n let index = acts.length - 1;\n let local = 0;\n let dur = 1;\n for (let i = 0; i < acts.length; i++) {\n const len = acts[i].frames ?? DEFAULT_FRAMES[acts[i].act];\n const last = i === acts.length - 1;\n if (frame < start + len || last) {\n index = i;\n local = frame - start;\n dur = len + (last ? hold : 0);\n break;\n }\n start += len;\n }\n const beat = acts[index];\n const Act = ACTS[beat.act];\n\n return (\n <AbsoluteFill style={{ backgroundColor: c.bg, overflow: \"hidden\" }}>\n {beat ? (\n <Act\n word={beat.word}\n t={local}\n dur={dur}\n W={W}\n H={H}\n fg={c.fg}\n accent={accent}\n ink={inkStops(theme)}\n guide={c.guide}\n fps={fps}\n />\n ) : null}\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/word-acts.tsx"
}
],
"type": "registry:component"
}