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": "clock-sweep",
"title": "Clock Sweep",
"description": "A clock hand sweeps a glowing wedge as the line From idea to video in 4 minutes appears.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"files": [
{
"path": "registry/remocn/clock-sweep/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadSans } from \"@remotion/google-fonts/InstrumentSans\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { loadFont as loadMono } from \"@remotion/google-fonts/JetBrainsMono\";\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: display } = loadSans(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\nconst { fontFamily: serif } = loadSerif(\"italic\", {\n weights: [\"400\"],\n subsets: [\"latin\"],\n});\nconst { fontFamily: mono } = loadMono(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\n\nexport interface ClockSweepProps {\n minutes?: number;\n title?: string;\n accent?: string;\n theme?: \"dark\" | \"light\";\n speed?: number;\n}\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_SWEEP = Easing.bezier(0.55, 0, 0.3, 1);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n dark: {\n bg: \"#0A0A0B\",\n stage: \"rgba(255,255,255,0.05)\",\n glow: [\"rgba(75,43,214,0.2)\", \"rgba(138,139,255,0.08)\"],\n fg: \"#F3F2EF\",\n muted: \"#85848A\",\n major: \"rgba(243,242,239,0.78)\",\n minor: \"rgba(243,242,239,0.3)\",\n wedge: 0.92,\n limb: [\"#160c3a\", \"#4b2bd6\", \"#8a8bff\", \"#e9ecff\"],\n word: \"linear-gradient(100deg, #e9ecff 0%, #b4b6ff 40%, #8a8bff 75%, #6d5cf0 100%)\",\n grain: 0.065,\n },\n light: {\n bg: \"#F5F4F0\",\n stage: \"rgba(255,255,255,0.9)\",\n glow: [\"rgba(138,139,255,0.16)\", \"rgba(233,236,255,0.9)\"],\n fg: \"#121214\",\n muted: \"#6E6C67\",\n major: \"rgba(18,18,20,0.7)\",\n minor: \"rgba(18,18,20,0.26)\",\n wedge: 0.85,\n limb: [\"#e9ecff\", \"#8a8bff\", \"#4b2bd6\", \"#160c3a\"],\n word: \"linear-gradient(100deg, #4b2bd6 0%, #6a5cf5 45%, #8a8bff 100%)\",\n grain: 0.045,\n },\n} as const;\n\ntype Palette = (typeof THEMES)[keyof typeof THEMES];\n\nfunction polar(deg: number, r: number) {\n const a = (deg * Math.PI) / 180;\n return { x: Math.sin(a) * r, y: -Math.cos(a) * r };\n}\n\nfunction arcPath(deg: number, r: number) {\n const a = polar(0, r);\n const b = polar(Math.max(0.001, deg), r);\n const large = deg > 180 ? 1 : 0;\n return `M ${a.x} ${a.y} A ${r} ${r} 0 ${large} 1 ${b.x} ${b.y}`;\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={21}\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\nfunction Dial({\n t,\n r,\n value,\n minutes,\n accent,\n p,\n u,\n}: {\n t: number;\n r: number;\n value: number;\n minutes: number;\n accent: string;\n p: Palette;\n u: number;\n}) {\n const deg = value * 6;\n const stop = interpolate(t, [66, 69, 84], [0, 1, 0], CLAMP);\n const settled = interpolate(t, [66, 76], [0, 1], CLAMP);\n\n const ticks: React.ReactNode[] = [];\n for (let i = 0; i < 60; i++) {\n const major = i % 5 === 0;\n const at = 2 + i * 0.32;\n const k = interpolate(t, [at, at + 10], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const len = r * (major ? 0.085 : 0.042);\n const outer = r * (1 - (1 - k) * 0.05);\n const a = polar(i * 6, outer);\n const b = polar(i * 6, outer - len);\n const passed = i > 0 && i <= minutes && deg >= i * 6 - 0.01;\n const lit = passed\n ? interpolate(deg, [i * 6 - 0.01, i * 6 + 2], [0, 1], CLAMP)\n : 0;\n const zero = i === 0 ? interpolate(t, [28, 34], [0, 1], CLAMP) : 0;\n const base = major ? p.major : p.minor;\n ticks.push(\n <line\n key={i}\n x1={a.x}\n y1={a.y}\n x2={b.x}\n y2={b.y}\n stroke={lit > 0.5 || zero > 0.5 ? accent : base}\n strokeWidth={(major ? 2 : 1.25) * u * (1 + 0.4 * Math.max(lit, zero))}\n strokeLinecap=\"round\"\n opacity={k}\n />,\n );\n }\n\n const handIn = interpolate(t, [12, 30], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const handLen = r * 0.8 * (0.18 + 0.82 * handIn);\n const tip = polar(deg, handLen);\n const tail = polar(deg + 180, r * 0.1 * handIn);\n const arcR = r * 1.075;\n const arcW = 3 * u;\n const arcOn = interpolate(t, [28, 34], [0, 1], CLAMP);\n const [c0, c1, c2, c3] = p.limb;\n const d = Math.max(0.001, deg);\n const wedge = `conic-gradient(from 0deg, ${c0} 0deg, ${c1} ${d * 0.45}deg, ${c2} ${d * 0.82}deg, ${c3} ${d}deg, transparent ${d}deg)`;\n const wedgeMask =\n \"radial-gradient(circle closest-side, transparent 8%, rgba(0,0,0,0.5) 40%, #000 92%, transparent 92.6%)\";\n const endDot = polar(deg, arcR);\n const pad = r * 1.25;\n\n return (\n <>\n {deg > 0.05 ? (\n <div\n style={{\n position: \"absolute\",\n left: -r * 1.04,\n top: -r * 1.04,\n width: r * 2.08,\n height: r * 2.08,\n borderRadius: \"50%\",\n background: wedge,\n maskImage: wedgeMask,\n WebkitMaskImage: wedgeMask,\n opacity: p.wedge * (0.85 + stop * 0.15),\n }}\n />\n ) : null}\n <svg\n width={pad * 2}\n height={pad * 2}\n viewBox={`${-pad} ${-pad} ${pad * 2} ${pad * 2}`}\n style={{\n position: \"absolute\",\n left: -pad,\n top: -pad,\n overflow: \"visible\",\n }}\n aria-hidden\n >\n <circle\n r={r * 1.075}\n fill=\"none\"\n stroke={p.minor}\n strokeWidth={Math.max(1, u)}\n opacity={0.5 * interpolate(t, [6, 26], [0, 1], CLAMP)}\n />\n {ticks}\n {deg > 0.05 ? (\n <path\n d={arcPath(deg, arcR)}\n fill=\"none\"\n stroke={accent}\n strokeWidth={arcW * (1 + stop * 0.35)}\n strokeLinecap=\"round\"\n opacity={arcOn}\n />\n ) : null}\n <circle\n cx={endDot.x}\n cy={endDot.y}\n r={arcW * 1.6}\n fill={accent}\n opacity={settled}\n />\n <circle\n r={arcW * (1.6 + 2.6 * stop)}\n cx={endDot.x}\n cy={endDot.y}\n fill=\"none\"\n stroke={accent}\n strokeWidth={u}\n opacity={stop * 0.6}\n />\n <line\n x1={tail.x}\n y1={tail.y}\n x2={tip.x}\n y2={tip.y}\n stroke={p.fg}\n strokeWidth={2.25 * u}\n strokeLinecap=\"round\"\n opacity={handIn}\n />\n <circle r={5.5 * u} fill={p.fg} opacity={handIn} />\n <circle r={2 * u} fill={accent} opacity={handIn} />\n </svg>\n </>\n );\n}\n\nfunction Headline({\n t,\n title,\n minutes,\n size,\n p,\n}: {\n t: number;\n title: string;\n minutes: number;\n size: number;\n p: Palette;\n}) {\n const lines = title.split(\"\\n\").map((l) => l.split(/\\s+/).filter(Boolean));\n const flat = lines.flat();\n const hit = flat.indexOf(String(minutes));\n let n = 0;\n return (\n <div\n style={{\n fontFamily: display,\n fontWeight: 500,\n fontSize: size,\n lineHeight: 1.06,\n letterSpacing: \"-0.032em\",\n color: p.fg,\n textWrap: \"balance\",\n }}\n >\n {lines.map((line, li) => (\n <div key={`l${li}-${line.join(\" \")}`}>\n {line.map((w, wi) => {\n const i = n++;\n const at = 82 + i * 2.5;\n const k = interpolate(t, [at, at + 20], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const accentWord = hit >= 0 && (i === hit || i === hit + 1);\n return (\n <span\n key={`${w}-${i}`}\n style={{\n display: \"inline-block\",\n overflow: \"hidden\",\n verticalAlign: \"top\",\n paddingBottom: size * 0.14,\n marginBottom: -size * 0.14,\n marginRight: wi < line.length - 1 ? size * 0.24 : 0,\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n transform: `translateY(${(1 - k) * 135}%)`,\n color: p.fg,\n ...(accentWord\n ? {\n fontFamily: serif,\n fontStyle: \"italic\",\n fontWeight: 400,\n fontSize: \"1.12em\",\n lineHeight: 0.95,\n letterSpacing: \"-0.01em\",\n paddingRight: \"0.06em\",\n backgroundImage: p.word,\n WebkitBackgroundClip: \"text\",\n backgroundClip: \"text\",\n color: \"transparent\",\n }\n : null),\n }}\n >\n {w}\n </span>\n </span>\n );\n })}\n </div>\n ))}\n </div>\n );\n}\n\nexport function ClockSweep({\n minutes = 4,\n title,\n accent = \"#3B5BFD\",\n theme = \"dark\",\n speed = 1,\n}: ClockSweepProps) {\n const t = useCurrentFrame() * speed;\n const { width, height } = useVideoConfig();\n const u = height / 720;\n const p: Palette = THEMES[theme];\n const total = Math.min(59, Math.max(0.25, minutes));\n\n const sweep = interpolate(t, [32, 66], [0, 1], {\n ...CLAMP,\n easing: EASE_SWEEP,\n });\n const after = Math.max(0, t - 66);\n const kick =\n t > 66 ? 0.07 * Math.sin(after * 1.1) * Math.exp(-after * 0.45) : 0;\n const value = total * sweep + kick;\n\n const r = Math.min(height * 0.29, width * 0.19);\n const glide = interpolate(t, [70, 104], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const leftX = width * 0.255;\n const push =\n interpolate(t, [20, 66], [0, 1], { ...CLAMP, easing: EASE_IO }) *\n (1 - glide);\n const focus = polar(total * 3, r * 0.62);\n const pushS = 1 + push * 0.32;\n const cx =\n interpolate(glide, [0, 1], [width / 2, leftX]) - focus.x * (pushS - 1);\n const cy = height / 2 - focus.y * (pushS - 1);\n const dialScale =\n interpolate(t, [0, 30], [1.04, 1], { ...CLAMP, easing: EASE_OUT }) *\n pushS *\n interpolate(t, [104, 170], [1, 1.015], CLAMP);\n\n const secs = total * sweep * 60;\n const mm = Math.floor(secs / 60);\n const ss = Math.floor(secs % 60);\n const readout = `${String(mm).padStart(2, \"0\")}:${String(ss).padStart(2, \"0\")}`;\n const readIn = interpolate(t, [18, 34], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const readLit = interpolate(t, [66, 72], [0, 1], CLAMP);\n\n const headSize = Math.min(height * 0.098, width * 0.055);\n const headLeft = cx + r * 1.36;\n const headW = width - (leftX + r * 1.36) - width * 0.03;\n const headDrift = interpolate(t, [76, 170], [0, -6 * u], CLAMP);\n\n return (\n <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n <AbsoluteFill\n style={{\n background: [\n `radial-gradient(ellipse 34% 52% at ${(cx / width) * 100 + 4}% ${30 - 4 * glide}%, ${p.glow[1]}, transparent 70%)`,\n `radial-gradient(ellipse 60% 80% at ${(cx / width) * 100}% 62%, ${p.glow[0]}, transparent 72%)`,\n `radial-gradient(ellipse 55% 75% at ${(cx / width) * 100}% 48%, ${p.stage}, transparent 72%)`,\n ].join(\", \"),\n }}\n />\n <div\n style={{\n position: \"absolute\",\n left: cx,\n top: cy,\n width: 0,\n height: 0,\n transform: `scale(${dialScale})`,\n }}\n >\n <Dial\n t={t}\n r={r}\n value={value}\n minutes={total}\n accent={accent}\n p={p}\n u={u}\n />\n <div\n style={{\n position: \"absolute\",\n left: -r,\n width: r * 2,\n top: r * 0.34,\n textAlign: \"center\",\n fontFamily: mono,\n fontWeight: 400,\n fontSize: r * 0.1,\n letterSpacing: \"0.02em\",\n fontVariantNumeric: \"tabular-nums\",\n color: readLit > 0.5 ? accent : p.muted,\n opacity: readIn,\n }}\n >\n {readout}\n </div>\n </div>\n <div\n style={{\n position: \"absolute\",\n left: headLeft,\n width: headW,\n top: cy,\n transform: `translateY(calc(-50% + ${headDrift}px))`,\n }}\n >\n <Headline\n t={t}\n title={\n title ??\n `From idea to video\\nin ${minutes} ${minutes === 1 ? \"minute\" : \"minutes\"}`\n }\n minutes={minutes}\n size={headSize}\n p={p}\n />\n </div>\n <Grain opacity={p.grain} />\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/clock-sweep.tsx"
}
],
"type": "registry:component"
}