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": "glyph-matrix",
"title": "Glyph Matrix",
"description": "A round LED dot matrix counts 3-2-1, then its dots hop into the R mark and the logo.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"files": [
{
"path": "registry/remocn/glyph-matrix/index.tsx",
"content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Manrope\";\nimport { useId, useMemo } from \"react\";\nimport {\n AbsoluteFill,\n Easing,\n interpolate,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: MANROPE } = loadFont(\"normal\", {\n weights: [\"500\", \"600\"],\n subsets: [\"latin\"],\n});\n\n/**\n * Beat sheet (30fps, speed 1):\n * 0–48 a round 25×25 LED matrix counts down 3-2-1; each numeral swaps in\n * with a top-to-bottom row refresh.\n * 48–76 the 1 steps down in brightness while a progress arc sweeps the rim,\n * its head lit in the accent. Complete ring flashes to full.\n * 80–104 the ring pixels hop cell by cell into a pixel version of the real\n * remocn R; the accent head lands as the R's leg.\n * 104–126 the matrix shrinks and eases left; the unlit dots fade out so the\n * pixel R becomes the R of the logo.\n * 128–143 \"emocn\" types in beside it (Manrope 600, as on remocn.dev), accent\n * caret blinks out.\n * 143–180 hold on the lockup.\n * Lit dots and the typed word share one gradients.sh fill (\"limb\" on dark,\n * \"pixel-glass\" on light) that turns from the disc into the lockup.\n */\n\nexport interface GlyphMatrixProps {\n /**\n * Word typed in beside the pixel R at the end. \"remocn\" (any case) types\n * \"emocn\" so the lockup reads as the real logo.\n */\n label?: string;\n accent?: string;\n speed?: number;\n theme?: \"dark\" | \"light\";\n}\n\nconst N = 25;\nconst C = 12;\nconst R_MASK = 12.55;\nconst RING_IN = 10.4;\nconst HEAD = 0.22;\nconst TAU = Math.PI * 2;\n\nconst L1 = 0.3;\nconst L2 = 0.6;\nconst L3 = 1;\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\nconst INOUT = Easing.bezier(0.65, 0, 0.35, 1);\n\nconst THEMES = {\n dark: {\n bg: \"#0A0A0B\",\n off: \"#FFFFFF\",\n offAlpha: 0.085,\n // gradients.sh \"limb\" (#4b2bd6, #8a8bff, #e9ecff), deep end lifted a\n // step so the dimmest LED level still reads on black.\n fill: [\"#5B5BF5\", \"#8A8BFF\", \"#E9ECFF\"],\n },\n light: {\n bg: \"#F5F4F0\",\n off: \"#141416\",\n offAlpha: 0.075,\n // gradients.sh \"pixel-glass\".\n fill: [\"#3D6BFF\", \"#7A3CFF\", \"#FF4FB8\"],\n },\n} as const;\n\nconst NUMERALS: Record<string, string[]> = {\n \"3\": [\n \".#########.\",\n \"###########\",\n \"###########\",\n \"###.....###\",\n \"........###\",\n \"........###\",\n \"........###\",\n \"....######.\",\n \"....#######\",\n \"....######.\",\n \"........###\",\n \"........###\",\n \"........###\",\n \"###.....###\",\n \"###########\",\n \"###########\",\n \".#########.\",\n ],\n \"2\": [\n \".#########.\",\n \"###########\",\n \"###########\",\n \"###.....###\",\n \"........###\",\n \"........###\",\n \".......####\",\n \".....#####.\",\n \"...######..\",\n \"..#####....\",\n \".####......\",\n \"####.......\",\n \"###........\",\n \"###........\",\n \"###########\",\n \"###########\",\n \"###########\",\n ],\n \"1\": [\n \"....####...\",\n \"..######...\",\n \".#######...\",\n \".##..###...\",\n \".....###...\",\n \".....###...\",\n \".....###...\",\n \".....###...\",\n \".....###...\",\n \".....###...\",\n \".....###...\",\n \".....###...\",\n \".....###...\",\n \".....###...\",\n \"..#########\",\n \"..#########\",\n \"..#########\",\n ],\n};\n\n/**\n * The real remocn R, rasterised to the LED grid (14×15, strokes two cells\n * wide). \"o\" cells are the leg, where the accent head of the arc lands.\n */\nconst MARK = [\n \"###########...\",\n \".###########..\",\n \"..........###.\",\n \"...........##.\",\n \"...........###\",\n \"...........###\",\n \"...........##.\",\n \"......#######.\",\n \"..##########..\",\n \".#########....\",\n \"###....ooo....\",\n \"##......oo....\",\n \"##......ooo...\",\n \"##.......ooo..\",\n \"##........ooo.\",\n];\nconst MARK_COLS = 14;\nconst MARK_ROWS = 15;\nconst MARK_COL = C - 7;\nconst MARK_ROW = C - 7;\n/** As on remocn.dev: the R is 0.76em tall and sits 0.04em before \"emocn\". */\nconst R_EM = 0.76;\nconst LOGO_GAP = 0.04;\n\n/** Manrope 500 advance widths (1/1000 em) for ASCII 32–126. */\nconst ADV = [\n 200, 329, 417, 924, 602, 901, 657, 229, 435, 435, 446, 575, 278, 420, 270,\n 402, 626, 406, 578, 562, 596, 580, 621, 512, 591, 621, 314, 318, 622, 750,\n 622, 534, 907, 646, 619, 723, 681, 575, 510, 714, 697, 249, 476, 612, 518,\n 846, 696, 732, 616, 732, 640, 630, 600, 708, 616, 949, 622, 574, 630, 412,\n 402, 412, 673, 660, 506, 562, 600, 561, 600, 590, 362, 600, 604, 249, 263,\n 510, 249, 865, 604, 600, 600, 600, 374, 530, 412, 604, 523, 779, 536, 538,\n 531, 430, 269, 430, 680,\n];\n/** The logo word \"emocn\": Manrope 600 advances and kerning (em). */\nconst LOGO_ADV: Record<string, number> = {\n e: 0.596,\n m: 0.882,\n o: 0.61,\n c: 0.568,\n n: 0.615,\n};\nconst LOGO_KERN: Record<string, number> = { em: -0.015, mo: -0.006 };\n\ninterface TypeSet {\n chars: string[];\n /** Pen x of each glyph and its advance, in em. */\n xs: number[];\n advs: number[];\n width: number;\n weight: number;\n logo: boolean;\n}\n\nfunction typeset(label: string): TypeSet {\n const logo = label.trim().toLowerCase() === \"remocn\";\n const chars = Array.from(logo ? \"emocn\" : label);\n const track = logo ? -0.025 : -0.03;\n const xs: number[] = [];\n const advs: number[] = [];\n let pen = 0;\n chars.forEach((ch, i) => {\n if (logo && i > 0) pen += LOGO_KERN[chars[i - 1] + ch] ?? 0;\n const code = ch.charCodeAt(0);\n const a = logo\n ? (LOGO_ADV[ch] ?? 0.6)\n : (code >= 32 && code <= 126 ? ADV[code - 32] : 600) / 1000;\n xs.push(pen);\n advs.push(a);\n pen += a + (i < chars.length - 1 ? track : 0);\n });\n return { chars, xs, advs, width: pen, weight: logo ? 600 : 500, logo };\n}\n\ninterface Cell {\n i: number;\n j: number;\n}\n\nconst inMask = (i: number, j: number) =>\n (i - C) * (i - C) + (j - C) * (j - C) <= R_MASK * R_MASK;\nconst angleOf = (i: number, j: number) => {\n const a = Math.atan2(i - C, -(j - C));\n return a < 0 ? a + TAU : a;\n};\n\nfunction bitmapCells(rows: string[], ch = \"#\"): Cell[] {\n const w = rows[0].length;\n const h = rows.length;\n const c0 = C - Math.floor(w / 2);\n const r0 = C - Math.floor(h / 2);\n const out: Cell[] = [];\n rows.forEach((row, r) => {\n for (let x = 0; x < row.length; x++) {\n if (row[x] === ch) out.push({ i: c0 + x, j: r0 + r });\n }\n });\n return out;\n}\n\nfunction markCells(ch: string): Cell[] {\n const out: Cell[] = [];\n MARK.forEach((row, r) => {\n for (let x = 0; x < row.length; x++) {\n if (row[x] === ch) out.push({ i: MARK_COL + x, j: MARK_ROW + r });\n }\n });\n return out;\n}\n\ninterface Hop {\n from: Cell;\n to: Cell;\n delay: number;\n accent: boolean;\n}\n\nfunction pairUp(src: Cell[], tgt: Cell[], accent: boolean, d0: number) {\n const byAngle = (a: Cell, b: Cell) => angleOf(a.i, a.j) - angleOf(b.i, b.j);\n const s = [...src].sort(byAngle);\n const t = [...tgt].sort(byAngle);\n const n = Math.max(s.length, t.length);\n const out: Hop[] = [];\n for (let k = 0; k < n; k++) {\n out.push({\n from: s[Math.floor((k * s.length) / n)],\n to: t[Math.floor((k * t.length) / n)],\n delay: d0 + (k / n) * 10,\n accent,\n });\n }\n return out;\n}\n\nfunction buildModel() {\n const all: Cell[] = [];\n for (let j = 0; j < N; j++) {\n for (let i = 0; i < N; i++) if (inMask(i, j)) all.push({ i, j });\n }\n const ring = all.filter((c) => {\n const d = Math.hypot(c.i - C, c.j - C);\n return d >= RING_IN;\n });\n const ringBody = ring.filter((c) => angleOf(c.i, c.j) < TAU - HEAD);\n const ringHead = ring.filter((c) => angleOf(c.i, c.j) >= TAU - HEAD);\n const hops = [\n ...pairUp(ringBody, markCells(\"#\"), false, 0),\n ...pairUp(ringHead, markCells(\"o\"), true, 3),\n ];\n return {\n all,\n ring,\n numerals: {\n \"3\": bitmapCells(NUMERALS[\"3\"]),\n \"2\": bitmapCells(NUMERALS[\"2\"]),\n \"1\": bitmapCells(NUMERALS[\"1\"]),\n } as Record<string, Cell[]>,\n hops,\n };\n}\n\n// Timeline (frames at speed 1).\nconst NUM_STEP = 16;\nconst ROW_STEP = 0.45;\nconst ARC_START = 48;\nconst ARC_LEN = 26;\nconst HOP_START = 80;\nconst HOP_LEN = 13;\nconst MOVE_START = 104;\nconst MOVE_LEN = 22;\nconst TYPE_START = 128;\nconst TYPE_STEP = 2.5;\n\ntype Lit = Map<number, { b: number; accent: boolean }>;\n\nfunction light(lit: Lit, c: Cell, b: number, accent = false) {\n if (!inMask(c.i, c.j)) return;\n const key = c.j * N + c.i;\n const prev = lit.get(key);\n if (prev?.accent && !accent) return;\n lit.set(key, { b: accent ? b : Math.max(prev?.b ?? 0, b), accent });\n}\n\nfunction numeralSwap(\n lit: Lit,\n prev: Cell[] | null,\n next: Cell[],\n t: number,\n start: number,\n) {\n // Rows of the matrix refresh top to bottom; the row being written shows\n // at mid brightness for one step.\n const front = (t - start) / ROW_STEP;\n const r0 = C - 8;\n for (const c of next) {\n const row = c.j - r0;\n if (row < front - 1) light(lit, c, L3);\n else if (row < front) light(lit, c, L2);\n }\n if (prev) {\n for (const c of prev) {\n const row = c.j - r0;\n if (row >= front) light(lit, c, L3);\n }\n }\n}\n\nexport function GlyphMatrix({\n label = \"remocn\",\n accent = \"#3B5BFD\",\n speed = 1,\n theme = \"dark\",\n}: GlyphMatrixProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H } = useVideoConfig();\n const pal = THEMES[theme];\n const model = useMemo(buildModel, []);\n\n const lit: Lit = new Map();\n const nums = model.numerals;\n\n // 1. Countdown.\n if (t < NUM_STEP) numeralSwap(lit, null, nums[\"3\"], t, 0);\n else if (t < NUM_STEP * 2)\n numeralSwap(lit, nums[\"3\"], nums[\"2\"], t, NUM_STEP);\n else if (t < ARC_START)\n numeralSwap(lit, nums[\"2\"], nums[\"1\"], t, NUM_STEP * 2);\n else {\n // The 1 steps down through the brightness levels as the arc runs.\n const k = Math.floor((t - ARC_START) / 6);\n const b = [L3, L2, L1][k];\n if (b !== undefined) for (const c of nums[\"1\"]) light(lit, c, b);\n }\n\n // 2. Progress arc around the rim.\n if (t >= ARC_START && t < HOP_START + 1) {\n const p = INOUT(\n interpolate(t, [ARC_START, ARC_START + ARC_LEN], [0, 1], CLAMP),\n );\n const sweep = p * TAU;\n const done = t >= ARC_START + ARC_LEN;\n for (const c of model.ring) {\n const a = angleOf(c.i, c.j);\n if (a >= sweep) continue;\n const gap = sweep - a;\n if (gap < HEAD) light(lit, c, L3, true);\n else if (done) light(lit, c, L3);\n else if (gap < HEAD * 2.2) light(lit, c, L3);\n else light(lit, c, L2);\n }\n }\n\n // 3. Ring pixels hop into the R on the grid. The accent head flies in\n // accent and joins the gradient once it lands.\n if (t >= HOP_START + 1) {\n for (const h of model.hops) {\n const local = (t - HOP_START - h.delay) / HOP_LEN;\n const p = INOUT(Math.min(1, Math.max(0, local)));\n const i = Math.round(h.from.i + (h.to.i - h.from.i) * p);\n const j = Math.round(h.from.j + (h.to.j - h.from.j) * p);\n const landed = local >= 1;\n light(\n lit,\n { i, j },\n landed || local <= 0 ? L3 : h.accent ? L3 : L2,\n h.accent && !landed,\n );\n }\n }\n\n // Lockup: the pixel R is the logo's R (0.76em tall), the word follows it.\n const type = useMemo(() => typeset(label), [label]);\n const gapEm = type.logo ? LOGO_GAP : 0.16;\n const markEm = (R_EM * MARK_COLS) / MARK_ROWS;\n const fontSize = Math.min(\n (W * 0.62) / (markEm + gapEm + type.width),\n (H * 0.3) / R_EM,\n );\n const p1 = (R_EM * fontSize) / MARK_ROWS;\n const lockW = (markEm + gapEm + type.width) * fontSize;\n const markLeft = (W - lockW) / 2;\n const markTop = H / 2 - (R_EM * fontSize) / 2;\n const baseline = markTop + R_EM * fontSize;\n const lx = markLeft + (markEm + gapEm) * fontSize;\n\n const D0 = Math.min(H * 0.74, W * 0.5);\n const D1 = N * p1;\n const cx1 = markLeft - MARK_COL * p1 + D1 / 2;\n const cy1 = markTop - MARK_ROW * p1 + D1 / 2;\n const mv = INOUT(\n interpolate(t, [MOVE_START, MOVE_START + MOVE_LEN], [0, 1], CLAMP),\n );\n const D = D0 + (D1 - D0) * mv;\n const cx = W / 2 + (cx1 - W / 2) * mv;\n const cy = H / 2 + (cy1 - H / 2) * mv;\n const pitch = D / N;\n const ox = cx - D / 2;\n const oy = cy - D / 2;\n // LEDs swell as the disc shrinks so the R holds the weight of the type.\n const rOn = pitch * (0.4 + 0.07 * mv);\n\n const circle = (c: Cell, r: number) => {\n const x = ox + (c.i + 0.5) * pitch;\n const y = oy + (c.j + 0.5) * pitch;\n return `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 };\n\n // Unlit LEDs go dark as the disc shrinks, leaving only the R.\n const offAlpha = pal.offAlpha * (1 - mv);\n const offPath = offAlpha > 0.001 ? model.all.map((c) => circle(c, rOn)) : [];\n const levels = [L1, L2, L3];\n const inkPaths = levels.map(() => [] as string[]);\n const accentPaths: string[] = [];\n for (const [key, v] of lit) {\n const c = { i: key % N, j: Math.floor(key / N) };\n if (v.accent) accentPaths.push(circle(c, rOn));\n else inkPaths[levels.indexOf(v.b)]?.push(circle(c, rOn));\n }\n\n // One fill for every lit LED and the typed word: a diagonal across the\n // disc that turns into a left-to-right sweep across the lockup.\n const g0 = { x1: ox, y1: oy + D, x2: ox + D, y2: oy };\n const g1 = {\n x1: markLeft,\n y1: baseline,\n x2: markLeft + lockW,\n y2: markTop,\n };\n const mix = (a: number, b: number) => a + (b - a) * mv;\n const gradId = `gm${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n\n // Label: typed character by character, caret in the accent.\n const { chars, xs, advs } = type;\n const typed = Math.max(\n 0,\n Math.min(chars.length, Math.floor((t - TYPE_START) / TYPE_STEP) + 1),\n );\n const typeEnd = TYPE_START + chars.length * TYPE_STEP;\n const caretX =\n lx + (typed > 0 ? (xs[typed - 1] + advs[typed - 1]) * fontSize : 0);\n const caretOn =\n t >= MOVE_START + MOVE_LEN &&\n (t < typeEnd + 2 ||\n (t < typeEnd + 34 && Math.floor((t - typeEnd) / 8) % 2 === 1));\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={mix(g0.x1, g1.x1)}\n y1={mix(g0.y1, g1.y1)}\n x2={mix(g0.x2, g1.x2)}\n y2={mix(g0.y2, g1.y2)}\n >\n {pal.fill.map((col, k) => (\n <stop\n key={col}\n offset={k / (pal.fill.length - 1)}\n stopColor={col}\n />\n ))}\n </linearGradient>\n </defs>\n {offPath.length ? (\n <path d={offPath.join(\"\")} fill={pal.off} fillOpacity={offAlpha} />\n ) : null}\n {inkPaths.map((segs, k) =>\n segs.length ? (\n <path\n key={levels[k]}\n d={segs.join(\"\")}\n fill={`url(#${gradId})`}\n fillOpacity={levels[k]}\n />\n ) : null,\n )}\n {accentPaths.length ? (\n <path d={accentPaths.join(\"\")} fill={accent} />\n ) : null}\n {chars.slice(0, typed).map((ch, k) => (\n <text\n key={k}\n x={lx + xs[k] * fontSize}\n y={baseline}\n fill={`url(#${gradId})`}\n fontFamily={MANROPE}\n fontWeight={type.weight}\n fontSize={fontSize}\n style={{ fontKerning: \"none\" }}\n >\n {ch}\n </text>\n ))}\n {caretOn ? (\n <rect\n x={caretX + fontSize * 0.05}\n y={baseline - fontSize * 0.74}\n width={Math.max(2, fontSize * 0.04)}\n height={fontSize * 0.86}\n fill={accent}\n />\n ) : null}\n </svg>\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/glyph-matrix.tsx"
}
],
"type": "registry:component"
}