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": "ndot-resolve",
"title": "Ndot Resolve",
"description": "A headline scans in as a dot-matrix face, then refreshes letter by letter into solid type.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"files": [
{
"path": "registry/remocn/ndot-resolve/index.tsx",
"content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Geist\";\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n AbsoluteFill,\n continueRender,\n delayRender,\n Easing,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\n\nconst geist = loadFont(\"normal\", {\n weights: [\"500\"],\n subsets: [\"latin\"],\n});\nconst WEIGHT = 500;\n\n/**\n * Beat sheet (30fps, speed 1):\n * 0–20 the headline scans in row by row in a round-dot matrix face, like\n * an LED panel refreshing top to bottom.\n * 20–34 hold on the dot headline.\n * 34–83 left to right (2.2f stagger), a hard refresh line runs down each\n * glyph in 5 frames: solid Geist 500 above it, dot face below it.\n * The emphasis word refreshes into a gradients.sh fill (\"halo\" on\n * dark, \"pixel-glass\" on light, ending in the accent) and stays dots.\n * 83–135 hold; one quiet refresh pass runs over the emphasis word while its\n * gradient drifts a few percent.\n */\n\nexport interface NdotResolveProps {\n /** Headline. Use \"\\n\" to force line breaks; otherwise it is balanced. */\n text?: string;\n /** Word that stays in dots, in the gradient. Empty string = none. */\n emphasis?: string;\n accent?: string;\n speed?: number;\n theme?: \"dark\" | \"light\";\n}\n\nconst THEMES = {\n dark: { bg: \"#0A0A0B\", ink: \"#F3F2EF\", hot: [\"#FFB36B\", \"#E2457A\"] },\n light: { bg: \"#F5F4F0\", ink: \"#141416\", hot: [\"#7A3CFF\", \"#FF4FB8\"] },\n} as const;\n\nconst TRACK = -0.032;\n\ntype Measure = (s: string) => number;\n\n/** Waits for Geist, then measures with a canvas (em, kerning included). */\nfunction useMeasurer() {\n const [ready, setReady] = useState(false);\n const [handle] = useState(() => delayRender(\"ndot-resolve: measuring\"));\n const released = useRef(false);\n const font = `${WEIGHT} 100px \"${geist.fontFamily}\"`;\n\n useEffect(() => {\n let live = true;\n Promise.all([geist.waitUntilDone(), document.fonts.load(font)])\n .catch(() => undefined)\n .then(() => {\n if (!live) return;\n setReady(true);\n if (!released.current) {\n released.current = true;\n continueRender(handle);\n }\n });\n return () => {\n live = false;\n };\n }, [font, handle]);\n\n const ctx = useMemo(\n () => (ready ? document.createElement(\"canvas\").getContext(\"2d\") : null),\n [ready],\n );\n const measure = useCallback(\n (s: string) => {\n if (!ctx) return s.length * 0.55;\n ctx.font = font;\n return ctx.measureText(s).width / 100;\n },\n [ctx, font],\n );\n const cap = useMemo(() => {\n if (!ctx) return 0.71;\n ctx.font = font;\n return ctx.measureText(\"H\").actualBoundingBoxAscent / 100;\n }, [ctx, font]);\n return useMemo(\n () => (ready ? { measure, cap } : null),\n [ready, measure, cap],\n );\n}\n\n/**\n * Round-dot face on a 7-row cap grid (row 6 sits on the baseline, rows 7–8 are\n * descenders). Dot glyphs are centred in each Geist glyph's advance, so the\n * dot line and the solid line share one set of measured metrics.\n */\nconst GLYPHS: Record<string, string[]> = {\n A: [\".###.\", \"#...#\", \"#...#\", \"#####\", \"#...#\", \"#...#\", \"#...#\"],\n B: [\"####.\", \"#...#\", \"#...#\", \"####.\", \"#...#\", \"#...#\", \"####.\"],\n C: [\".####\", \"#....\", \"#....\", \"#....\", \"#....\", \"#....\", \".####\"],\n D: [\"####.\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \"####.\"],\n E: [\"####\", \"#...\", \"#...\", \"###.\", \"#...\", \"#...\", \"####\"],\n F: [\"####\", \"#...\", \"#...\", \"###.\", \"#...\", \"#...\", \"#...\"],\n G: [\".####\", \"#....\", \"#....\", \"#..##\", \"#...#\", \"#...#\", \".###.\"],\n H: [\"#...#\", \"#...#\", \"#...#\", \"#####\", \"#...#\", \"#...#\", \"#...#\"],\n I: [\"#\", \"#\", \"#\", \"#\", \"#\", \"#\", \"#\"],\n J: [\"...#\", \"...#\", \"...#\", \"...#\", \"...#\", \"#..#\", \".##.\"],\n K: [\"#...#\", \"#..#.\", \"#.#..\", \"##...\", \"#.#..\", \"#..#.\", \"#...#\"],\n L: [\"#...\", \"#...\", \"#...\", \"#...\", \"#...\", \"#...\", \"####\"],\n M: [\n \"#.....#\",\n \"##...##\",\n \"#.#.#.#\",\n \"#..#..#\",\n \"#.....#\",\n \"#.....#\",\n \"#.....#\",\n ],\n N: [\"#....#\", \"##...#\", \"#.#..#\", \"#..#.#\", \"#...##\", \"#....#\", \"#....#\"],\n O: [\".####.\", \"#....#\", \"#....#\", \"#....#\", \"#....#\", \"#....#\", \".####.\"],\n P: [\"####.\", \"#...#\", \"#...#\", \"####.\", \"#....\", \"#....\", \"#....\"],\n Q: [\".####.\", \"#....#\", \"#....#\", \"#....#\", \"#..#.#\", \"#...#.\", \".###.#\"],\n R: [\"####.\", \"#...#\", \"#...#\", \"####.\", \"#.#..\", \"#..#.\", \"#...#\"],\n S: [\".####\", \"#....\", \"#....\", \".###.\", \"....#\", \"....#\", \"####.\"],\n T: [\"#####\", \"..#..\", \"..#..\", \"..#..\", \"..#..\", \"..#..\", \"..#..\"],\n U: [\"#....#\", \"#....#\", \"#....#\", \"#....#\", \"#....#\", \"#....#\", \".####.\"],\n V: [\"#...#\", \"#...#\", \"#...#\", \"#...#\", \".#.#.\", \".#.#.\", \"..#..\"],\n W: [\n \"#.....#\",\n \"#.....#\",\n \"#.....#\",\n \"#..#..#\",\n \"#.#.#.#\",\n \"##...##\",\n \"#.....#\",\n ],\n X: [\"#...#\", \"#...#\", \".#.#.\", \"..#..\", \".#.#.\", \"#...#\", \"#...#\"],\n Y: [\"#...#\", \"#...#\", \".#.#.\", \"..#..\", \"..#..\", \"..#..\", \"..#..\"],\n Z: [\"#####\", \"....#\", \"...#.\", \"..#..\", \".#...\", \"#....\", \"#####\"],\n a: [\".....\", \".....\", \".###.\", \"....#\", \".####\", \"#...#\", \".####\"],\n b: [\"#....\", \"#....\", \"####.\", \"#...#\", \"#...#\", \"#...#\", \"####.\"],\n c: [\"....\", \"....\", \".###\", \"#...\", \"#...\", \"#...\", \".###\"],\n d: [\"....#\", \"....#\", \".####\", \"#...#\", \"#...#\", \"#...#\", \".####\"],\n e: [\".....\", \".....\", \".###.\", \"#...#\", \"#####\", \"#....\", \".####\"],\n f: [\"..##\", \".#..\", \"###.\", \".#..\", \".#..\", \".#..\", \".#..\"],\n g: [\n \".....\",\n \".....\",\n \".####\",\n \"#...#\",\n \"#...#\",\n \"#...#\",\n \".####\",\n \"....#\",\n \".###.\",\n ],\n h: [\"#....\", \"#....\", \"####.\", \"#...#\", \"#...#\", \"#...#\", \"#...#\"],\n i: [\"#\", \".\", \"#\", \"#\", \"#\", \"#\", \"#\"],\n j: [\"..#\", \"...\", \"..#\", \"..#\", \"..#\", \"..#\", \"..#\", \"..#\", \"##.\"],\n k: [\"#...\", \"#...\", \"#..#\", \"#.#.\", \"##..\", \"#.#.\", \"#..#\"],\n l: [\"#\", \"#\", \"#\", \"#\", \"#\", \"#\", \"#\"],\n m: [\n \".......\",\n \".......\",\n \"###.##.\",\n \"#..#..#\",\n \"#..#..#\",\n \"#..#..#\",\n \"#..#..#\",\n ],\n n: [\".....\", \".....\", \"####.\", \"#...#\", \"#...#\", \"#...#\", \"#...#\"],\n o: [\".....\", \".....\", \".###.\", \"#...#\", \"#...#\", \"#...#\", \".###.\"],\n p: [\n \".....\",\n \".....\",\n \"####.\",\n \"#...#\",\n \"#...#\",\n \"#...#\",\n \"####.\",\n \"#....\",\n \"#....\",\n ],\n q: [\n \".....\",\n \".....\",\n \".####\",\n \"#...#\",\n \"#...#\",\n \"#...#\",\n \".####\",\n \"....#\",\n \"....#\",\n ],\n r: [\"...\", \"...\", \"#.#\", \"##.\", \"#..\", \"#..\", \"#..\"],\n s: [\"....\", \"....\", \".###\", \"#...\", \".##.\", \"...#\", \"###.\"],\n t: [\"...\", \".#.\", \"###\", \".#.\", \".#.\", \".#.\", \"..#\"],\n u: [\".....\", \".....\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \".####\"],\n v: [\".....\", \".....\", \"#...#\", \"#...#\", \".#.#.\", \".#.#.\", \"..#..\"],\n w: [\n \".......\",\n \".......\",\n \"#.....#\",\n \"#.....#\",\n \"#..#..#\",\n \"#.#.#.#\",\n \".#...#.\",\n ],\n x: [\".....\", \".....\", \"#...#\", \".#.#.\", \"..#..\", \".#.#.\", \"#...#\"],\n y: [\n \".....\",\n \".....\",\n \"#...#\",\n \"#...#\",\n \"#...#\",\n \"#...#\",\n \".####\",\n \"....#\",\n \".###.\",\n ],\n z: [\".....\", \".....\", \"#####\", \"...#.\", \"..#..\", \".#...\", \"#####\"],\n \"0\": [\".###.\", \"#...#\", \"#..##\", \"#.#.#\", \"##..#\", \"#...#\", \".###.\"],\n \"1\": [\"..#\", \".##\", \"#.#\", \"..#\", \"..#\", \"..#\", \"..#\"],\n \"2\": [\".###.\", \"#...#\", \"....#\", \"...#.\", \"..#..\", \".#...\", \"#####\"],\n \"3\": [\"####.\", \"....#\", \"....#\", \".###.\", \"....#\", \"....#\", \"####.\"],\n \"4\": [\"...#.\", \"..##.\", \".#.#.\", \"#..#.\", \"#####\", \"...#.\", \"...#.\"],\n \"5\": [\"#####\", \"#....\", \"####.\", \"....#\", \"....#\", \"#...#\", \".###.\"],\n \"6\": [\".###.\", \"#....\", \"#....\", \"####.\", \"#...#\", \"#...#\", \".###.\"],\n \"7\": [\"#####\", \"....#\", \"...#.\", \"..#..\", \"..#..\", \"..#..\", \"..#..\"],\n \"8\": [\".###.\", \"#...#\", \"#...#\", \".###.\", \"#...#\", \"#...#\", \".###.\"],\n \"9\": [\".###.\", \"#...#\", \"#...#\", \".####\", \"....#\", \"....#\", \".###.\"],\n \".\": [\".\", \".\", \".\", \".\", \".\", \".\", \"#\"],\n \",\": [\".\", \".\", \".\", \".\", \".\", \".\", \"#\", \"#\"],\n \"!\": [\"#\", \"#\", \"#\", \"#\", \"#\", \".\", \"#\"],\n \"?\": [\".###.\", \"#...#\", \"....#\", \"...#.\", \"..#..\", \".....\", \"..#..\"],\n \"'\": [\"#\", \"#\", \".\", \".\", \".\", \".\", \".\"],\n \"’\": [\"#\", \"#\", \".\", \".\", \".\", \".\", \".\"],\n \"-\": [\"...\", \"...\", \"...\", \"###\", \"...\", \"...\", \"...\"],\n \"–\": [\"....\", \"....\", \"....\", \"####\", \"....\", \"....\", \"....\"],\n \":\": [\".\", \".\", \"#\", \".\", \".\", \".\", \"#\"],\n \"/\": [\"...#\", \"...#\", \"..#.\", \"..#.\", \".#..\", \".#..\", \"#...\"],\n};\n\ninterface Glyph {\n ch: string;\n line: number;\n /** Pen x and glyph advance in em, relative to the line start. */\n pen: number;\n adv: number;\n /** Lit cells (col, row) of the dot glyph. */\n cells: [number, number][];\n cols: number;\n emphasis: boolean;\n order: number;\n}\n\nfunction lineWidth(s: string, m: Measure) {\n return m(s) + TRACK * Math.max(0, s.length - 1);\n}\n\nfunction splitLines(text: string, maxEm: number, m: Measure): string[] {\n if (text.includes(\"\\n\")) return text.split(\"\\n\");\n const widthOf = (s: string) => lineWidth(s, m);\n if (widthOf(text) <= maxEm) return [text];\n const words = text.split(\" \");\n let best: string[] = [text];\n let bestScore = Number.POSITIVE_INFINITY;\n for (let k = 1; k < words.length; k++) {\n const a = words.slice(0, k).join(\" \");\n const b = words.slice(k).join(\" \");\n const sentence = /[.!?,:;]$/.test(a) ? 0.75 : 1;\n const score = Math.max(widthOf(a), widthOf(b)) * sentence;\n if (score < bestScore) {\n bestScore = score;\n best = [a, b];\n }\n }\n return best;\n}\n\nfunction layout(text: string, emphasis: string, maxEm: number, m: Measure) {\n const lines = splitLines(text, maxEm, m);\n const target = emphasis.trim().toLowerCase();\n const glyphs: Glyph[] = [];\n let order = 0;\n lines.forEach((line, li) => {\n // Mark which characters belong to the emphasis word (with its punctuation).\n const hot = new Array(line.length).fill(false);\n if (target) {\n const re = /\\S+/g;\n let m = re.exec(line);\n while (m) {\n const core = m[0].replace(/[^\\p{L}\\p{N}]/gu, \"\").toLowerCase();\n if (core === target) {\n for (let i = m.index; i < m.index + m[0].length; i++) hot[i] = true;\n }\n m = re.exec(line);\n }\n }\n for (let i = 0; i < line.length; i++) {\n const ch = line[i];\n const a = m(ch);\n // Pen from the measured prefix, so the font's kerning carries through.\n const pen = m(line.slice(0, i)) + TRACK * i;\n const rows = GLYPHS[ch];\n const cells: [number, number][] = [];\n if (rows) {\n rows.forEach((row, r) => {\n for (let c = 0; c < row.length; c++) {\n if (row[c] === \"#\") cells.push([c, r]);\n }\n });\n }\n glyphs.push({\n ch,\n line: li,\n pen,\n adv: a,\n cells,\n cols: rows ? rows[0].length : 0,\n emphasis: hot[i],\n order: ch === \" \" ? -1 : order++,\n });\n }\n });\n const widths = lines.map((l) => lineWidth(l, m));\n const descender = glyphs.some((g) => (GLYPHS[g.ch]?.length ?? 0) > 7);\n return { lines, glyphs, widths, count: order, descender };\n}\n\n// Timeline (frames at speed 1).\nconst ROW_STEP = 1.1;\nconst RES_START = 34;\nconst STAGGER = 2.2;\nconst WIPE_LEN = 5;\nconst WIPE_EASE = Easing.bezier(0.33, 0, 0.2, 1);\nconst DOT_R = 0.47;\n\nconst dotPath = (x: number, y: number, r: number) =>\n `M${(x - r).toFixed(2)} ${y.toFixed(2)}a${r.toFixed(2)} ${r.toFixed(2)} 0 1 0 ${(2 * r).toFixed(2)} 0a${r.toFixed(2)} ${r.toFixed(2)} 0 1 0 ${(-2 * r).toFixed(2)} 0`;\n\nexport function NdotResolve({\n text = \"Less noise. More launch.\",\n emphasis = \"launch\",\n accent = \"#3B5BFD\",\n speed = 1,\n theme = \"dark\",\n}: NdotResolveProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H } = useVideoConfig();\n const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n const pal = THEMES[theme];\n const metrics = useMeasurer();\n\n const maxFs = H * 0.235;\n const laid = useMemo(\n () =>\n metrics\n ? layout(text, emphasis, (W * 0.84) / maxFs, metrics.measure)\n : null,\n [text, emphasis, W, maxFs, metrics],\n );\n\n if (!metrics || !laid) {\n return (\n <div style={{ position: \"absolute\", inset: 0, background: pal.bg }} />\n );\n }\n\n const { glyphs, widths, lines, count, descender } = laid;\n const CAP = metrics.cap;\n const blockEm = Math.max(...widths);\n const fs = Math.min(maxFs, (W * 0.84) / blockEm);\n const p = (CAP * fs) / 7;\n const lead = fs * (descender ? 1.16 : 1.08);\n const blockH = (lines.length - 1) * lead + CAP * fs;\n const left = (W - blockEm * fs) / 2;\n const top = (H - blockH) / 2 + CAP * fs;\n const rowsPerLine = 9;\n\n const ink2: string[] = [];\n const ink3: string[] = [];\n const hot: string[] = [];\n const hotDim: string[] = [];\n const wiping: ReactNode[] = [];\n const solid: ReactNode[] = [];\n const resEnd = RES_START + (count - 1) * STAGGER + WIPE_LEN;\n // Extent of the emphasis word, for its gradient.\n let hotX0 = Number.POSITIVE_INFINITY;\n let hotX1 = Number.NEGATIVE_INFINITY;\n let hotY = top;\n\n for (const g of glyphs) {\n if (g.order < 0) continue;\n const baseline = top + g.line * lead;\n const penX = left + g.pen * fs;\n const inkLeft = penX + (g.adv * fs - g.cols * p) / 2;\n const cx = (c: number) => inkLeft + (c + 0.5) * p;\n const cy = (r: number) => baseline - (6.5 - r) * p;\n const start = RES_START + g.order * STAGGER;\n\n if (g.emphasis) {\n hotX0 = Math.min(hotX0, inkLeft);\n hotX1 = Math.max(hotX1, inkLeft + g.cols * p);\n hotY = baseline;\n for (const [c, r] of g.cells) {\n const tr = (g.line * rowsPerLine + r) * ROW_STEP;\n if (t < tr) continue;\n // Refresh into the gradient, row by row, one dark step per row.\n const sw = start + r * 0.6;\n if (t >= sw && t < sw + 1) continue;\n // A quiet refresh pass over the emphasis word during the hold.\n const pass = resEnd + 12 + r * 0.9;\n const d = dotPath(cx(c), cy(r), DOT_R * p);\n if (t >= sw + 1) {\n if (t >= pass && t < pass + 1.5) hotDim.push(d);\n else hot.push(d);\n } else if (t < tr + 1) ink2.push(d);\n else ink3.push(d);\n }\n continue;\n }\n\n // A hard line refreshes each glyph top to bottom: solid Geist above it,\n // the dot face below it. One system per region, never two overlapping.\n const lf = t - start;\n const yTop = baseline - fs * 0.8;\n const yBot = baseline + fs * 0.26;\n const wipeY =\n lf <= 0\n ? yTop\n : yTop + (yBot - yTop) * WIPE_EASE(Math.min(1, lf / WIPE_LEN));\n\n if (lf < WIPE_LEN) {\n for (const [c, row] of g.cells) {\n const tr = (g.line * rowsPerLine + row) * ROW_STEP;\n if (t < tr) continue;\n if (lf > 0 && cy(row) < wipeY) continue;\n const d = dotPath(cx(c), cy(row), DOT_R * p);\n if (t < tr + 1) ink2.push(d);\n else ink3.push(d);\n }\n }\n if (lf <= 0) continue;\n\n const glyphText = (extra: Record<string, string | number>) => (\n <text\n key={`t${g.order}-${g.line}`}\n x={penX}\n y={baseline}\n fill={pal.ink}\n fontFamily={geist.fontFamily}\n fontWeight={WEIGHT}\n fontSize={fs}\n style={{ fontKerning: \"none\" }}\n {...extra}\n >\n {g.ch}\n </text>\n );\n\n if (lf >= WIPE_LEN) {\n solid.push(glyphText({}));\n continue;\n }\n const id = `${uid}-c${g.line}-${g.order}`;\n wiping.push(\n <g key={id}>\n <clipPath id={id}>\n <rect\n x={penX - fs * 0.2}\n y={yTop - fs * 0.2}\n width={g.adv * fs + fs * 0.4}\n height={wipeY - yTop + fs * 0.2}\n />\n </clipPath>\n {glyphText({ clipPath: `url(#${id})` })}\n </g>,\n );\n }\n\n // The emphasis fill sweeps left to right and drifts a few percent.\n const hotW = Math.max(1, hotX1 - hotX0);\n const sway = Math.sin(t / 34) * 0.06 * hotW;\n const gradId = `${uid}-hot`;\n\n return (\n <AbsoluteFill style={{ background: pal.bg, overflow: \"hidden\" }}>\n <svg\n width={W}\n height={H}\n viewBox={`0 0 ${W} ${H}`}\n style={{ position: \"absolute\", inset: 0 }}\n aria-hidden\n >\n <defs>\n <linearGradient\n id={gradId}\n gradientUnits=\"userSpaceOnUse\"\n x1={hotX0 - 0.08 * hotW + sway}\n y1={hotY - CAP * fs * 0.6}\n x2={hotX1 + 0.04 * hotW + sway}\n y2={hotY + CAP * fs * 0.1}\n >\n <stop offset={0} stopColor={pal.hot[0]} />\n <stop offset={0.5} stopColor={pal.hot[1]} />\n <stop offset={1} stopColor={accent} />\n </linearGradient>\n </defs>\n {ink2.length ? (\n <path d={ink2.join(\"\")} fill={pal.ink} fillOpacity={0.45} />\n ) : null}\n {ink3.length ? <path d={ink3.join(\"\")} fill={pal.ink} /> : null}\n {wiping}\n {solid}\n {hot.length ? <path d={hot.join(\"\")} fill={`url(#${gradId})`} /> : null}\n {hotDim.length ? (\n <path\n d={hotDim.join(\"\")}\n fill={`url(#${gradId})`}\n fillOpacity={0.45}\n />\n ) : null}\n </svg>\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/ndot-resolve.tsx"
}
],
"type": "registry:component"
}