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": "Band Shift",
"initialProps": null,
"slug": "band-shift",
"sourceCode": "import { loadFont as loadDisplay } from \"@remotion/google-fonts/BricolageGrotesque\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport React, { useId } from \"react\";\nimport { AbsoluteFill, Easing, interpolate, useCurrentFrame, useVideoConfig } from \"remotion\";\n\nconst { fontFamily: display } = loadDisplay(\"normal\", {\n weights: [\"500\"],\n subsets: [\"latin\"],\n});\nconst manrope = loadManrope(\"normal\", {\n weights: [\"600\"],\n subsets: [\"latin\"],\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 (0.76em, on the baseline) + \"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\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\ntype Tone = \"dark\" | \"light\";\n\nconst TONES: Record<Tone, { bg: string; fg: string }> = {\n dark: { bg: \"#0A0A0B\", fg: \"#F3F2EF\" },\n light: { bg: \"#F5F4F0\", fg: \"#121214\" },\n};\n\n/* gradients.sh \"mesh\" palette. The colour blocks are windows onto one\n frame-anchored mesh field; the landed scene sits on a quieter version. */\nconst MESH = {\n bg: \"#0a0d24\",\n colors: [\"#ecdcf2\", \"#8796ee\", \"#2e45b7\", \"#0e1645\"],\n at: [\n [16, 20],\n [84, 26],\n [72, 86],\n [22, 80],\n [52, 48],\n [92, 62],\n ],\n};\n\nconst mixA = (c: string, a: number) =>\n `color-mix(in oklab, ${c} ${Math.round(a * 100)}%, transparent)`;\n\n/** Bright mesh, used inside the blocks: lilac and periwinkle blobs over the\n mesh blue, so every block reads as a lit colour. `d` drifts the blobs. */\nfunction meshField(d: number) {\n const [c0, c1, c2, c3] = MESH.colors;\n const cols = [c0, c1, c3, c1, c0, c2];\n const alpha = [0.95, 0.9, 0.7, 0.8, 0.55, 0.9];\n const layers = MESH.at.map(([x, y], i) => {\n const dx = Math.sin(d * Math.PI * 2 + i * 1.7) * 3;\n const dy = Math.cos(d * Math.PI * 2 + i * 2.3) * 3;\n return `radial-gradient(55% 65% at ${(x + dx).toFixed(2)}% ${(y + dy).toFixed(2)}%, ${mixA(cols[i], alpha[i])} 0%, transparent 70%)`;\n });\n return `${layers.join(\", \")}, linear-gradient(${c2}, ${c2})`;\n}\n\n/** Quiet mesh ground for the landed scene: dark centre, colour at the edges. */\nfunction meshGround(tone: Tone, d: number) {\n const [c0, c1, c2] = MESH.colors;\n const s = Math.sin(d * Math.PI * 2) * 3;\n if (tone === \"light\") {\n return [\n `radial-gradient(60% 70% at ${(10 + s).toFixed(2)}% ${(12 - s).toFixed(2)}%, ${mixA(c1, 0.3)} 0%, transparent 70%)`,\n `radial-gradient(60% 70% at ${(90 - s).toFixed(2)}% ${(90 + s).toFixed(2)}%, ${mixA(c0, 1)} 0%, transparent 72%)`,\n ].join(\", \");\n }\n return [\n `radial-gradient(60% 70% at ${(8 + s).toFixed(2)}% ${(6 - s).toFixed(2)}%, ${mixA(c2, 0.6)} 0%, transparent 70%)`,\n `radial-gradient(75% 85% at ${(92 - s).toFixed(2)}% ${(92 + s).toFixed(2)}%, ${mixA(c2, 1)} 0%, transparent 70%)`,\n ].join(\", \");\n}\n\nconst isLogo = (s: string) => /^remocn\\.?$/i.test(s.trim());\n\nfunction Headline({\n text,\n tone,\n accent,\n mark,\n}: {\n text: string;\n tone: Tone;\n accent: string;\n mark: boolean;\n}) {\n const { width: W, height: H } = useVideoConfig();\n const u = H / 720;\n const c = TONES[tone];\n const logo = mark && isLogo(text);\n const dot = mark && !logo && text.endsWith(\".\");\n const body = dot ? text.slice(0, -1) : text;\n const size = Math.min(220 * u, (0.78 * W) / (Math.max(4, text.length) * 0.5));\n return (\n <AbsoluteFill\n style={{\n color: c.fg,\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n {logo ? (\n <RemocnLogo\n fontSize={Math.min(168 * u, (0.56 * W) / 3.9)}\n color={c.fg}\n />\n ) : (\n <div\n style={{\n fontFamily: display,\n fontWeight: 500,\n fontSize: size,\n letterSpacing: \"-0.04em\",\n lineHeight: 1,\n whiteSpace: \"nowrap\",\n paddingBottom: size * 0.08,\n paddingRight: size * 0.04,\n }}\n >\n {body}\n {dot ? <span style={{ color: accent }}>.</span> : null}\n </div>\n )}\n </AbsoluteFill>\n );\n}\n\nfunction Scene({\n content,\n tone,\n accent,\n mark,\n ground,\n}: {\n content: React.ReactNode;\n tone: Tone;\n accent: string;\n mark: boolean;\n ground?: string;\n}) {\n const text = typeof content === \"string\" || typeof content === \"number\";\n return (\n <AbsoluteFill\n style={{ backgroundColor: TONES[tone].bg, backgroundImage: ground }}\n >\n {text ? (\n <Headline\n text={String(content)}\n tone={tone}\n accent={accent}\n mark={mark}\n />\n ) : (\n content\n )}\n </AbsoluteFill>\n );\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\nexport interface BandShiftProps {\n /** Outgoing scene: a short headline string or any React node. */\n from?: React.ReactNode;\n /** Incoming scene. `\"remocn\"` sets the remocn.dev logo. */\n to?: React.ReactNode;\n /** Number of horizontal bands, 5–7. */\n bands?: number;\n /** Override the colour blocks riding between the scenes (default: a mesh gradient field). */\n colors?: string[];\n /** Frames the outgoing scene holds before the shift. */\n delay?: number;\n /** Frames between neighbouring bands. */\n stagger?: number;\n accent?: string;\n /** Playback multiplier. */\n speed?: number;\n /** `dark` lands on a dark scene, `light` on a light one. */\n theme?: Tone;\n}\n\nconst TRAVEL = 22;\nconst EASE_SHIFT = Easing.bezier(0.78, 0, 0.18, 1.045);\nconst BLOCKS = [0.2, 0.3, 0.16, 0.26, 0.34, 0.18, 0.24];\nconst STAGE = \"#0A0A0B\";\n\nexport function BandShift({\n from = \"Before.\",\n to = \"remocn\",\n bands = 6,\n colors,\n delay = 18,\n stagger = 3,\n accent = \"#3B5BFD\",\n speed = 1,\n theme = \"dark\",\n}: BandShiftProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H } = useVideoConfig();\n const u = H / 720;\n const n = Math.round(Math.min(7, Math.max(5, bands)));\n const toneB: Tone = theme;\n const toneA: Tone = theme === \"dark\" ? \"light\" : \"dark\";\n const fills = colors?.length ? colors : null;\n const drift = Math.min(1, t / 150);\n const field = meshField(drift * 0.18);\n const ground = meshGround(toneB, drift * 0.12);\n const bandH = H / n;\n const lastEnd = delay + (n - 1) * stagger + TRAVEL;\n\n return (\n <AbsoluteFill style={{ background: STAGE, overflow: \"hidden\" }}>\n {Array.from({ length: n }, (_, i) => {\n const start = delay + i * stagger;\n const p = interpolate(t, [start, start + TRAVEL], [0, 1], CLAMP);\n const e = EASE_SHIFT(p);\n const d = i % 2 === 0 ? 1 : -1;\n const S = BLOCKS[i % BLOCKS.length] * W;\n const offset = d * e * (W + S);\n const xA = offset;\n const xS = d > 0 ? offset - S : offset + W;\n const xB = d > 0 ? offset - S - W : offset + W + S;\n const moving = t > start && t < lastEnd;\n const gap = moving\n ? 3 * u * Math.sin(Math.PI * Math.min(1, p * 1.15))\n : 0;\n const top = i * bandH;\n const y0 = top + (i > 0 ? gap / 2 : 0);\n const y1 = top + bandH - (i < n - 1 ? gap / 2 : 0);\n const idle = p <= 0;\n const landed = p >= 1;\n const fill = fills ? fills[i % fills.length] : null;\n const inView = (x: number, w: number) => x < W && x + w > 0;\n return (\n <div\n key={`band-${top}`}\n style={{\n position: \"absolute\",\n left: 0,\n top: y0,\n width: W,\n height: y1 - y0,\n overflow: \"hidden\",\n background: landed || !idle ? TONES[toneB].bg : TONES[toneA].bg,\n }}\n >\n {landed || !inView(xA, W) ? null : (\n <div\n style={{\n position: \"absolute\",\n left: xA,\n top: -y0,\n width: W,\n height: H,\n }}\n >\n <Scene\n content={from}\n tone={toneA}\n accent={accent}\n mark={false}\n />\n </div>\n )}\n {idle || landed || !inView(xS, S) ? null : (\n <div\n style={{\n position: \"absolute\",\n left: xS,\n top: 0,\n width: S,\n height: \"100%\",\n ...(fill\n ? { background: fill }\n : {\n backgroundImage: field,\n backgroundSize: `${W}px ${H}px`,\n backgroundPosition: `${(-xS).toFixed(2)}px ${(-y0).toFixed(2)}px`,\n }),\n }}\n />\n )}\n {idle || !inView(xB, W) ? null : (\n <div\n style={{\n position: \"absolute\",\n left: landed ? 0 : xB,\n top: -y0,\n width: W,\n height: H,\n }}\n >\n <Scene\n content={to}\n tone={toneB}\n accent={accent}\n mark\n ground={ground}\n />\n </div>\n )}\n </div>\n );\n })}\n <Grain opacity={theme === \"light\" ? 0.035 : 0.05} />\n </AbsoluteFill>\n );\n}",
"durationInFrames": 55,
"installationMode": "wrapped"
},
"durationInFrames": 55
}