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": "grid-snap-poster",
"title": "Grid Snap Poster",
"description": "A giant gradient 3.0 snaps onto a grid poster with a headline and caption.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"files": [
{
"path": "registry/remocn/grid-snap-poster/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadGeist } from \"@remotion/google-fonts/Geist\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n AbsoluteFill,\n Easing,\n interpolate,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: geist } = loadGeist(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\nconst manrope = loadManrope(\"normal\", {\n weights: [\"500\", \"600\"],\n subsets: [\"latin\"],\n});\n\nexport interface GridSnapPosterProps {\n title?: string;\n number?: string;\n body?: string;\n name?: string;\n logo?: React.ReactNode;\n accent?: string;\n theme?: \"dark\" | \"light\";\n speed?: number;\n}\n\n// gradients.sh \"mesh\" palette, used as the clip-text fill of the hero number.\nconst MESH = [\"#ecdcf2\", \"#8796ee\", \"#2e45b7\", \"#0e1645\"] as const;\n\nfunction meshFill(theme: \"dark\" | \"light\", t: number) {\n const d = (i: number) => 5 * Math.sin(t / 70 + i * 1.7);\n const blob = (x: number, y: number, col: string, i: number, r = 68) =>\n `radial-gradient(70% 80% at ${x + d(i)}% ${y + d(i + 3)}%, ${col} 0%, transparent ${r}%)`;\n if (theme === \"dark\") {\n return [\n blob(14, 18, MESH[0], 0),\n blob(86, 24, MESH[1], 1),\n blob(70, 92, MESH[2], 2, 60),\n blob(24, 84, MESH[1], 3, 55),\n `linear-gradient(160deg, ${MESH[1]} 0%, ${MESH[2]} 100%)`,\n ].join(\", \");\n }\n return [\n blob(84, 20, MESH[1], 0, 62),\n blob(12, 30, MESH[1], 2, 42),\n blob(18, 86, MESH[2], 1, 60),\n `linear-gradient(160deg, ${MESH[2]} 0%, ${MESH[3]} 100%)`,\n ].join(\", \");\n}\n\nconst COLS = 12;\nconst STEP = 5;\nconst MOVE = 3;\nconst GRID_FADE = 84;\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_SNAP = Easing.bezier(0.2, 0.9, 0.1, 1);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n dark: {\n bg: \"#0A0A0B\",\n key: \"rgba(255,255,255,0.05)\",\n fg: \"#F3F2EF\",\n muted: \"#8B8A90\",\n hair: \"rgba(255,255,255,0.13)\",\n band: 0.05,\n grain: 0.07,\n },\n light: {\n bg: \"#F5F4F0\",\n key: \"rgba(255,255,255,0.9)\",\n fg: \"#121214\",\n muted: \"#6E6C67\",\n hair: \"rgba(18,18,20,0.14)\",\n band: 0.06,\n grain: 0.045,\n },\n} as const;\n\n// Geist 500 metrics (unitsPerEm 1000), measured from the font file.\nconst BASELINE = 0.855;\nconst CAP = 0.71;\nconst GEIST_500 =\n \"243,228,361,515,643,810,649,186,290,290,427,562,213,418,213,494,673,406,630,625,629,641,604,531,624,606,302,302,546,544,546,570,925,689,688,713,701,609,595,713,716,280,607,656,583,890,745,751,657,745,680,654,568,694,688,968,633,594,561,361,470,361,438,558,258,565,608,563,608,576,412,607,591,256,284,609,282,885,591,588,608,608,394,537,410,586,560,829,607,553,552,395,274,395,523\"\n .split(\",\")\n .map((v) => Number(v) / 1000);\n\nfunction glyphEm(ch: string) {\n const code = ch.charCodeAt(0);\n return code >= 32 && code < 127 ? GEIST_500[code - 32] : 0.58;\n}\n\nfunction em(text: string, track: number) {\n let w = 0;\n for (const ch of text) w += glyphEm(ch) + track;\n return w;\n}\n\nfunction hexA(hex: string, a: number) {\n const h = hex.replace(\"#\", \"\");\n const full =\n h.length === 3\n ? h\n .split(\"\")\n .map((x) => x + x)\n .join(\"\")\n : h.slice(0, 6);\n const v = Number.parseInt(full, 16);\n return `rgba(${(v >> 16) & 255},${(v >> 8) & 255},${v & 255},${a})`;\n}\n\nfunction Grain({ opacity }: { opacity: number }) {\n const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n return (\n <svg\n width=\"100%\"\n height=\"100%\"\n style={{ position: \"absolute\", inset: 0, opacity, pointerEvents: \"none\" }}\n aria-hidden\n >\n <filter id={id}>\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.9\"\n numOctaves={2}\n seed={3}\n stitchTiles=\"stitch\"\n />\n <feColorMatrix values=\"0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.9 0\" />\n </filter>\n <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n </svg>\n );\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\n/** remocn.dev logo: R mark (0.76em, on the baseline) + \"emocn\" in Manrope 600. */\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\nfunction Accented({ text, accent }: { text: string; accent: string }) {\n const parts = text.split(/([.!?])/);\n return (\n <>\n {parts.map((p, i) =>\n /^[.!?]$/.test(p) ? (\n <span key={`${i}-${p}`} style={{ color: accent }}>\n {p}\n </span>\n ) : (\n p\n ),\n )}\n </>\n );\n}\n\ninterface Snap {\n from: number;\n to: number;\n start: number;\n}\n\nfunction snapState(t: number, s: Snap) {\n const steps = Math.abs(s.to - s.from);\n const dir = Math.sign(s.to - s.from);\n const local = t - s.start;\n const total = steps * STEP;\n const appear = interpolate(local, [-8, -2], [0, 1], CLAMP);\n if (local <= 0) {\n return { pos: s.from, appear, moving: 0, landed: s.from, since: local };\n }\n if (local >= total) {\n return { pos: s.to, appear, moving: 0, landed: s.to, since: local - total };\n }\n const k = Math.floor(local / STEP);\n const frac = Math.min(1, (local - k * STEP) / MOVE);\n const e = EASE_SNAP(frac);\n const landedK = frac >= 1 ? k + 1 : k;\n return {\n pos: s.from + dir * (k + e),\n appear,\n moving: 1,\n landed: s.from + dir * landedK,\n since: frac >= 1 ? local - k * STEP - MOVE : local - k * STEP,\n };\n}\n\nexport function GridSnapPoster({\n title = \"Launch films,\\nset in motion.\",\n number = \"3.0\",\n body = \"Production-ready motion for launch videos. Install a component, drop in your words, render.\",\n name = \"remocn\",\n logo,\n accent = \"#3B5BFD\",\n theme = \"dark\",\n speed = 1,\n}: GridSnapPosterProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H } = useVideoConfig();\n const u = H / 720;\n const c = THEMES[theme];\n\n const mX = W * 0.075;\n const mY = H * 0.1;\n const cw = W - mX * 2;\n const g = 16 * u;\n const colW = (cw - g * (COLS - 1)) / COLS;\n const colX = (k: number) => mX + k * (colW + g);\n const span = (n: number) => n * colW + (n - 1) * g;\n const hair = Math.max(1, u);\n\n const lines = title.split(\"\\n\").map((l) => l.trim());\n const headTrack = -0.035;\n const headF = Math.min(\n 82 * u,\n span(9) / Math.max(...lines.map((l) => em(l, headTrack))),\n );\n const headLead = 0.98;\n const headLastBase = H - mY;\n const headTop =\n headLastBase - (lines.length - 1) * headLead * headF - BASELINE * headF;\n\n const numTrack = -0.045;\n const numMaxH = headTop + (BASELINE - CAP) * headF - mY - 56 * u;\n const numF = Math.min(\n numMaxH / CAP,\n span(8) / Math.max(0.6, em(number, numTrack)),\n );\n const numTop = mY - (BASELINE - CAP) * numF + 0.012 * numF;\n\n const numSnap: Snap = { from: 4, to: 0, start: 20 };\n const headSnap: Snap = { from: 3, to: 0, start: 32 };\n const bodySnap: Snap = { from: 6, to: 9, start: 54 };\n const logoSnap: Snap = { from: 10, to: 9, start: 66 };\n const snaps = [numSnap, headSnap, bodySnap, logoSnap].map((s) =>\n snapState(t, s),\n );\n\n const gridFade = interpolate(t, [GRID_FADE, GRID_FADE + 22], [1, 0], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const band = (i: number) =>\n interpolate(t, [i * 2, i * 2 + 18], [0, 1], { ...CLAMP, easing: EASE_IO });\n const ruleP = interpolate(t, [4, 34], [0, 1], { ...CLAMP, easing: EASE_IO });\n\n const flash = (k: number) => {\n let f = 0;\n for (const s of snaps) {\n if (s.landed === k && s.since >= 0 && s.appear > 0.5) {\n f = Math.max(f, Math.exp(-s.since / 5));\n }\n }\n return f;\n };\n\n const bodyF = 18 * u;\n const push = interpolate(t, [GRID_FADE, GRID_FADE + 70], [1, 1.012], {\n ...CLAMP,\n easing: EASE_IO,\n });\n\n const guide = (i: number) => {\n const s = snaps[i];\n const o = s.moving ? 1 : Math.exp(-Math.max(0, s.since) / 4) * s.appear;\n return (\n <div\n key={`g${i}`}\n style={{\n position: \"absolute\",\n left: colX(s.pos) - hair,\n top: mY,\n width: hair * 2,\n height: H - mY * 2,\n background: accent,\n opacity: o * gridFade * (s.since > -2 ? 1 : 0),\n }}\n />\n );\n };\n\n return (\n <AbsoluteFill style={{ background: c.bg, overflow: \"hidden\" }}>\n <AbsoluteFill\n style={{\n background: `radial-gradient(ellipse 70% 80% at 30% 30%, ${c.key}, transparent 70%)`,\n }}\n />\n <AbsoluteFill\n style={{ transform: `scale(${push})`, transformOrigin: \"40% 50%\" }}\n >\n <div style={{ position: \"absolute\", inset: 0, opacity: gridFade }}>\n {Array.from({ length: COLS }, (_, i) => {\n const p = band(i);\n return (\n <div\n key={`b${i}`}\n style={{\n position: \"absolute\",\n left: colX(i),\n top: mY,\n width: colW,\n height: (H - mY * 2) * p,\n background: hexA(accent, c.band + flash(i) * 0.2),\n borderLeft: `${hair}px solid ${hexA(accent, 0.28)}`,\n borderRight: `${hair}px solid ${hexA(accent, 0.28)}`,\n boxSizing: \"border-box\",\n }}\n />\n );\n })}\n {[mY, H - mY].map((y) => (\n <div\n key={`h${y}`}\n style={{\n position: \"absolute\",\n left: mX,\n top: y - hair / 2,\n width: cw * ruleP,\n height: hair,\n background: c.hair,\n }}\n />\n ))}\n </div>\n\n {[0, 1, 2, 3].map(guide)}\n\n <div\n style={{\n position: \"absolute\",\n left: colX(snaps[0].pos) - 0.05 * numF,\n top: numTop,\n fontFamily: geist,\n fontWeight: 500,\n fontSize: numF,\n lineHeight: 1,\n letterSpacing: `${numTrack}em`,\n whiteSpace: \"pre\",\n backgroundImage: meshFill(theme, t),\n WebkitBackgroundClip: \"text\",\n backgroundClip: \"text\",\n color: \"transparent\",\n opacity: snaps[0].appear,\n }}\n >\n {number}\n </div>\n\n <div\n style={{\n position: \"absolute\",\n left: colX(snaps[1].pos) - 0.04 * headF,\n top: headTop,\n fontFamily: geist,\n fontWeight: 500,\n fontSize: headF,\n lineHeight: headLead,\n letterSpacing: `${headTrack}em`,\n whiteSpace: \"pre\",\n color: c.fg,\n opacity: snaps[1].appear,\n }}\n >\n {lines.map((l, i) => (\n <div key={`${i}-${l}`}>\n <Accented text={l} accent={accent} />\n </div>\n ))}\n </div>\n\n {body ? (\n <div\n style={{\n position: \"absolute\",\n left: colX(snaps[2].pos),\n bottom: mY - 0.3 * bodyF,\n width: span(3),\n fontFamily: geist,\n fontWeight: 400,\n fontSize: bodyF,\n lineHeight: 1.4,\n letterSpacing: \"-0.005em\",\n color: c.muted,\n textWrap: \"pretty\",\n opacity: snaps[2].appear,\n }}\n >\n {body}\n </div>\n ) : null}\n\n <div\n style={{\n position: \"absolute\",\n left: colX(snaps[3].pos),\n top: mY,\n fontFamily: geist,\n fontWeight: 500,\n fontSize: 26 * u,\n lineHeight: 1,\n letterSpacing: \"-0.02em\",\n color: c.fg,\n opacity: snaps[3].appear,\n }}\n >\n {logo ??\n (name === \"remocn\" ? (\n <RemocnLogo fontSize={28 * u} color={c.fg} />\n ) : (\n name\n ))}\n </div>\n </AbsoluteFill>\n <Grain opacity={c.grain} />\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/grid-snap-poster.tsx"
}
],
"type": "registry:component"
}