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": "letter-gate",
"title": "Letter Gate",
"description": "The camera pushes into a giant letter pair, the gap opens like a gate onto the next scene.",
"dependencies": [
"remotion",
"@remotion/google-fonts",
"@remotion/transitions"
],
"registryDependencies": ["@remocn/gsh"],
"files": [
{
"path": "registry/remocn/letter-gate/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadGeist } from \"@remotion/google-fonts/Geist\";\nimport { loadFont as loadMono } from \"@remotion/google-fonts/GeistMono\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport {\n linearTiming,\n type TransitionPresentation,\n type TransitionPresentationComponentProps,\n TransitionSeries,\n} from \"@remotion/transitions\";\nimport type React from \"react\";\nimport { useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport {\n AbsoluteFill,\n continueRender,\n delayRender,\n Easing,\n spring,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/remocn/gsh/gradient-engine\";\nimport { GshGround } from \"@/lib/remocn/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/remocn/gsh/presets\";\n\nconst geist = loadGeist(\"normal\", {\n weights: [\"300\", \"400\"],\n subsets: [\"latin\"],\n});\nconst mono = loadMono(\"normal\", { weights: [\"400\"], subsets: [\"latin\"] });\nconst manrope = loadManrope(\"normal\", {\n weights: [\"600\"],\n subsets: [\"latin\"],\n});\n\nconst REMOCN_R_PATH =\n \"M 0.01 0.81 C 0.01 1.73, 0.36 2.79, 1.09 4.13 C 4.91 11.04, 13.45 17.16, 21.7 18.9 C 22.94 19.16, 23.18 19.16, 51.39 19.27 C 76.07 19.36, 80.02 19.4, 81.32 19.57 C 89.89 20.69, 96.2 24.68, 99.38 31.01 C 103.19 38.56, 102.53 50.1, 97.91 57.07 C 94.66 61.96, 89.68 64.99, 83.26 66 C 82.81 66.07, 70.18 66.83, 55.2 67.69 C 24.82 69.43, 27.03 69.23, 24.18 70.4 C 19.9 72.15, 14.84 75.7, 10.65 79.89 C 4.86 85.68, 1.3 91.91, 0.25 98.13 C 0.12 98.85, 0.08 103.13, 0.04 116.66 L 0 134.26 9.5 134.26 L 19 134.26 19.05 119.41 C 19.1 103.27, 19.08 103.82, 19.82 101.04 C 21.79 93.65, 27.86 88.75, 36.45 87.63 C 37.23 87.53, 39.41 87.5, 43.57 87.53 C 50.12 87.59, 50.75 87.65, 53.22 88.45 C 56.61 89.56, 59.67 91.86, 62.02 95.07 C 62.52 95.76, 69.35 103.85, 77.2 113.07 C 85.04 122.28, 91.63 130.04, 91.85 130.32 C 92.07 130.59, 92.5 131.34, 92.82 131.97 C 93.52 133.35, 94.11 133.93, 95.06 134.13 C 95.5 134.23, 98.97 134.26, 106.36 134.23 L 117.01 134.19 100.82 113.07 C 91.91 101.45, 84.52 91.78, 84.39 91.57 C 83.36 89.89, 83.66 87.53, 85.09 86 C 85.79 85.25, 86.36 84.94, 88.07 84.38 C 96.18 81.72, 104.15 76.62, 109.97 70.36 C 120.59 58.93, 124.06 44.32, 119.44 30.43 C 114.59 15.81, 101.93 4.02, 87.64 0.83 C 83.93 0.01, 88.09 0.08, 41.85 0.04 L 0.01 0 0.01 0.81 Z\";\n\nfunction RemocnLogo({ fontSize, color }: { fontSize: number; color: string }) {\n return (\n <div\n style={{\n display: \"flex\",\n alignItems: \"baseline\",\n color,\n fontFamily: manrope.fontFamily,\n fontWeight: 600,\n fontSize,\n letterSpacing: \"-0.025em\",\n lineHeight: 1,\n }}\n >\n <svg\n viewBox=\"0 0 124.06 134.26\"\n style={{ height: \"0.76em\", width: \"auto\" }}\n aria-hidden\n >\n <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n </svg>\n <span style={{ marginLeft: \"0.04em\" }}>emocn</span>\n </div>\n );\n}\n\nconst MPX = 100;\n\ntype Metrics = {\n width: (s: string) => number;\n ink: (ch: string) => { left: number; right: number };\n xh: number;\n asc: number;\n desc: number;\n};\n\nfunction buildMetrics(family: string, weight: number, _version: number) {\n const ctx =\n typeof document !== \"undefined\"\n ? document.createElement(\"canvas\").getContext(\"2d\")\n : null;\n const font = `${weight} ${MPX}px \"${family}\"`;\n const wCache: Record<string, number> = {};\n const metrics: Metrics = {\n width: (s: string) => {\n if (wCache[s] === undefined) {\n if (!ctx) return s.length * 0.55;\n ctx.font = font;\n wCache[s] = ctx.measureText(s).width / MPX;\n }\n return wCache[s];\n },\n ink: (ch: string) => {\n if (!ctx) return { left: 0.04, right: 0.52 };\n ctx.font = font;\n const m = ctx.measureText(ch);\n return {\n left: -m.actualBoundingBoxLeft / MPX,\n right: m.actualBoundingBoxRight / MPX,\n };\n },\n xh: (() => {\n if (!ctx) return 0.53;\n ctx.font = font;\n return ctx.measureText(\"x\").actualBoundingBoxAscent / MPX;\n })(),\n asc: 0.94,\n desc: 0.22,\n };\n if (ctx) {\n ctx.font = font;\n const box = ctx.measureText(\"x\");\n metrics.asc = box.fontBoundingBoxAscent / MPX;\n metrics.desc = box.fontBoundingBoxDescent / MPX;\n }\n return metrics;\n}\n\nfunction useMetrics(family: string, weight: number, label: string) {\n const [version, setVersion] = useState(0);\n const [handle] = useState(() => delayRender(`letter-gate: ${label}`));\n const released = useRef(false);\n useEffect(() => {\n let live = true;\n const bump = () => {\n if (live) setVersion((v) => v + 1);\n };\n document.fonts.addEventListener(\"loadingdone\", bump);\n Promise.all([\n geist.waitUntilDone(),\n document.fonts.load(`${weight} ${MPX}px \"${family}\"`),\n ])\n .catch(() => undefined)\n .then(() => {\n bump();\n if (!released.current) {\n released.current = true;\n continueRender(handle);\n }\n });\n return () => {\n live = false;\n document.fonts.removeEventListener(\"loadingdone\", bump);\n };\n }, [handle, family, weight]);\n return useMemo(\n () => buildMetrics(family, weight, version),\n [family, weight, version],\n );\n}\n\nconst MOVE = Easing.bezier(0.65, 0, 0.35, 1);\nconst ENTER = Easing.bezier(0.22, 1, 0.36, 1);\nconst EXIT = Easing.bezier(0.7, 0, 0.84, 0);\nconst CARD = { mass: 0.8, damping: 18, stiffness: 160 };\nconst CHIP = { mass: 0.5, damping: 12, stiffness: 200 };\n\nconst clamp01 = (v: number) => Math.min(1, Math.max(0, v));\nconst lerp = (a: number, b: number, t: number) => a + (b - a) * t;\n\nexport type LetterGateProps = {\n letters?: string;\n fontFamily?: string;\n fontWeight?: number;\n ink?: string;\n /** Point of the outgoing scene (0–1) that the push carries to frame centre. */\n focus?: [number, number];\n /** Share of the transition spent pushing into the outgoing scene. */\n cut?: number;\n zoom?: number;\n size?: number;\n depth?: number;\n};\n\nexport const letterGateDefaults: Required<LetterGateProps> = {\n letters: \"bu\",\n fontFamily: geist.fontFamily,\n fontWeight: 400,\n ink: \"#16181d\",\n focus: [0.5, 0.5],\n cut: 0.38,\n zoom: 3.4,\n size: 1.12,\n depth: 1.1,\n};\n\nconst LETTER_TRACK = -0.02;\nconst SWAP = 0.12;\nconst PUSH_BLUR = 5;\n\nconst travel = (q: number) => 0.32 * q + 0.68 * q ** 1.9;\n\nconst FILL: React.CSSProperties = { position: \"absolute\", inset: 0 };\n\nconst LetterGatePresentation: React.FC<\n TransitionPresentationComponentProps<LetterGateProps>\n> = ({\n children,\n presentationProgress: p,\n presentationDirection,\n presentationDurationInFrames,\n passedProps,\n}) => {\n const { width: W, height: H } = useVideoConfig();\n const o = { ...letterGateDefaults, ...passedProps };\n const uid = useId().replace(/:/g, \"\");\n const m = useMetrics(o.fontFamily, o.fontWeight, \"gate glyphs\");\n const q = clamp01((p - o.cut) / (1 - o.cut));\n\n if (presentationDirection === \"exiting\") {\n const t = clamp01(p / o.cut);\n // The push accelerates straight into the cut: it never decelerates onto\n // the magnified pair, so there is no held frame before the gate opens.\n const e = t ** 1.6;\n const z = Math.exp(Math.log(o.zoom) * e);\n const tx = (0.5 - o.focus[0]) * W * e;\n const ty = (0.5 - o.focus[1]) * H * e;\n const blur = PUSH_BLUR * t * t;\n return (\n <div\n style={{\n ...FILL,\n opacity: q > 0 ? 0 : 1,\n filter: blur > 0.2 ? `blur(${blur.toFixed(2)}px)` : undefined,\n }}\n >\n <div\n style={{\n ...FILL,\n transform: `translate(${tx}px, ${ty}px) scale(${z})`,\n transformOrigin: `${o.focus[0] * 100}% ${o.focus[1] * 100}%`,\n }}\n >\n {children}\n </div>\n </div>\n );\n }\n\n const shown = p >= o.cut ? 1 : 0;\n // Match cut: the glyphs take over at full strength on the cut frame, and\n // only the scene behind them dissolves in.\n const sceneIn = clamp01(q / SWAP);\n // Parting starts on the cut itself: the glyphs never hold, they open while\n // the new scene dissolves in under them.\n const frames = Math.max(1, presentationDurationInFrames * (1 - o.cut));\n // The gate is already opening on the cut frame, so the pair is never seen\n // closed and still.\n const g = clamp01(q + 2 / frames);\n const dg = 1 / frames;\n const bScale = lerp(o.depth, 1, ENTER(q));\n const bBlur = 14 * (1 - ENTER(clamp01(q / 0.85)));\n\n const chars = Array.from(o.letters);\n const first = chars[0] ?? \"b\";\n const second = chars[1] ?? \"u\";\n const Fm = Math.min(H * o.size, W * 0.95);\n const boundary =\n (m.width(first + second) - m.width(second) + LETTER_TRACK) * Fm;\n const reach = W * 0.5 + Fm * 0.7;\n const d = travel(g) * reach;\n const v = (travel(g) - travel(Math.max(0, g - dg))) * reach;\n // Carries the push's momentum: a quick extra swell that hands over to the\n // slower spread.\n const s = 1 + 0.18 * (1 - (1 - g) ** 4) + 0.45 * g * g;\n const blurX = Math.min(48, v * 0.22);\n const baseline = H / 2 + (m.xh * Fm) / 2;\n const leftX = W / 2 - boundary - d;\n const rightX = W / 2 + d;\n const lInk = m.ink(first);\n const rInk = m.ink(second);\n const leftGone = leftX + lInk.right * Fm < W / 2 - (W / 2) * (1 / s) - 4;\n const rightGone = rightX + rInk.left * Fm > W / 2 + (W / 2) * (1 / s) + 4;\n\n return (\n <div style={{ ...FILL, opacity: shown }}>\n <div\n style={{\n ...FILL,\n opacity: sceneIn,\n transform: `scale(${bScale})`,\n filter: bBlur > 0.2 ? `blur(${bBlur.toFixed(2)}px)` : undefined,\n }}\n >\n {children}\n </div>\n <svg\n width={W}\n height={H}\n style={{ ...FILL, overflow: \"visible\" }}\n aria-hidden\n >\n <defs>\n <filter\n id={`${uid}-smear`}\n x=\"-60%\"\n y=\"-10%\"\n width=\"220%\"\n height=\"120%\"\n >\n <feGaussianBlur stdDeviation={`${blurX.toFixed(2)} 0`} />\n </filter>\n </defs>\n <g\n transform={`translate(${W / 2} ${H / 2}) scale(${s}) translate(${-W / 2} ${-H / 2})`}\n filter={blurX > 0.3 ? `url(#${uid}-smear)` : undefined}\n style={{\n fontFamily: o.fontFamily,\n fontWeight: o.fontWeight,\n fontSize: Fm,\n }}\n fill={o.ink}\n >\n {leftGone ? null : (\n <text x={leftX} y={baseline}>\n {first}\n </text>\n )}\n {rightGone ? null : (\n <text x={rightX} y={baseline}>\n {second}\n </text>\n )}\n </g>\n </svg>\n </div>\n );\n};\n\nexport function letterGate(\n props: LetterGateProps = {},\n): TransitionPresentation<LetterGateProps> {\n return { component: LetterGatePresentation, props };\n}\n\ntype Palette = {\n ink: string;\n muted: string;\n tint: string;\n accent: string;\n pillBg: string;\n pillBorder: string;\n pillInk: string;\n pillShadow: string;\n logo: string;\n field: string;\n handle: string;\n dot: string;\n nodeBase: string;\n shadow: string;\n violet: string;\n groundA: Partial<GradientParams>;\n groundB: Partial<GradientParams>;\n};\n\nconst THEMES: Record<\"dark\" | \"light\", Palette> = {\n dark: {\n ink: \"#eef1fa\",\n muted: \"rgba(226,232,248,0.48)\",\n tint: \"#7b95ff\",\n accent: \"#3b5bfd\",\n pillBg: \"rgba(10,13,26,0.78)\",\n pillBorder: \"rgba(255,255,255,0.16)\",\n pillInk: \"#eef1fa\",\n pillShadow:\n \"inset 0 1px 0 rgba(255,255,255,0.1), 0 2px 8px rgba(0,0,0,0.35), 0 18px 40px rgba(0,4,30,0.45)\",\n logo: \"#ffffff\",\n field: \"rgba(255,255,255,0.035)\",\n handle: \"#0b0e17\",\n dot: \"rgba(255,255,255,0.085)\",\n nodeBase: \"rgba(13,17,29,0.86)\",\n shadow:\n \"inset 0 1px 0 rgba(255,255,255,0.06), 0 2px 6px rgba(0,0,0,0.3), 0 14px 32px rgba(0,0,0,0.35)\",\n violet: \"#b39bff\",\n groundA: {\n kind: \"dither-burst\",\n colors: [\"#14208f\", \"#2e5bff\", \"#9fbcff\", \"#f4f6ff\"],\n background: \"#020309\",\n speed: 1,\n loopSeconds: 14,\n warp: 0.25,\n seed: 12,\n },\n groundB: {\n kind: \"mist\",\n colors: [\"#3557f0\", \"#1a2a8c\", \"#0b1240\", \"#04060f\"],\n background: \"#03050c\",\n speed: 0.5,\n loopSeconds: 18,\n scale: 0.75,\n warp: 0.35,\n blur: 0.8,\n grain: 0.1,\n seed: 9,\n },\n },\n light: {\n ink: \"#16181d\",\n muted: \"rgba(22,24,29,0.46)\",\n tint: \"#3b5bfd\",\n accent: \"#3b5bfd\",\n pillBg: \"#ffffff\",\n pillBorder: \"rgba(20,24,40,0.08)\",\n pillInk: \"#16181d\",\n pillShadow:\n \"0 1px 2px rgba(30,40,90,0.08), 0 8px 20px rgba(30,40,90,0.1), 0 24px 48px rgba(30,40,90,0.08)\",\n logo: \"#16181d\",\n field: \"#ffffff\",\n handle: \"#ffffff\",\n dot: \"rgba(30,34,52,0.14)\",\n nodeBase: \"rgba(255,255,255,0.92)\",\n shadow:\n \"0 1px 2px rgba(30,40,80,0.06), 0 6px 18px rgba(30,40,80,0.07), 0 20px 40px rgba(30,40,80,0.05)\",\n violet: \"#7a4df0\",\n groundA: {\n kind: \"mist\",\n colors: [\"#3d5cf5\", \"#8ea4ff\", \"#d4dcff\", \"#f3efe7\"],\n background: \"#eceef6\",\n speed: 0.6,\n loopSeconds: 16,\n scale: 0.8,\n warp: 0.4,\n blur: 0.7,\n grain: 0.2,\n seed: 7,\n },\n groundB: {\n kind: \"mist\",\n colors: [\"#c9d3ff\", \"#e6e9fb\", \"#f6efe4\", \"#9fb0f5\"],\n background: \"#f4f1ea\",\n speed: 0.5,\n loopSeconds: 18,\n scale: 0.8,\n warp: 0.35,\n blur: 0.75,\n grain: 0.22,\n seed: 4,\n },\n },\n};\n\nconst A_LEN = 64;\nconst B_LEN = 80;\nconst T_LEN = 26;\nexport const LETTER_GATE_DURATION = A_LEN + B_LEN - T_LEN;\n\nconst A_BEATS = { pill: -4, logo: -1, punch1: 18, punch2: 30 } as const;\nconst B_BEATS = {\n type: 24,\n press: 46,\n edge: 48,\n edgeLen: 14,\n node: 58,\n} as const;\nconst PUNCH = [1, 1.35, 1.8] as const;\n\nfunction pillFont(W: number, H: number) {\n const u = Math.min(W, H) / 720;\n return 38 * u;\n}\n\nfunction SceneA({\n text,\n palette,\n ground,\n groundParams,\n}: {\n text: string;\n palette: Palette;\n ground?: GshPresetId;\n groundParams?: Partial<GradientParams>;\n}) {\n const frame = useCurrentFrame();\n const { width: W, height: H, fps } = useVideoConfig();\n const u = Math.min(W, H) / 720;\n const fs = pillFont(W, H);\n const rise = spring({ frame: frame - A_BEATS.pill, fps, config: CARD });\n const logoIn = ENTER(clamp01((frame - A_BEATS.logo) / 12));\n const step = frame >= A_BEATS.punch2 ? 2 : frame >= A_BEATS.punch1 ? 1 : 0;\n const since =\n step === 2\n ? frame - A_BEATS.punch2\n : step === 1\n ? frame - A_BEATS.punch1\n : 99;\n const kick = since < 3 ? 1.035 - since * 0.012 : 1;\n const cam = PUNCH[step] * kick * (1 + 0.01 * clamp01(frame / A_LEN));\n return (\n <AbsoluteFill style={{ background: palette.groundA.background }}>\n <GshGround\n preset={ground}\n params={\n ground && !groundParams\n ? undefined\n : (groundParams ?? palette.groundA)\n }\n timeOffset={3}\n timeScale={0.7}\n />\n <AbsoluteFill\n style={{\n transform: `scale(${cam})`,\n transformOrigin: \"50% 50%\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: 0,\n width: W,\n top: H / 2 - fs * 2.6,\n display: \"flex\",\n justifyContent: \"center\",\n opacity: logoIn,\n transform: `translateY(${(1 - logoIn) * 10 * u}px)`,\n }}\n >\n <RemocnLogo fontSize={24 * u} color={palette.logo} />\n </div>\n <div\n style={{\n position: \"absolute\",\n left: 0,\n width: W,\n top: H / 2,\n display: \"flex\",\n justifyContent: \"center\",\n }}\n >\n <div\n style={{\n transform: `translateY(-50%) translateY(${(1 - rise) * 40 * u}px) scale(${lerp(0.9, 1, rise)})`,\n opacity: clamp01(rise * 2),\n filter: `blur(${Math.max(0, (1 - rise) * 6).toFixed(2)}px)`,\n background: palette.pillBg,\n border: `${1 * u}px solid ${palette.pillBorder}`,\n boxShadow: palette.pillShadow,\n borderRadius: 999,\n padding: `${fs * 0.42}px ${fs * 0.78}px ${fs * 0.46}px`,\n fontFamily: geist.fontFamily,\n fontWeight: 400,\n fontSize: fs,\n letterSpacing: \"-0.02em\",\n lineHeight: 1.1,\n color: palette.pillInk,\n whiteSpace: \"pre\",\n }}\n >\n {text}\n </div>\n </div>\n </AbsoluteFill>\n </AbsoluteFill>\n );\n}\n\nfunction Handles({\n w,\n h,\n k,\n color,\n fill,\n t,\n}: {\n w: number;\n h: number;\n k: number;\n color: string;\n fill: string;\n t: number;\n}) {\n if (t <= 0.001) return null;\n const s = 7 * k;\n const corners = [\n [0, 0],\n [w, 0],\n [0, h],\n [w, h],\n ];\n return (\n <>\n {corners.map(([cx, cy]) => (\n <div\n key={`h${cx}-${cy}`}\n style={{\n position: \"absolute\",\n left: cx - s / 2,\n top: cy - s / 2,\n width: s,\n height: s,\n background: fill,\n border: `${1.25 * k}px solid ${color}`,\n borderRadius: 1.5 * k,\n transform: `scale(${t})`,\n boxSizing: \"border-box\",\n }}\n />\n ))}\n </>\n );\n}\n\nfunction SceneB({\n prompt,\n placeholder,\n label,\n nextLabel,\n palette,\n accent,\n ground,\n groundParams,\n}: {\n prompt: string;\n placeholder: string;\n label: string;\n nextLabel: string;\n palette: Palette;\n accent: string;\n ground?: GshPresetId;\n groundParams?: Partial<GradientParams>;\n}) {\n const frame = useCurrentFrame();\n const { width: W, height: H, fps } = useVideoConfig();\n const uid = useId().replace(/:/g, \"\");\n const tall = H > W * 1.1;\n const u = Math.min(W, H) / 720;\n const k = (tall ? 1.6 : 1.9) * u;\n const fieldText = 15 * k;\n const chars = Math.max(prompt.length, placeholder.length);\n const fw = 14 * k + chars * 0.6 * fieldText + 12 * k + 34 * k + 10 * k;\n const fh = 56 * k;\n const cx = W / 2;\n const cy = H / 2;\n const typed = Math.floor(\n clamp01((frame - B_BEATS.type) / prompt.length) * prompt.length,\n );\n const press = frame - B_BEATS.press;\n const pressS =\n press >= 0 ? 1 - 0.12 * Math.sin(Math.PI * clamp01(press / 6)) : 1;\n const edgeP = MOVE(clamp01((frame - B_BEATS.edge) / B_BEATS.edgeLen));\n const nodeLocal = frame - B_BEATS.node;\n const tw = 64 * k;\n const nx = tall ? cx + W * 0.16 : W * 0.85;\n const ny = tall ? cy + fh / 2 + 170 * k : cy + 0.2 * H;\n const from = tall ? { x: cx, y: cy + fh / 2 } : { x: cx + fw / 2, y: cy };\n const to = tall ? { x: nx, y: ny - tw / 2 } : { x: nx - tw / 2, y: ny };\n const c1 = tall\n ? { x: from.x, y: from.y + (to.y - from.y) * 0.5 }\n : { x: from.x + (to.x - from.x) * 0.5, y: from.y };\n const c2 = tall\n ? { x: to.x, y: to.y - (to.y - from.y) * 0.5 }\n : { x: to.x - (to.x - from.x) * 0.5, y: to.y };\n const edgeD = `M${from.x} ${from.y}C${c1.x} ${c1.y} ${c2.x} ${c2.y} ${to.x} ${to.y}`;\n const inFrom = tall\n ? { x: cx - W * 0.2, y: -20 }\n : { x: -20, y: cy - 90 * k };\n const inTo = tall\n ? { x: cx, y: cy - fh / 2 - 34 * k }\n : { x: cx - fw / 2, y: cy };\n const inD = tall\n ? `M${inFrom.x} ${inFrom.y}C${inFrom.x} ${inTo.y * 0.6} ${inTo.x} ${inTo.y * 0.5} ${inTo.x} ${inTo.y}`\n : `M${inFrom.x} ${inFrom.y}C${inTo.x * 0.5} ${inFrom.y} ${inTo.x * 0.5} ${inTo.y} ${inTo.x} ${inTo.y}`;\n const push = 1 + 0.04 * clamp01(frame / B_LEN);\n const len = 900 * k;\n const nodePop = spring({ frame: nodeLocal, fps, config: CARD });\n const labelShown = Math.max(0, nodeLocal - 2);\n return (\n <AbsoluteFill style={{ background: palette.groundB.background }}>\n <GshGround\n preset={ground}\n params={\n ground && !groundParams\n ? undefined\n : (groundParams ?? palette.groundB)\n }\n timeOffset={5}\n timeScale={0.6}\n />\n <AbsoluteFill\n style={{ transform: `scale(${push})`, transformOrigin: \"50% 50%\" }}\n >\n <svg\n width={W}\n height={H}\n style={{ position: \"absolute\", inset: 0, overflow: \"visible\" }}\n aria-hidden\n >\n <defs>\n <pattern\n id={`${uid}-dots`}\n width={24 * k}\n height={24 * k}\n patternUnits=\"userSpaceOnUse\"\n x={cx}\n y={cy}\n >\n <circle cx={12 * k} cy={12 * k} r={1.1 * k} fill={palette.dot} />\n </pattern>\n </defs>\n <rect x={0} y={0} width={W} height={H} fill={`url(#${uid}-dots)`} />\n <path\n d={inD}\n fill=\"none\"\n stroke={palette.tint}\n strokeOpacity={0.55}\n strokeWidth={1.6 * k}\n strokeDasharray={`${5 * k} ${5 * k}`}\n strokeDashoffset={-frame * 0.4 * k}\n strokeLinecap=\"round\"\n />\n {edgeP > 0 ? (\n <path\n d={edgeD}\n fill=\"none\"\n stroke={palette.violet}\n strokeWidth={1.6 * k}\n strokeDasharray={`${len * edgeP} ${len}`}\n strokeLinecap=\"round\"\n mask={`url(#${uid}-dash)`}\n />\n ) : null}\n <mask id={`${uid}-dash`} maskUnits=\"userSpaceOnUse\">\n <path\n d={edgeD}\n fill=\"none\"\n stroke=\"#fff\"\n strokeWidth={3 * k}\n strokeDasharray={`${5 * k} ${5 * k}`}\n />\n </mask>\n </svg>\n <div\n style={{\n position: \"absolute\",\n left: cx - fw / 2,\n top: cy - fh / 2,\n width: fw,\n height: fh,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: 0,\n width: fw,\n bottom: fh + 10 * k,\n textAlign: \"center\",\n fontFamily: mono.fontFamily,\n fontWeight: 400,\n fontSize: 15 * k,\n lineHeight: 1,\n color: palette.tint,\n }}\n >\n {label}\n </div>\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n borderRadius: 11 * k,\n background: palette.field,\n border: `${1.5 * k}px solid ${palette.tint}`,\n boxShadow: palette.shadow,\n display: \"flex\",\n alignItems: \"center\",\n paddingLeft: 16 * k,\n boxSizing: \"border-box\",\n fontFamily: mono.fontFamily,\n fontWeight: 400,\n fontSize: fieldText,\n color: typed > 0 ? palette.ink : palette.muted,\n whiteSpace: \"pre\",\n }}\n >\n {typed > 0 ? prompt.slice(0, typed) : placeholder}\n {frame < B_BEATS.press + 2 && Math.floor(frame / 5) % 2 === 0 ? (\n <span\n style={{\n display: \"inline-block\",\n width: 1.5 * k,\n height: fieldText * 1.15,\n marginLeft: 2 * k,\n background: palette.tint,\n }}\n />\n ) : null}\n <div\n style={{\n position: \"absolute\",\n right: 10 * k,\n top: fh / 2 - 17 * k,\n width: 34 * k,\n height: 34 * k,\n borderRadius: 17 * k,\n background: accent,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n transform: `scale(${pressS})`,\n }}\n >\n <svg\n viewBox=\"0 0 24 24\"\n width={18 * k}\n height={18 * k}\n aria-hidden\n >\n <path\n d=\"M5 12h14M13 6l6 6-6 6\"\n fill=\"none\"\n stroke=\"#ffffff\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </div>\n </div>\n <Handles\n w={fw}\n h={fh}\n k={k}\n color={palette.tint}\n fill={palette.handle}\n t={1 - EXIT(clamp01((frame - B_BEATS.edge - 4) / 6))}\n />\n </div>\n {nodeLocal >= 0 ? (\n <div\n style={{\n position: \"absolute\",\n left: nx - tw / 2,\n top: ny - tw / 2,\n width: tw,\n height: tw,\n opacity: clamp01(nodeLocal / 4),\n transform: `scale(${lerp(1.14, 1, nodePop)})`,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n ...(tall\n ? { left: tw + 14 * k, top: tw / 2 - 7.5 * k }\n : { left: -40 * k, width: tw + 80 * k, bottom: tw + 9 * k }),\n textAlign: tall ? \"left\" : \"center\",\n fontFamily: mono.fontFamily,\n fontWeight: 400,\n fontSize: 15 * k,\n lineHeight: 1,\n color: palette.violet,\n whiteSpace: \"pre\",\n }}\n >\n {nextLabel.slice(0, Math.min(nextLabel.length, labelShown))}\n </div>\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n borderRadius: 6 * k,\n background: palette.nodeBase,\n border: `${1.5 * k}px solid ${palette.violet}`,\n boxShadow: palette.shadow,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n style={{\n width: 40 * k,\n height: 40 * k,\n borderRadius: 7 * k,\n border: `${1.2 * k}px dashed ${palette.violet}`,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n transform: `scale(${spring({ frame: nodeLocal - 4, fps, config: CHIP })})`,\n }}\n >\n <svg\n viewBox=\"0 0 24 24\"\n width={21 * k}\n height={21 * k}\n aria-hidden\n >\n <rect\n x={5}\n y={3}\n width={14}\n height={18}\n rx={2.5}\n fill=\"none\"\n stroke={palette.violet}\n strokeWidth={1.5}\n />\n <path\n d=\"M8.5 8h7M8.5 12h7M8.5 16h4\"\n fill=\"none\"\n stroke={palette.violet}\n strokeWidth={1.5}\n strokeLinecap=\"round\"\n />\n </svg>\n </div>\n </div>\n <Handles\n w={tw}\n h={tw}\n k={k}\n color={palette.violet}\n fill={palette.handle}\n t={spring({ frame: nodeLocal, fps, config: CHIP })}\n />\n </div>\n ) : null}\n </AbsoluteFill>\n </AbsoluteFill>\n );\n}\n\nexport type LetterGateDemoProps = {\n theme?: \"dark\" | \"light\";\n accent?: string;\n text?: string;\n gate?: string;\n prompt?: string;\n placeholder?: string;\n label?: string;\n nextLabel?: string;\n ground?: GshPresetId;\n groundParams?: Partial<GradientParams>;\n groundB?: GshPresetId;\n groundParamsB?: Partial<GradientParams>;\n transition?: LetterGateProps;\n};\n\nexport function LetterGateDemo({\n theme = \"dark\",\n accent,\n text = \"Start building\",\n gate = \"bu\",\n prompt = \"A launch film for v2\",\n placeholder = \"Describe your launch\",\n label = \"Prompt\",\n nextLabel = \"Script\",\n ground,\n groundParams,\n groundB,\n groundParamsB,\n transition,\n}: LetterGateDemoProps) {\n const { width: W, height: H } = useVideoConfig();\n const palette = THEMES[theme];\n const acc = accent ?? palette.accent;\n const m = useMetrics(geist.fontFamily, 400, \"pill text\");\n const idx = Math.max(0, text.indexOf(gate));\n const pair = text.indexOf(gate) >= 0 ? gate : text.slice(idx, idx + 2);\n const t = { ...letterGateDefaults, ...transition };\n // The push lands the pair exactly where the gate glyphs start, so the cut is\n // a match cut: same letters, same size, same place, new scene behind them.\n const u = Math.min(W, H) / 720;\n const fs = pillFont(W, H);\n const cutFrame = A_LEN - T_LEN + t.cut * T_LEN;\n const cam = PUNCH[2] * (1 + 0.01 * clamp01(cutFrame / A_LEN));\n const textW = (m.width(text) + LETTER_TRACK * text.length) * fs;\n const pairEnd = m.width(text.slice(0, idx + 2)) - m.width(pair.slice(1));\n const gateX = W / 2 - textW / 2 + (pairEnd + LETTER_TRACK * (idx + 1)) * fs;\n // Mirrors Chrome's line box: ascent and descent round to whole pixels and\n // the half-leading floors, which matters once the push magnifies it ~20×.\n const pillH = fs * (0.42 + 1.1 + 0.46) + 2 * u;\n const lineTop = H / 2 - pillH / 2 + u + 0.42 * fs;\n const asc = Math.round(m.asc * fs);\n const desc = Math.round(m.desc * fs);\n const baseline = lineTop + Math.floor((1.1 * fs - asc - desc) / 2) + asc;\n const gateY = baseline - (m.xh * fs) / 2;\n const Fm = Math.min(H * t.size, W * 0.95);\n const fx = (W / 2 + (gateX - W / 2) * cam) / W;\n const fy = (H / 2 + (gateY - H / 2) * cam) / H;\n const zoom = Fm / (fs * cam);\n return (\n <AbsoluteFill style={{ backgroundColor: palette.groundB.background }}>\n <TransitionSeries>\n <TransitionSeries.Sequence durationInFrames={A_LEN}>\n <SceneA\n text={text}\n palette={palette}\n ground={ground}\n groundParams={groundParams}\n />\n </TransitionSeries.Sequence>\n <TransitionSeries.Transition\n presentation={letterGate({\n letters: pair,\n fontFamily: geist.fontFamily,\n fontWeight: 400,\n ink: palette.ink,\n focus: [fx, fy],\n zoom,\n ...transition,\n })}\n timing={linearTiming({ durationInFrames: T_LEN })}\n />\n <TransitionSeries.Sequence durationInFrames={B_LEN}>\n <SceneB\n prompt={prompt}\n placeholder={placeholder}\n label={label}\n nextLabel={nextLabel}\n palette={palette}\n accent={acc}\n ground={groundB}\n groundParams={groundParamsB}\n />\n </TransitionSeries.Sequence>\n </TransitionSeries>\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/letter-gate.tsx"
}
],
"type": "registry:component"
}