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": "fluted-glass",
"title": "Fluted Glass",
"description": "Fluted glass refracts a gradient orb and its headline, clearing as it comes into focus.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"files": [
{
"path": "registry/remocn/fluted-glass/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadDisplay } from \"@remotion/google-fonts/Fraunces\";\nimport { useId } from \"react\";\nimport {\n AbsoluteFill,\n Easing,\n interpolate,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: display } = loadDisplay(\"normal\", {\n weights: [\"400\"],\n subsets: [\"latin\"],\n});\n\nexport interface FlutedGlassProps {\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 CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\n// gradients.sh \"fluted\" palette: bg #050507, [#1d2a8f, #2f7bff, #ff7a3d, #ffe2c4].\n// It fills the disc only, so the flutes have colour to refract.\nconst FLUTED = [\"#1d2a8f\", \"#2f7bff\", \"#ff7a3d\", \"#ffe2c4\"] as const;\n\nconst THEMES = {\n dark: {\n bg: \"#050507\",\n fg: \"#F3F2EF\",\n tint: \"rgba(255,255,255,0.025)\",\n ridge: \"rgba(255,255,255,0.13)\",\n spec: \"rgba(255,255,255,0.2)\",\n valley: \"rgba(0,0,0,0.42)\",\n sheen: \"rgba(255,255,255,0.05)\",\n edge: \"rgba(255,255,255,0.55)\",\n contact: \"rgba(0,0,0,0.5)\",\n grain: 0.06,\n },\n light: {\n bg: \"#F5F4F0\",\n fg: \"#121214\",\n tint: \"rgba(255,255,255,0.22)\",\n ridge: \"rgba(255,255,255,0.75)\",\n spec: \"rgba(255,255,255,0.9)\",\n valley: \"rgba(70,62,48,0.2)\",\n sheen: \"rgba(255,255,255,0.3)\",\n edge: \"rgba(255,255,255,1)\",\n contact: \"rgba(70,62,48,0.2)\",\n grain: 0.045,\n },\n} as const;\n\ntype Palette = (typeof THEMES)[keyof typeof THEMES];\n\n// Rough Fraunces 400 advances, only used to pick a font size that fits;\n// the row itself is laid out by flexbox so the estimate never shifts it.\nfunction textWidth(s: string, size: number) {\n let w = 0;\n for (const ch of s) {\n if (ch === \" \") w += 0.25;\n else if (\"iljtfr,.;:!'|\".includes(ch)) w += 0.32;\n else if (\"mwMW\".includes(ch)) w += 0.86;\n else if (ch >= \"A\" && ch <= \"Z\") w += 0.68;\n else if (ch >= \"0\" && ch <= \"9\") w += 0.6;\n else w += 0.54;\n w -= 0.025;\n }\n return w * size;\n}\n\nfunction hash(n: number) {\n const x = Math.sin(n * 127.1 + 311.7) * 43758.5453;\n return x - Math.floor(x);\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 }}\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\ninterface Layout {\n u: number;\n size: number;\n disc: number;\n gap: number;\n}\n\nfunction useLayout(title: string): Layout {\n const { width, height } = useVideoConfig();\n const u = height / 720;\n const disc = height * 0.42;\n const gap = 60 * u;\n const room = width * 0.84 - disc - gap;\n const size = Math.min(170 * u, room / Math.max(textWidth(title, 1), 0.1));\n return { u, size, disc, gap };\n}\n\nfunction Backdrop({\n t,\n title,\n accent,\n p,\n L,\n}: {\n t: number;\n title: string;\n accent: string;\n p: Palette;\n L: Layout;\n}) {\n const { width, height } = useVideoConfig();\n const drift = EASE_IO(interpolate(t, [0, 62], [0, 1], CLAMP));\n const ox = -width * 0.34 * (1 - drift);\n const oy = Math.sin(drift * Math.PI) * -46 * L.u;\n const angle = 168 + 10 * Math.sin(t / 44);\n return (\n <div\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n width,\n height,\n background: p.bg,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n style={{\n position: \"relative\",\n flex: \"none\",\n width: L.disc,\n height: L.disc,\n marginRight: L.gap,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n transform: `translate(${ox}px, ${oy}px)`,\n borderRadius: \"50%\",\n background: `linear-gradient(${angle}deg, ${FLUTED[3]} 2%, ${FLUTED[2]} 30%, color-mix(in oklab, ${FLUTED[2]} 35%, ${FLUTED[1]}) 50%, ${FLUTED[1]} 70%, ${FLUTED[0]} 100%)`,\n boxShadow: `inset 0 0 0 ${1 * L.u}px color-mix(in oklab, ${accent} 30%, transparent)`,\n }}\n />\n </div>\n <div\n style={{\n flex: \"none\",\n fontFamily: display,\n fontWeight: 400,\n fontSize: L.size,\n letterSpacing: \"-0.035em\",\n lineHeight: 1,\n color: p.fg,\n whiteSpace: \"pre\",\n paddingBottom: L.size * 0.06,\n }}\n >\n {title}\n </div>\n </div>\n );\n}\n\nexport function FlutedGlass({\n title = \"In focus.\",\n accent = \"#3B5BFD\",\n theme = \"dark\",\n speed = 1,\n}: FlutedGlassProps) {\n const t = useCurrentFrame() * speed;\n const { width, height } = useVideoConfig();\n const p = THEMES[theme];\n const L = useLayout(title);\n const { u } = L;\n\n const fw = 26 * u;\n const lens = 0.3;\n const travel = width + 90 * u;\n const slideAt = (f: number) =>\n EASE_IO(interpolate(f, [66, 112], [0, 1], CLAMP)) * travel;\n const gx = slideAt(t);\n const vel = (gx - slideAt(t - 1)) / u;\n const smear = interpolate(vel, [8, 40], [0, 5], CLAMP) * u;\n\n const flutes: number[] = [];\n for (let i = 0; gx + i * fw < width; i++) flutes.push(i);\n\n const scene = { t, title, accent, p, L };\n\n return (\n <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n <Backdrop {...scene} />\n {gx < width ? (\n <div\n style={{\n position: \"absolute\",\n left: gx,\n top: 0,\n width: width + fw,\n height,\n boxShadow: `${-18 * u}px 0 ${40 * u}px ${-6 * u}px ${p.contact}`,\n }}\n />\n ) : null}\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n filter: `blur(${1.4 * u + smear}px)`,\n }}\n >\n {flutes.map((i) => {\n const x0 = gx + i * fw;\n const wobble = (hash(i) - 0.5) * 3 * u;\n return (\n <div\n key={i}\n style={{\n position: \"absolute\",\n left: x0,\n top: 0,\n width: fw + 0.6,\n height,\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: -x0,\n top: 0,\n width,\n height,\n transform: `scaleX(${-lens})`,\n transformOrigin: `${x0 + fw / 2 + wobble}px 50%`,\n }}\n >\n <Backdrop {...scene} />\n </div>\n </div>\n );\n })}\n </div>\n {gx < width ? (\n <div\n style={{\n position: \"absolute\",\n left: gx,\n top: 0,\n right: 0,\n bottom: 0,\n filter: smear > 0.3 ? `blur(${smear}px)` : undefined,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: p.tint,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n backgroundImage: `linear-gradient(90deg, ${p.ridge} 0, rgba(0,0,0,0) ${fw * 0.1}px, rgba(0,0,0,0) ${fw * 0.2}px, ${p.spec} ${fw * 0.27}px, rgba(0,0,0,0) ${fw * 0.4}px, rgba(0,0,0,0) ${fw * 0.62}px, ${p.valley} ${fw}px)`,\n backgroundSize: `${fw}px 100%`,\n opacity: 0.85,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: `linear-gradient(180deg, ${p.sheen}, rgba(0,0,0,0) 45%, rgba(0,0,0,0) 70%, ${p.sheen})`,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n bottom: 0,\n width: 7 * u,\n background: `linear-gradient(90deg, ${p.edge}, rgba(255,255,255,0.08) 45%, rgba(0,0,0,0) 100%)`,\n opacity: gx > 0 ? 1 : 0,\n }}\n />\n </div>\n ) : null}\n <Grain opacity={p.grain} />\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/fluted-glass.tsx"
}
],
"type": "registry:component"
}