Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"type": "remotion-element",
"version": 1,
"element": {
"assets": [],
"dependencies": [
{
"name": "@remotion/google-fonts",
"version": null
}
],
"dimensions": null,
"displayName": "Scan Reveal",
"initialProps": null,
"slug": "scan-reveal",
"sourceCode": "import { loadFont } from \"@remotion/google-fonts/SpaceGrotesk\";\nimport React, { forwardRef, useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { AbsoluteFill, Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst { fontFamily: sans } = loadFont(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\nconst display = sans;\n\n// gradients.sh \"silk\" palette (bg #030308): #3b3fd8, #f3d6c0, #8a7bff.\nconst SILK = [\"#3b3fd8\", \"#f3d6c0\", \"#8a7bff\"] as const;\n\n// Space Grotesk 500 advances (1/1000 em), ASCII 32–126, measured with HarfBuzz.\nconst SPACE_500 = [\n 255, 276, 470, 632, 609, 765, 598, 273, 389, 383, 530, 620, 273, 443, 276,\n 379, 645, 435, 598, 606, 630, 599, 615, 559, 611, 615, 276, 276, 620, 620,\n 620, 579, 1020, 632, 663, 643, 665, 559, 537, 661, 656, 254, 602, 618, 544,\n 874, 667, 673, 603, 673, 632, 609, 588, 669, 619, 887, 641, 617, 577, 347,\n 379, 347, 620, 620, 288, 577, 641, 592, 641, 584, 439, 640, 615, 256, 258,\n 551, 256, 857, 615, 615, 641, 641, 387, 525, 458, 614, 544, 792, 593, 614,\n 519, 449, 249, 449, 620,\n];\nconst TRACK = -0.04;\nconst SUB_TRACK = -0.01;\n\ninterface ScanRevealProps {\n title?: string;\n subtitle?: string;\n accent?: string;\n theme?: \"dark\" | \"light\";\n speed?: number;\n}\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst CAP = 0.7;\nconst XH = 0.4925;\nconst DESC = 0.2;\nconst BASE = 0.846;\n\nconst GUIDE_AT = -10;\nconst GUIDE_END = 14;\nconst LINE_IN_AT = -2;\nconst LINE_IN_END = 12;\nconst DOWN_AT = 10;\nconst DOWN_END = 66;\nconst UP_AT = 71;\nconst UP_END = 89;\nconst PARK_AT = 89;\nconst PARK_END = 107;\n\nconst SCAN = Easing.bezier(0.65, 0, 0.35, 1);\nconst RISE = Easing.bezier(0.45, 0, 0.12, 1);\nconst OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst PARK = Easing.bezier(0.65, 0, 0.35, 1);\n\nconst STAGES = {\n dark: {\n bg: \"#0A0A0B\",\n fg: \"#F3F2EF\",\n muted: \"#A3A29C\",\n guide: \"rgba(243,242,239,0.15)\",\n dot: \"rgba(243,242,239,0.34)\",\n },\n light: {\n bg: \"#F5F4F0\",\n fg: \"#121214\",\n muted: \"#5C5A55\",\n guide: \"rgba(18,18,20,0.14)\",\n dot: \"rgba(18,18,20,0.3)\",\n },\n};\n\nfunction widthEm(text: string, track: number) {\n let w = 0;\n for (const ch of text) {\n const code = ch.charCodeAt(0);\n const adv = code >= 32 && code < 127 ? SPACE_500[code - 32] : 600;\n w += adv / 1000 + track;\n }\n return Math.max(w, 0.5);\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={11}\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 solid = (from: number, to: number) =>\n `linear-gradient(to bottom, #000 ${from}px, transparent ${to}px)`;\nconst slab = (a: number, b: number) =>\n `linear-gradient(to bottom, transparent ${a - 0.5}px, #000 ${a}px, #000 ${b - 0.5}px, transparent ${b}px)`;\nconst solidBelow = (from: number, to: number) =>\n `linear-gradient(to bottom, transparent ${from}px, #000 ${to}px)`;\n\nfunction maskStyle(image: string): React.CSSProperties {\n return {\n WebkitMaskImage: image,\n maskImage: image,\n WebkitMaskRepeat: \"no-repeat\",\n maskRepeat: \"no-repeat\",\n WebkitMaskSize: \"100% 100%\",\n maskSize: \"100% 100%\",\n };\n}\n\nfunction Row({\n baseline,\n size,\n children,\n}: {\n baseline: number;\n size: number;\n children: React.ReactNode;\n}) {\n return (\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: baseline - BASE * size,\n display: \"flex\",\n justifyContent: \"center\",\n }}\n >\n {children}\n </div>\n );\n}\n\nfunction ScanRevealBase({\n title = \"Built frame by frame\",\n subtitle = \"Launch films from components you own.\",\n accent = \"#3B5BFD\",\n theme = \"dark\",\n speed = 1,\n}: ScanRevealProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H } = useVideoConfig();\n const u = H / 720;\n const c = STAGES[theme];\n\n const s = Math.min(150 * u, (0.84 * W) / widthEm(title, TRACK));\n const ss = Math.min(\n 30 * u,\n (0.8 * W) / (widthEm(subtitle, SUB_TRACK) * 0.97),\n );\n const capGap = CAP * s;\n const under = 0.36 * s;\n const subGap = 38 * u + CAP * ss;\n const block = capGap + under + subGap;\n const capTop = H / 2 - block / 2 - 0.02 * H;\n const yB = capTop + capGap;\n const yU = yB + under;\n const yS = yU + subGap;\n\n const lw = Math.max(1.5, 2 * u);\n const fall = 11 * u;\n const G = 0.88 * W;\n const y0 = capTop - 0.1 * H;\n const y1 = yS + 0.11 * H;\n\n const down = SCAN(interpolate(t, [DOWN_AT, DOWN_END], [0, 1], CLAMP));\n const up = RISE(interpolate(t, [UP_AT, UP_END], [0, 1], CLAMP));\n const goingUp = t >= UP_AT;\n const downY = y0 + (y1 - y0) * down;\n const upY = y1 + (yU - y1) * up;\n const lineY = goingUp ? upY : downY;\n\n const lineIn = OUT(interpolate(t, [LINE_IN_AT, LINE_IN_END], [0, 1], CLAMP));\n const park = PARK(interpolate(t, [PARK_AT, PARK_END], [0, 1], CLAMP));\n const guideFade = 1 - park;\n const guideIn = (i: number) =>\n OUT(interpolate(t, [GUIDE_AT + i * 2, GUIDE_END + i * 2], [0, 1], CLAMP));\n\n const band = 0.42 * s;\n const soft = 0.22 * s;\n const subBand = 1.1 * ss;\n const subSoft = 0.6 * ss;\n const pitch = Math.max(3.5 * u, s / 24);\n const dotR = pitch * 0.3;\n const dots = (color: string, p: number, r: number): React.CSSProperties => ({\n color: \"transparent\",\n backgroundImage: `radial-gradient(circle at 50% 50%, ${color} ${r}px, transparent ${r + 0.7}px)`,\n backgroundSize: `${p}px ${p}px`,\n WebkitBackgroundClip: \"text\",\n backgroundClip: \"text\",\n });\n\n const titleType: React.CSSProperties = {\n fontFamily: display,\n fontWeight: 500,\n fontSize: s,\n lineHeight: 1,\n letterSpacing: `${TRACK}em`,\n whiteSpace: \"nowrap\",\n paddingLeft: `${-TRACK}em`,\n };\n const subType: React.CSSProperties = {\n fontFamily: sans,\n fontWeight: 400,\n fontSize: ss,\n lineHeight: 1,\n letterSpacing: `${SUB_TRACK}em`,\n whiteSpace: \"nowrap\",\n };\n\n const guides = [\n { y: capTop, strong: false },\n { y: yB - XH * s, strong: false },\n { y: yB, strong: true },\n { y: yB + DESC * s, strong: false },\n { y: yU, strong: true },\n { y: yS - CAP * ss, strong: false },\n { y: yS, strong: true },\n ];\n\n const gridStep = (yB - capTop) / 2;\n const gridTop = capTop - gridStep / 2;\n const gridH = yU - capTop + gridStep;\n const gridCols = Math.floor(G / gridStep);\n const gridW = gridCols * gridStep;\n const subH = CAP * ss;\n\n // Silk sheen across the developed title; the bright band slides a few\n // percent over the shot, so the hold never sits perfectly still.\n const sheen = interpolate(t, [DOWN_AT, PARK_END + 40], [0, 1], CLAMP);\n const silk =\n theme === \"dark\"\n ? `linear-gradient(102deg, ${SILK[1]} ${-6 + 10 * sheen}%, #d9c3e6 ${26 + 10 * sheen}%, ${SILK[2]} ${62 + 8 * sheen}%, #6f6ef2 100%)`\n : `linear-gradient(102deg, ${SILK[0]} ${-4 + 10 * sheen}%, ${SILK[2]} ${48 + 10 * sheen}%, #2c2fa8 100%)`;\n\n const lineWidth = `calc(${park} * 100% + ${(1 - park) * G * lineIn}px)`;\n const fallOpacity = (1 - park) * lineIn;\n\n return (\n <AbsoluteFill style={{ background: c.bg, overflow: \"hidden\" }}>\n <AbsoluteFill style={{ opacity: guideFade }}>\n {guides.map((g, i) => {\n const p = guideIn(i);\n return (\n <div\n key={g.y}\n style={{\n position: \"absolute\",\n left: (W - G) / 2,\n top: g.y - 0.5,\n width: G * p,\n height: 1,\n background: c.guide,\n opacity: g.strong ? 1 : 0.7,\n }}\n />\n );\n })}\n {guides.map((g, i) => (\n <div\n key={`tick-${g.y}`}\n style={{\n position: \"absolute\",\n left: (W - G) / 2 - 0.5,\n top: g.y - 4 * u,\n width: 1,\n height: 8 * u,\n background: c.dot,\n opacity: guideIn(i),\n }}\n />\n ))}\n <AbsoluteFill style={maskStyle(solidBelow(downY, downY + 1))}>\n <div\n style={{\n position: \"absolute\",\n left: (W - gridW) / 2 - gridStep / 2,\n top: gridTop,\n width: gridW + gridStep,\n height: gridH,\n opacity: guideIn(2),\n backgroundImage: `radial-gradient(circle at 50% 50%, ${c.dot} ${1.5 * u}px, transparent ${1.5 * u + 0.7}px)`,\n backgroundSize: `${gridStep}px ${gridStep}px`,\n }}\n />\n </AbsoluteFill>\n <AbsoluteFill style={maskStyle(solid(upY - 1, upY))}>\n <div\n style={{\n position: \"absolute\",\n left: (W - gridW) / 2 - gridStep / 2,\n top: yS - subH * 1.5,\n width: gridW + gridStep,\n height: subH * 2,\n opacity: guideIn(4),\n backgroundImage: `radial-gradient(circle at 50% 50%, ${c.dot} ${1.5 * u}px, transparent ${1.5 * u + 0.7}px)`,\n backgroundSize: `${gridStep}px ${subH}px`,\n }}\n />\n </AbsoluteFill>\n </AbsoluteFill>\n\n <AbsoluteFill style={maskStyle(slab(downY - band - soft - 2, downY))}>\n <Row baseline={yB} size={s}>\n <div style={{ ...titleType, ...dots(c.fg, pitch, dotR) }}>\n {title}\n </div>\n </Row>\n </AbsoluteFill>\n <AbsoluteFill style={maskStyle(solid(downY - band - soft, downY - band))}>\n <Row baseline={yB} size={s}>\n <div\n style={{\n ...titleType,\n color: \"transparent\",\n backgroundImage: silk,\n WebkitBackgroundClip: \"text\",\n backgroundClip: \"text\",\n }}\n >\n {title}\n </div>\n </Row>\n </AbsoluteFill>\n\n <AbsoluteFill style={maskStyle(slab(upY, upY + subBand + subSoft + 2))}>\n <Row baseline={yS} size={ss}>\n <div\n style={{\n ...subType,\n ...dots(c.muted, Math.max(2.4 * u, ss / 11), ss / 36),\n }}\n >\n {subtitle}\n </div>\n </Row>\n </AbsoluteFill>\n <AbsoluteFill\n style={maskStyle(solidBelow(upY + subBand, upY + subBand + subSoft))}\n >\n <Row baseline={yS} size={ss}>\n <div style={{ ...subType, color: c.muted }}>{subtitle}</div>\n </Row>\n </AbsoluteFill>\n\n <Row baseline={yB} size={s}>\n <div style={{ ...titleType, position: \"relative\", height: 0 }}>\n <div style={{ visibility: \"hidden\", height: 0, overflow: \"hidden\" }}>\n {title}\n </div>\n <div\n style={{\n position: \"absolute\",\n left: \"50%\",\n width: lineWidth,\n transform: \"translateX(-50%)\",\n top: lineY - (yB - BASE * s) - lw / 2,\n height: lw,\n background: accent,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: goingUp ? lw : -fall,\n height: fall,\n opacity: 0.32 * fallOpacity,\n background: `linear-gradient(${goingUp ? \"to bottom\" : \"to top\"}, ${accent}, transparent)`,\n }}\n />\n </div>\n </div>\n </Row>\n\n <Grain opacity={theme === \"light\" ? 0.04 : 0.05} />\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n theme: {\n type: \"enum\",\n default: \"dark\",\n variants: {\n dark: {},\n light: {},\n },\n description: \"Theme\",\n },\n accent: {\n type: \"color\",\n default: \"#3B5BFD\",\n description: \"Accent\",\n },\n title: {\n type: \"text-content\",\n default: \"Built frame by frame\",\n description: \"Title\",\n },\n subtitle: {\n type: \"text-content\",\n default: \"Launch films from components you own.\",\n description: \"Subtitle\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"theme\",\"accent\",\"title\",\"subtitle\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n theme: \"dark\",\n accent: \"#3B5BFD\",\n title: \"Built frame by frame\",\n subtitle: \"Launch films from components you own.\",\n speed: 1,\n};\n\ntype ScanRevealElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ScanRevealBase>;\n\nconst ScanRevealInner = forwardRef<\n HTMLDivElement,\n ScanRevealElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ScanReveal>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ScanRevealBase\n {...(componentProps as unknown as ComponentProps<typeof ScanRevealBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ScanReveal = Interactive.withSchema({\n Component: ScanRevealInner,\n componentName: \"<ScanReveal>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 107,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 107
}