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-block-decode",
"title": "Glyph Block Decode",
"description": "Blocky glyphs decode into \"Remocn Studio\" with its URL underlined beneath.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"registryDependencies": ["@remocn/gsh"],
"files": [
{
"path": "registry/remocn/glyph-block-decode/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadGeist } from \"@remotion/google-fonts/Geist\";\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n AbsoluteFill,\n continueRender,\n delayRender,\n Easing,\n Img,\n interpolate,\n random,\n spring,\n staticFile,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/remocn/gsh/gradient-engine\";\nimport { GshGround, gshParams } 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});\n\nexport interface GlyphBlockDecodeProps {\n name?: string;\n url?: string;\n images?: string[];\n blockColors?: string[];\n accent?: string;\n ink?: string;\n theme?: \"dark\" | \"light\";\n ground?: GshPresetId;\n groundParams?: Partial<GradientParams>;\n speed?: number;\n seed?: number;\n}\n\nconst DEFAULT_IMAGES = [\n \"reel/reel-2.jpg\",\n \"templates/product-showcase/sculpture.jpg\",\n \"reel/reel-5.jpg\",\n \"templates/brand-guidelines/ceramics.jpg\",\n \"templates/launch-anything/horizon.jpg\",\n \"templates/product-showcase/workbench.jpg\",\n \"reel/reel-3.jpg\",\n];\n\nconst LIGHT_GROUND: Partial<GradientParams> = {\n kind: \"mist\",\n background: \"#f1eee8\",\n colors: [\"#f7e7f0\", \"#f6efd2\", \"#e3e0f6\", \"#f1eee8\"],\n blur: 0.8,\n warp: 0.35,\n seed: 5,\n grain: 0.18,\n};\n\nconst THEMES = {\n dark: {\n ink: \"#f2f0ea\",\n muted: \"rgba(242,240,234,0.62)\",\n accent: \"#4a6bff\",\n blocks: [\"#4a6bff\", \"#c8b9ff\", \"#c8b9ff\", \"#4a6bff\", \"#ff6a3d\", \"#f2f0ea\"],\n chip: \"#121218\",\n chipGlyph: \"rgba(255,255,255,0.86)\",\n ground: \"velvet-hour\" as GshPresetId | undefined,\n groundParams: undefined as Partial<GradientParams> | undefined,\n groundOffset: 6,\n scrim: \"5,5,12\",\n scrimAlpha: 0.5,\n shadow:\n \"0 1px 2px rgba(0,0,0,0.35), 0 10px 24px rgba(0,0,0,0.32), 0 30px 70px rgba(0,0,0,0.35)\",\n hairline: \"inset 0 0 0 1px rgba(255,255,255,0.1)\",\n },\n light: {\n ink: \"#16161a\",\n muted: \"rgba(22,22,26,0.56)\",\n accent: \"#1f7bff\",\n blocks: [\"#1f7bff\", \"#c9b4ff\", \"#c9b4ff\", \"#1f7bff\", \"#ff5a2e\", \"#16161a\"],\n chip: \"#141418\",\n chipGlyph: \"rgba(255,255,255,0.9)\",\n ground: undefined as GshPresetId | undefined,\n groundParams: LIGHT_GROUND as Partial<GradientParams> | undefined,\n groundOffset: 2,\n scrim: \"241,238,232\",\n scrimAlpha: 0.3,\n shadow:\n \"0 1px 2px rgba(30,24,20,0.08), 0 8px 20px rgba(30,24,20,0.09), 0 26px 60px rgba(30,24,20,0.12)\",\n hairline: \"inset 0 0 0 1px rgba(0,0,0,0.06)\",\n },\n};\n\nconst BEAT = {\n nameIn: -8,\n satOut: 18,\n nameOut: 18,\n nameDone: 60,\n urlIn: 36,\n urlOut: 54,\n urlDone: 78,\n rule: 84,\n ruleLen: 18,\n};\n\nconst FONT_PX = 200;\nconst NAME_TRACK = -0.035;\nconst URL_TRACK = -0.01;\nconst GLYPHS = \"ABCDEFGHJKLMNPQRSTUVWXYZabcdeghkmnopqrsuvwxyz0123456789#%&/\";\nconst EXIT = Easing.bezier(0.55, 0, 1, 0.45);\nconst MORPH = Easing.bezier(0.65, 0, 0.35, 1);\nconst CAMERA = Easing.bezier(0.87, 0, 0.13, 1);\nconst REVEAL = Easing.bezier(0.22, 1, 0.36, 1);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\nconst CHIP = { mass: 0.5, damping: 12, stiffness: 200 };\nconst CARD = { mass: 0.8, damping: 18, stiffness: 160 };\n\ntype Measure = (s: string, weight: number) => number;\n\nfunction buildMeasure(_version: number): Measure {\n const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n const cache: Record<string, number> = {};\n return (s: string, weight: number) => {\n const k = `${weight}|${s}`;\n if (cache[k] === undefined) {\n if (!ctx) return s.length * 0.55;\n ctx.font = `${weight} ${FONT_PX}px \"${geist.fontFamily}\"`;\n cache[k] = ctx.measureText(s).width / FONT_PX;\n }\n return cache[k];\n };\n}\n\nfunction useMeasure() {\n const [version, setVersion] = useState(0);\n const [handle] = useState(() => delayRender(\"glyph-block-decode: fonts\"));\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(`400 100px \"${geist.fontFamily}\"`),\n document.fonts.load(`300 100px \"${geist.fontFamily}\"`),\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]);\n return useMemo(() => buildMeasure(version), [version]);\n}\n\nconst resolveSrc = (src: string) =>\n /^(https?:|data:|\\/)/.test(src) ? src : staticFile(src);\n\ninterface Char {\n ch: string;\n x: number;\n y: number;\n size: number;\n weight: number;\n track: number;\n url: boolean;\n reveal: number;\n flick: number;\n seed: number;\n}\n\ninterface Tile {\n x: number;\n y: number;\n w: number;\n h: number;\n kind: \"img\" | \"color\" | \"ui\";\n img: number;\n color: string;\n icon: number;\n tIn: number;\n tOut: number;\n rot: number;\n fromX: number;\n fromY: number;\n blur: number;\n sat: boolean;\n rule: boolean;\n}\n\nfunction ChipIcon({\n kind,\n size,\n color,\n}: {\n kind: number;\n size: number;\n color: string;\n}) {\n const common = {\n width: size,\n height: size,\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n stroke: color,\n strokeWidth: 1.6,\n strokeLinecap: \"round\" as const,\n strokeLinejoin: \"round\" as const,\n style: { display: \"block\" },\n };\n if (kind === 0) {\n return (\n <svg {...common} aria-hidden>\n <path d=\"M9 7.5v9l7-4.5z\" fill={color} />\n </svg>\n );\n }\n if (kind === 1) {\n return (\n <svg {...common} aria-hidden>\n <rect x=\"3.5\" y=\"5\" width=\"17\" height=\"14\" rx=\"2.5\" />\n <path d=\"M3.5 9h17\" />\n <circle cx=\"6.3\" cy=\"7\" r=\"0.4\" fill={color} />\n <circle cx=\"8.3\" cy=\"7\" r=\"0.4\" fill={color} />\n </svg>\n );\n }\n return (\n <svg {...common} aria-hidden>\n <path d=\"M12 5v14M5 12h14\" />\n </svg>\n );\n}\n\nexport function GlyphBlockDecode({\n name = \"Remocn Studio\",\n url = \"remocn.dev/studio\",\n images = DEFAULT_IMAGES,\n blockColors,\n accent,\n ink,\n theme = \"dark\",\n ground,\n groundParams,\n speed = 1,\n seed = 7,\n}: GlyphBlockDecodeProps) {\n const rawFrame = useCurrentFrame();\n const frame = rawFrame * speed;\n const { width: W, height: H, fps, durationInFrames } = useVideoConfig();\n const c = THEMES[theme];\n const inkC = ink ?? c.ink;\n const hi = accent ?? c.accent;\n const palette = blockColors ?? [hi, ...c.blocks.slice(1)];\n const preset = ground ?? (groundParams ? undefined : c.ground);\n const gParams = groundParams ?? (ground ? undefined : c.groundParams);\n const bg = gshParams(preset, gParams).background;\n const portrait = H > W * 1.1;\n const m = useMeasure();\n const pics = (images.length > 0 ? images : DEFAULT_IMAGES).map(resolveSrc);\n\n let content: ReactNode = <div />;\n if (m) {\n const nameLines = portrait && name.includes(\" \") ? name.split(\" \") : [name];\n const lineEm = (s: string, w: number, tr: number) =>\n m(s, w) + tr * Math.max(0, Array.from(s).length - 1);\n const widest = Math.max(\n ...nameLines.map((l) => lineEm(l, 400, NAME_TRACK)),\n );\n const nameSize = Math.min(\n ((portrait ? 0.82 : 0.62) * W) / widest,\n H * (portrait ? 0.14 : 0.22),\n );\n const urlEm = lineEm(url, 300, URL_TRACK);\n const urlSize = Math.min(\n Math.max(nameSize * (portrait ? 0.26 : 0.3), H * 0.032),\n (W * 0.72) / urlEm,\n );\n const nameLH = nameSize * 0.98;\n const gap = nameSize * (portrait ? 0.5 : 0.42);\n const blockH = nameLines.length * nameLH + gap + urlSize;\n const top = H / 2 - blockH / 2;\n\n const chars: Char[] = [];\n const lineRows: {\n start: number;\n end: number;\n url: boolean;\n size: number;\n }[] = [];\n const place = (\n s: string,\n cy: number,\n size: number,\n weight: number,\n tr: number,\n isUrl: boolean,\n ) => {\n const wEm = lineEm(s, weight, tr);\n const x0 = W / 2 - (wEm * size) / 2;\n const start = chars.length;\n Array.from(s).forEach((ch, i) => {\n const pre = s.slice(0, i);\n chars.push({\n ch,\n x: x0 + (m(pre, weight) + tr * i) * size,\n y: cy,\n size,\n weight,\n track: tr,\n url: isUrl,\n reveal: 0,\n flick: 0,\n seed: seed * 101 + chars.length,\n });\n });\n lineRows.push({ start, end: chars.length, url: isUrl, size });\n };\n nameLines.forEach((l, li) => {\n place(l, top + nameLH * (li + 0.5), nameSize, 400, NAME_TRACK, false);\n });\n const urlY = top + nameLines.length * nameLH + gap + urlSize / 2;\n place(url, urlY, urlSize, 300, URL_TRACK, true);\n const urlFirst = chars.findIndex((ch) => ch.url);\n const urlLeft = chars[urlFirst].x;\n const urlRight = W / 2 + (urlEm * urlSize) / 2;\n const charRight = (i: number) => {\n const ch = chars[i];\n return ch.x + m(ch.ch, ch.weight) * ch.size;\n };\n\n const tiles: Tile[] = [];\n const groups: { tile: number; chars: number[] }[] = [];\n let r = 0;\n const rnd = () => random(`gbd-${seed}-${r++}`);\n const cx = W / 2;\n const cy = top + (nameLines.length * nameLH) / 2;\n lineRows.forEach((row) => {\n let i = row.start;\n while (i < row.end) {\n if (chars[i].ch === \" \") {\n i++;\n continue;\n }\n const maxRun = row.url\n ? 2 + Math.floor(rnd() * 3)\n : 1 + Math.floor(rnd() * 3);\n const run: number[] = [];\n while (i < row.end && run.length < maxRun && chars[i].ch !== \" \") {\n run.push(i);\n i++;\n }\n const size = row.size;\n const pad = size * 0.06;\n const x0 = chars[run[0]].x - pad;\n const x1 = charRight(run[run.length - 1]) + pad;\n const hS = row.url ? 1.3 + rnd() * 0.3 : 0.95 + rnd() * 0.35;\n const h = size * hS;\n const yj = (rnd() - 0.5) * size * (row.url ? 0.2 : 0.16);\n const wj = (rnd() - 0.3) * size * 0.18;\n const pick = rnd();\n const kind: Tile[\"kind\"] =\n pick < 0.58 ? \"img\" : pick < 0.82 ? \"color\" : \"ui\";\n const tx = x0 - wj / 2;\n const ty = chars[run[0]].y - h / 2 + yj;\n const tw = x1 - x0 + wj;\n tiles.push({\n x: tx,\n y: ty,\n w: tw,\n h,\n kind,\n img: Math.floor(rnd() * pics.length),\n color: palette[Math.floor(rnd() * palette.length)],\n icon: Math.floor(rnd() * 3),\n tIn: 0,\n tOut: 0,\n rot: (rnd() - 0.5) * 16,\n fromX: tx + tw / 2 + (cx - (tx + tw / 2)) * 0.55,\n fromY: ty + h / 2 + ((row.url ? urlY : cy) - (ty + h / 2)) * 0.55,\n blur: 0,\n sat: false,\n rule: false,\n });\n groups.push({ tile: tiles.length - 1, chars: run });\n }\n });\n\n const schedule = (\n isUrl: boolean,\n inAt: number,\n outA: number,\n outB: number,\n ) => {\n const ids = groups\n .map((g, gi) => ({ g, gi }))\n .filter(({ g }) => chars[g.chars[0]].url === isUrl);\n const n = ids.length;\n const order = ids\n .map((o, k) => ({ ...o, key: k / Math.max(1, n) + rnd() * 0.32 }))\n .sort((a, b) => a.key - b.key);\n const inOrder = ids\n .map((o) => ({ ...o, key: rnd() }))\n .sort((a, b) => a.key - b.key);\n inOrder.forEach(({ g }, k) => {\n tiles[g.tile].tIn = inAt + k * (isUrl ? 1 : 1.5);\n });\n order.forEach(({ g }, k) => {\n const p = n <= 1 ? 1 : k / (n - 1);\n const t = outA + (outB - outA) * p ** 0.72;\n tiles[g.tile].tOut = t;\n g.chars.forEach((ci) => {\n chars[ci].reveal = t + 1;\n chars[ci].flick = 3 + Math.floor(rnd() * 3);\n });\n });\n return order.length > 0 ? order[order.length - 1].g : null;\n };\n schedule(false, BEAT.nameIn, BEAT.nameOut, BEAT.nameDone);\n const lastUrl = schedule(true, BEAT.urlIn, BEAT.urlOut, BEAT.urlDone);\n if (lastUrl) {\n const t = tiles[lastUrl.tile];\n t.kind = \"color\";\n t.color = hi;\n t.rule = true;\n t.tOut = BEAT.rule;\n lastUrl.chars.forEach((ci) => {\n chars[ci].reveal = BEAT.rule + 3;\n });\n }\n\n groups.forEach((g) => {\n const p = tiles[g.tile];\n if (chars[g.chars[0]].url || rnd() > 0.45) return;\n const s = p.h * (0.42 + rnd() * 0.2);\n const w = s * (1.2 + rnd() * 0.6);\n const up = rnd() < 0.5;\n const x = p.x + (rnd() * 0.8 - 0.1) * p.w;\n const y = up ? p.y - s * 0.55 : p.y + p.h - s * 0.45;\n const pick = rnd();\n tiles.push({\n x,\n y,\n w,\n h: s,\n kind: pick < 0.6 ? \"img\" : pick < 0.8 ? \"ui\" : \"color\",\n img: Math.floor(rnd() * pics.length),\n color: palette[Math.floor(rnd() * palette.length)],\n icon: Math.floor(rnd() * 3),\n tIn: p.tIn + 3,\n tOut: p.tOut - 3 - rnd() * 3,\n rot: (rnd() - 0.5) * 14,\n fromX: p.fromX,\n fromY: p.fromY,\n blur: 0,\n sat: false,\n rule: false,\n });\n });\n\n const nameW = widest * nameSize;\n const sats = portrait ? 6 : 7;\n for (let k = 0; k < sats; k++) {\n const ang = (k / sats) * Math.PI * 2 + rnd() * 0.6 + 0.3;\n const rx = (portrait ? W * 0.4 : nameW * 0.62) * (0.85 + rnd() * 0.3);\n const ry =\n (portrait ? nameLines.length * nameLH * 0.95 : nameSize * 1.25) *\n (0.85 + rnd() * 0.35);\n const s = nameSize * (0.35 + rnd() * 0.35);\n const w = s * (1.1 + rnd() * 0.7);\n const pick = rnd();\n const x = cx + Math.cos(ang) * rx - w / 2;\n const y = cy + Math.sin(ang) * ry - s / 2;\n tiles.push({\n x,\n y,\n w,\n h: s,\n kind: pick < 0.6 ? \"img\" : pick < 0.85 ? \"color\" : \"ui\",\n img: Math.floor(rnd() * pics.length),\n color: palette[Math.floor(rnd() * palette.length)],\n icon: Math.floor(rnd() * 3),\n tIn: -6 + k * 2,\n tOut: BEAT.satOut + k * 4 + rnd() * 3,\n rot: (rnd() - 0.5) * 20,\n fromX: x + w / 2 + (cx - (x + w / 2)) * 0.7,\n fromY: y + s / 2 + (cy - (y + s / 2)) * 0.7,\n blur: 1.2 + rnd() * 2.6,\n sat: true,\n rule: false,\n });\n }\n\n const f = frame;\n const ruleH = Math.max(2, urlSize * 0.07);\n const ruleY = urlY + urlSize * 0.62;\n\n const tileEls = tiles.map((t, ti) => {\n const inP = spring({\n frame: f - t.tIn,\n fps,\n config: t.sat ? CHIP : CARD,\n });\n if (f < t.tIn) return null;\n const ccx = t.x + t.w / 2;\n const ccy = t.y + t.h / 2;\n let x = t.fromX + (ccx - t.fromX) * inP;\n let y = t.fromY + (ccy - t.fromY) * inP;\n let w = t.w;\n let h = t.h;\n let scale = 0.25 + 0.75 * inP;\n let rot = t.rot * (1 - inP) * 0.6;\n let op = Math.min(1, inP * 3);\n let radius = Math.min(w, h) * 0.12;\n const bob = Math.sin(f * 0.07 + ti * 1.7) * t.h * 0.025;\n y += bob;\n if (t.sat) {\n const drift = (f - t.tIn) * 0.18;\n x += (ccx - cx) * 0.004 * drift;\n y += (ccy - cy) * 0.004 * drift;\n }\n const d = f - t.tOut;\n if (t.rule && d >= 0) {\n const p = interpolate(d, [0, BEAT.ruleLen], [0, 1], {\n ...CLAMP,\n easing: MORPH,\n });\n const tx = (urlLeft + urlRight) / 2;\n x = ccx + (tx - ccx) * p;\n y = ccy + (ruleY - ccy) * p;\n w = t.w + (urlRight - urlLeft - t.w) * p;\n h = t.h + (ruleH - t.h) * p;\n radius = radius + (ruleH / 2 - radius) * p;\n scale = 1;\n rot = 0;\n } else if (d >= 0) {\n const p = interpolate(d, [0, 7], [0, 1], { ...CLAMP, easing: EXIT });\n const punch = interpolate(d, [0, 2], [1, 1.07], CLAMP);\n scale = (punch - (punch - 0) * p) * scale;\n rot += t.rot * p;\n y -= t.h * 0.35 * p;\n x += (ccx - cx) * 0.06 * p;\n op *= interpolate(d, [4, 7], [1, 0], CLAMP);\n if (d > 7) return null;\n }\n const fill =\n t.kind === \"img\" ? (\n <Img\n src={pics[t.img]}\n style={{\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n display: \"block\",\n }}\n />\n ) : t.kind === \"ui\" ? (\n <div\n style={{\n width: \"100%\",\n height: \"100%\",\n background: c.chip,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <ChipIcon\n kind={t.icon}\n size={Math.min(w, h) * 0.46}\n color={c.chipGlyph}\n />\n </div>\n ) : (\n <div style={{ width: \"100%\", height: \"100%\", background: t.color }} />\n );\n return (\n <div\n key={`t${ti}`}\n style={{\n position: \"absolute\",\n left: x - w / 2,\n top: y - h / 2,\n width: w,\n height: h,\n borderRadius: radius,\n overflow: \"hidden\",\n opacity: op * (t.sat ? 0.9 : 1),\n transform: `rotate(${rot.toFixed(2)}deg) scale(${scale.toFixed(4)})`,\n boxShadow: t.rule && d >= 0 ? \"none\" : `${c.shadow}, ${c.hairline}`,\n filter: t.blur > 0 ? `blur(${t.blur.toFixed(2)}px)` : undefined,\n zIndex: t.sat ? 1 : 3,\n }}\n >\n {fill}\n </div>\n );\n });\n\n const charEls = chars.map((ch, i) => {\n if (ch.ch === \" \" || f < ch.reveal) return null;\n const d = f - ch.reveal;\n const flicking = d < ch.flick;\n const glyph = flicking\n ? GLYPHS[\n Math.floor(\n random(`${ch.seed}-${Math.floor(d / 1.5)}`) * GLYPHS.length,\n )\n ]\n : ch.ch;\n const settle = interpolate(d - ch.flick, [0, 6], [0, 1], {\n ...CLAMP,\n easing: REVEAL,\n });\n const color = flicking ? hi : inkC;\n return (\n <div\n key={`c${i}`}\n style={{\n position: \"absolute\",\n left: ch.x,\n top: ch.y - ch.size / 2,\n fontSize: ch.size,\n lineHeight: 1,\n height: ch.size,\n display: \"flex\",\n alignItems: \"center\",\n whiteSpace: \"pre\",\n fontFamily: geist.fontFamily,\n fontWeight: ch.weight,\n color: ch.url && !flicking ? c.muted : color,\n opacity: flicking ? 0.9 : 1,\n transform: `translateY(${((1 - settle) * ch.size * 0.03).toFixed(2)}px)`,\n zIndex: 2,\n }}\n >\n {glyph}\n </div>\n );\n });\n\n const push = interpolate(rawFrame, [0, durationInFrames], [1, 1.04], {\n ...CLAMP,\n easing: CAMERA,\n });\n content = (\n <AbsoluteFill\n style={{\n transform: `scale(${push.toFixed(5)})`,\n transformOrigin: \"50% 50%\",\n }}\n >\n {charEls}\n {tileEls}\n </AbsoluteFill>\n );\n }\n\n return (\n <AbsoluteFill style={{ background: bg, overflow: \"hidden\" }}>\n <GshGround\n preset={preset}\n params={gParams}\n timeOffset={c.groundOffset}\n timeScale={0.5}\n />\n <AbsoluteFill\n style={{\n background: `radial-gradient(${portrait ? \"95% 50%\" : \"70% 60%\"} at 50% 50%, rgba(${c.scrim},${c.scrimAlpha}) 0%, rgba(${c.scrim},0) 100%)`,\n }}\n />\n {content}\n </AbsoluteFill>\n );\n}\n\nexport default GlyphBlockDecode;\n",
"type": "registry:component",
"target": "components/remocn/glyph-block-decode.tsx"
}
],
"type": "registry:component"
}