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": "Layered Cutout",
"initialProps": null,
"slug": "layered-cutout",
"sourceCode": "import { loadFont } from \"@remotion/google-fonts/HankenGrotesk\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\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\"],\n subsets: [\"latin\"],\n});\nconst manrope = loadManrope(\"normal\", {\n weights: [\"600\"],\n subsets: [\"latin\"],\n});\n\n/**\n * Beat sheet (30fps, speed 1):\n * 0–72 the cut sheets part in depth while the camera starts its push.\n * 8–140 the camera dollies through the cuts; the innermost sheet, cut\n * from gradients.sh paper (\"smear\" on card stock, \"swirl\" on\n * charcoal), ends up framing the core.\n * 76–120 the remocn logo and the tagline surface on the core sheet.\n * 140–170 hold.\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/** Full logo as on remocn.dev: R mark + \"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\ninterface LayeredCutoutProps {\n /** Small line under the logo. Pass \"\" to hide. */\n tagline?: string;\n /** Replaces the remocn logo on the core sheet. */\n logo?: React.ReactNode;\n /** Number of cut sheets in front of the core (4–6). */\n layers?: number;\n /** Which sheet (0 = front) is cut from gradient paper. Default: the innermost. */\n accentLayer?: number;\n /** Accepted for parity with the other drafts; the gradient paper is the accent here. */\n accent?: string;\n /** Playback multiplier. */\n speed?: number;\n /** Light = warm card stock; dark = charcoal stock. */\n theme?: \"dark\" | \"light\";\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 CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n light: {\n bg: \"#F5F4F0\",\n // front to back, then the core\n papers: [\"#EFECE5\", \"#E5E1D8\", \"#DAD5CA\", \"#CEC8BB\", \"#C3BCAE\", \"#B8B0A1\"],\n core: \"#F6F4EF\",\n fg: \"#141413\",\n muted: \"#6E6C67\",\n shadow: [52, 44, 32] as const,\n shadowA: 0.34,\n lip: \"rgba(255,255,255,0.85)\",\n lipDark: \"rgba(60,50,35,0.25)\",\n light: \"rgba(255,252,245,0.5)\",\n vignette: \"rgba(60,50,35,0.22)\",\n grain: 0.05,\n // gradients.sh \"smear\" (light): #f2552c, #f7b23b, #e889b5, #2f6b3f\n paper: [\"#F7B23B\", \"#F2552C\", \"#E889B5\", \"#2F6B3F\"],\n },\n dark: {\n bg: \"#0A0A0B\",\n papers: [\"#2B2B2F\", \"#252528\", \"#1F1F22\", \"#1A1A1D\", \"#161618\", \"#131315\"],\n core: \"#0F0F11\",\n fg: \"#F3F2EF\",\n muted: \"#8B8A90\",\n shadow: [0, 0, 0] as const,\n shadowA: 0.7,\n lip: \"rgba(255,255,255,0.22)\",\n lipDark: \"rgba(0,0,0,0.4)\",\n light: \"rgba(255,255,255,0.07)\",\n vignette: \"rgba(0,0,0,0.55)\",\n grain: 0.06,\n // gradients.sh \"swirl\": #ffe2c4, #ff9a4d, #d2456b, #3a1f6b\n paper: [\"#FFE2C4\", \"#FF9A4D\", \"#D2456B\", \"#3A1F6B\"],\n },\n} as const;\n\ntype Palette = (typeof THEMES)[keyof typeof THEMES];\n\n/** Seeded hash in [0, 1). */\nfunction hash(n: number) {\n const x = Math.sin(n * 127.1 + 311.7) * 43758.5453;\n return x - Math.floor(x);\n}\n\n/** A soft organic cut: a wobbly superellipse closed with Catmull-Rom curves. */\nfunction holePath(R: number, aspect: number, seed: number, u: number) {\n const n = 56;\n const ph = [hash(seed) * 6.28, hash(seed + 1) * 6.28, hash(seed + 2) * 6.28];\n const amp = [0.014, 0.009, 0.004];\n const pts: [number, number][] = [];\n for (let i = 0; i < n; i++) {\n const a = (i / n) * Math.PI * 2;\n const wob =\n 1 +\n amp[0] * Math.sin(2 * a + ph[0]) +\n amp[1] * Math.sin(3 * a + ph[1]) +\n amp[2] * Math.sin(5 * a + ph[2]);\n // a touch of superellipse so the cut reads as a frame, not a blob\n const c = Math.cos(a);\n const s = Math.sin(a);\n const k = SQUIRCLE;\n const se = (Math.abs(c) ** k + Math.abs(s) ** k) ** (-1 / k);\n pts.push([c * se * R * aspect * wob * u, s * se * R * wob * u]);\n }\n let d = `M${pts[0][0].toFixed(2)},${pts[0][1].toFixed(2)}`;\n for (let i = 0; i < n; i++) {\n const p0 = pts[(i - 1 + n) % n];\n const p1 = pts[i];\n const p2 = pts[(i + 1) % n];\n const p3 = pts[(i + 2) % n];\n const c1 = [p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6];\n const c2 = [p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6];\n d += `C${c1[0].toFixed(2)},${c1[1].toFixed(2)} ${c2[0].toFixed(2)},${c2[1].toFixed(2)} ${p2[0].toFixed(2)},${p2[1].toFixed(2)}`;\n }\n return `${d}Z`;\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={13}\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\n/** Hole radius (u), aspect, centre offset (u) per sheet, front to back. */\nconst CUTS = [\n { R: 300, aspect: 1.62, ox: -6, oy: 4 },\n { R: 250, aspect: 1.58, ox: 5, oy: -3 },\n { R: 208, aspect: 1.54, ox: -4, oy: 4 },\n { R: 172, aspect: 1.5, ox: 3, oy: -2 },\n { R: 142, aspect: 1.46, ox: -2, oy: 2 },\n { R: 118, aspect: 1.42, ox: 1, oy: -1 },\n];\n\nconst D0 = 1000;\nconst SQUIRCLE = 3.4;\n\n/** One sheet of cut paper, drawn in screen space at its current depth. */\nfunction Sheet({\n index,\n scale,\n x,\n y,\n rot,\n color,\n gradient,\n drift,\n sep,\n blur,\n p,\n u,\n paperId,\n}: {\n index: number;\n scale: number;\n x: number;\n y: number;\n rot: number;\n color: string;\n /** Cut from gradient paper instead of `color`. */\n gradient: boolean;\n /** Slow drift of the gradient angle, in degrees. */\n drift: number;\n sep: number;\n blur: number;\n p: Palette;\n u: number;\n paperId: string;\n}) {\n const { width, height } = useVideoConfig();\n const cut = CUTS[index];\n const hole = holePath(cut.R, cut.aspect, index * 7 + 3, u);\n const X = (width / 2 + Math.abs(x) + 80 * u) / scale;\n const Y = (height / 2 + Math.abs(y) + 80 * u) / scale;\n const outer = `M${-X},${-Y}H${X}V${Y}H${-X}Z`;\n const lipId = `${paperId}lip${index}`;\n const fillId = `${paperId}fill${index}`;\n // the gradient runs corner to corner across the cut, slowly turning\n const ga = ((150 + drift) * Math.PI) / 180;\n const gr = cut.R * u * cut.aspect * 1.7;\n // the cast shadow grows as the sheets separate and come closer to camera\n const dy = (2 + 13 * sep) * u * Math.sqrt(scale);\n const sb = (3 + 20 * sep) * u * Math.sqrt(scale);\n const [r, g, b] = p.shadow;\n const filters = [\n `drop-shadow(0 ${dy}px ${sb}px rgba(${r},${g},${b},${p.shadowA}))`,\n `drop-shadow(0 ${dy * 0.25}px ${sb * 0.2}px rgba(${r},${g},${b},${p.shadowA * 0.6}))`,\n ];\n if (blur > 0.2) filters.push(`blur(${blur}px)`);\n return (\n <svg\n width={width}\n height={height}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"visible\",\n filter: filters.join(\" \"),\n }}\n aria-hidden\n >\n <defs>\n <linearGradient\n id={lipId}\n x1=\"0\"\n y1={-cut.R * u}\n x2=\"0\"\n y2={cut.R * u}\n gradientUnits=\"userSpaceOnUse\"\n >\n <stop offset=\"0\" stopColor={p.lipDark} />\n <stop offset=\"0.45\" stopColor=\"rgba(0,0,0,0)\" />\n <stop offset=\"1\" stopColor={p.lip} />\n </linearGradient>\n <linearGradient\n id={fillId}\n gradientUnits=\"userSpaceOnUse\"\n x1={-Math.cos(ga) * gr}\n y1={-Math.sin(ga) * gr}\n x2={Math.cos(ga) * gr}\n y2={Math.sin(ga) * gr}\n >\n <stop offset=\"0.08\" stopColor={p.paper[0]} />\n <stop offset=\"0.42\" stopColor={p.paper[1]} />\n <stop offset=\"0.68\" stopColor={p.paper[2]} />\n <stop offset=\"1\" stopColor={p.paper[3]} />\n </linearGradient>\n </defs>\n <g\n transform={`translate(${width / 2 + x} ${height / 2 + y}) scale(${scale}) rotate(${rot}) translate(${cut.ox * u} ${cut.oy * u})`}\n >\n <path\n d={`${outer} ${hole}`}\n fillRule=\"evenodd\"\n fill={gradient ? `url(#${fillId})` : color}\n filter={`url(#${paperId})`}\n />\n {/* the cut edge: lit lip below, shaded lip above */}\n <path\n d={hole}\n fill=\"none\"\n stroke={`url(#${lipId})`}\n strokeWidth={(1.8 * u) / scale}\n />\n </g>\n </svg>\n );\n}\n\nfunction LayeredCutoutBase({\n tagline = \"Launch films, cut from components.\",\n logo,\n layers = 5,\n accentLayer,\n speed = 1,\n theme = \"light\",\n}: LayeredCutoutProps) {\n const t = useCurrentFrame() * speed;\n const { width, height } = useVideoConfig();\n const u = height / 720;\n const p = THEMES[theme];\n const paperId = `paper${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n const n = Math.max(3, Math.min(6, Math.round(layers)));\n const gradientLayer = accentLayer ?? n - 1;\n\n // sheets part in depth, then the camera dollies through the cuts\n const part = interpolate(t, [0, 72], [0, 1], { ...CLAMP, easing: EASE_IO });\n const gap = 18 + 182 * part;\n const push = interpolate(t, [8, 140], [0, 1], { ...CLAMP, easing: EASE_IO });\n // land with the core at ~1.25x and the last two cuts framing it\n const coreDepth = n * 200;\n const camZ = push * (D0 + coreDepth - D0 / 1.25);\n const camX = interpolate(push, [0, 1], [46 * u, 0]);\n const camY = interpolate(push, [0, 1], [-22 * u, 0]);\n\n const depthOf = (i: number) => D0 + i * gap - camZ;\n const coreDist = depthOf(n);\n const coreScale = D0 / coreDist;\n\n const sheets: React.ReactNode[] = [];\n for (let i = n - 1; i >= 0; i--) {\n const dist = depthOf(i);\n if (dist < 70) continue;\n const s = D0 / dist;\n const cut = CUTS[i];\n // skip sheets whose cut already swallows the whole frame\n const hx = cut.R * cut.aspect * u * s * 0.97;\n const hy = cut.R * u * s * 0.97;\n const cxo = width / 2 + camX * s + Math.abs(cut.ox * u * s);\n const cyo = height / 2 + Math.abs(camY * s) + Math.abs(cut.oy * u * s);\n if ((cxo / hx) ** SQUIRCLE + (cyo / hy) ** SQUIRCLE < 1) continue;\n const blur = Math.max(0, Math.min(7, (s - coreScale) * 1.4)) * u;\n sheets.push(\n <Sheet\n key={i}\n index={i}\n scale={s}\n x={-camX * s}\n y={-camY * s}\n rot={(i % 2 ? 1 : -1) * (0.5 + i * 0.25) * push * 1.4}\n color={p.papers[i]}\n gradient={i === gradientLayer}\n drift={Math.sin(t / 45) * 6}\n sep={part}\n blur={blur}\n p={p}\n u={u}\n paperId={paperId}\n />,\n );\n }\n\n const reveal = interpolate(t, [76, 104], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const tag = interpolate(t, [98, 120], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n\n return (\n <AbsoluteFill style={{ background: p.core, overflow: \"hidden\" }}>\n <svg width={0} height={0} style={{ position: \"absolute\" }} aria-hidden>\n <defs>\n <filter\n id={paperId}\n x=\"0\"\n y=\"0\"\n width=\"1\"\n height=\"1\"\n colorInterpolationFilters=\"sRGB\"\n >\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.7\"\n numOctaves={3}\n seed={21}\n result=\"tooth\"\n />\n <feDiffuseLighting\n in=\"tooth\"\n surfaceScale={1.2}\n lightingColor=\"#FFFFFF\"\n result=\"lit\"\n >\n <feDistantLight azimuth={235} elevation={58} />\n </feDiffuseLighting>\n <feComposite\n in=\"SourceGraphic\"\n in2=\"lit\"\n operator=\"arithmetic\"\n k1={0.16}\n k2={0.88}\n result=\"paper\"\n />\n <feComposite in=\"paper\" in2=\"SourceAlpha\" operator=\"in\" />\n </filter>\n </defs>\n </svg>\n\n {/* the core sheet, lit from above, carrying the name */}\n <AbsoluteFill\n style={{\n background: `radial-gradient(ellipse ${46 * coreScale}% ${52 * coreScale}% at ${50 - (camX / width) * 100 * coreScale}% ${44 - (camY / height) * 100 * coreScale}%, ${p.light}, transparent 100%)`,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n left: width / 2 - camX * coreScale,\n top: height / 2 - camY * coreScale,\n transform: `translate(-50%, -50%) scale(${coreScale})`,\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n gap: 16 * u,\n }}\n >\n <div\n style={{\n opacity: reveal,\n filter: `blur(${(1 - reveal) * 6 * u}px)`,\n transform: `scale(${0.96 + 0.04 * reveal})`,\n }}\n >\n {logo ?? <RemocnLogo fontSize={76 * u} color={p.fg} />}\n </div>\n {tagline ? (\n <div\n style={{\n fontFamily: sans,\n fontWeight: 400,\n fontSize: 20 * u,\n letterSpacing: \"-0.005em\",\n color: p.muted,\n opacity: tag,\n transform: `translateY(${(1 - tag) * 8 * u}px)`,\n whiteSpace: \"nowrap\",\n }}\n >\n {tagline}\n </div>\n ) : null}\n </div>\n\n {sheets}\n\n {/* key light from above-left and a soft vignette over the whole stack */}\n <AbsoluteFill\n style={{\n background: `radial-gradient(ellipse 70% 80% at 32% 18%, ${p.light}, transparent 70%), radial-gradient(ellipse 90% 90% at 50% 50%, transparent 55%, ${p.vignette} 100%)`,\n pointerEvents: \"none\",\n }}\n />\n <Grain opacity={p.grain} />\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n theme: {\n type: \"enum\",\n default: \"light\",\n variants: {\n dark: {},\n light: {},\n },\n description: \"Theme\",\n },\n accent: {\n type: \"color\",\n default: \"#3B5BFD\",\n description: \"Accent\",\n },\n tagline: {\n type: \"text-content\",\n default: \"Launch films, cut from components.\",\n description: \"Tagline\",\n },\n layers: {\n type: \"number\",\n default: 5,\n min: 0,\n max: 15,\n step: 1,\n description: \"Layers\",\n hiddenFromList: false,\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\",\"tagline\",\"layers\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n theme: \"light\",\n accent: \"#3B5BFD\",\n tagline: \"Launch films, cut from components.\",\n layers: 5,\n speed: 1,\n};\n\ntype LayeredCutoutElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof LayeredCutoutBase>;\n\nconst LayeredCutoutInner = forwardRef<\n HTMLDivElement,\n LayeredCutoutElementProps & { 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 ?? \"<LayeredCutout>\"}\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 <LayeredCutoutBase\n {...(componentProps as unknown as ComponentProps<typeof LayeredCutoutBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const LayeredCutout = Interactive.withSchema({\n Component: LayeredCutoutInner,\n componentName: \"<LayeredCutout>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 140,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 140
}