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": "Line Cascade",
"initialProps": null,
"slug": "line-cascade",
"sourceCode": "import { loadFont } from \"@remotion/google-fonts/HankenGrotesk\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport { forwardRef, useId, useImperativeHandle, useMemo, 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 manrope = loadManrope(\"normal\", { weights: [\"600\"], subsets: [\"latin\"] });\n\n// gradients.sh \"fluted\" palette: the landed lines are the flutes, and the\n// pile fills from deep blue at the floor to warm cream at the top.\nconst FLUTED = [\"#1d2a8f\", \"#2f7bff\", \"#ff7a3d\", \"#ffe2c4\"] as const;\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/** remocn.dev logo, inline in running text: R mark on the baseline + \"emocn\". */\nfunction RemocnLogo({ color }: { color: string }) {\n return (\n <span\n style={{\n display: \"inline-flex\",\n alignItems: \"baseline\",\n color,\n fontFamily: manrope.fontFamily,\n fontWeight: 600,\n letterSpacing: \"-0.025em\",\n }}\n >\n <svg\n viewBox=\"0 0 124.06 134.26\"\n style={{ height: \"0.76em\", width: \"auto\", alignSelf: \"baseline\" }}\n aria-hidden\n >\n <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n </svg>\n <span style={{ marginLeft: \"0.04em\" }}>emocn</span>\n </span>\n );\n}\n\ninterface LineCascadeProps {\n value?: string;\n caption?: string;\n accent?: string;\n speed?: number;\n theme?: \"dark\" | \"light\";\n}\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\n\nconst FLOOR_AT = 2;\nconst FLOOR_END = 20;\nconst RAIN_AT = 10;\nconst RAIN_SPAN = 78;\nconst SNAP_AT = 102;\nconst SNAP_END = 111;\nconst CAPTION_AT = 108;\n\nconst THEMES = {\n dark: {\n bg: \"#0A0A0B\",\n fg: \"#F3F2EF\",\n muted: \"#8B8A90\",\n rain: 0.5,\n pile: 0.88,\n floor: \"rgba(255,255,255,0.16)\",\n grain: 0.055,\n },\n light: {\n bg: \"#F5F4F0\",\n fg: \"#121214\",\n muted: \"#6E6C67\",\n rain: 0.42,\n pile: 0.86,\n floor: \"rgba(18,18,20,0.16)\",\n grain: 0.04,\n },\n} as const;\n\ntype Pt = [number, number];\ntype Glyph = { advance: number; strokes: Pt[][] };\ntype Seg = [number, number, number, number];\n\nconst STROKE = 0.165;\nconst R = STROKE / 2;\nconst DW = 0.64;\nconst TRACK = 0.1;\nconst CX = DW / 2;\nconst X0 = R;\nconst X1 = DW - R;\nconst Y0 = R;\nconst Y1 = 1 - R;\n\nfunction arc(\n cx: number,\n cy: number,\n rx: number,\n ry: number,\n a0: number,\n a1: number,\n n = 40,\n): Pt[] {\n const pts: Pt[] = [];\n for (let i = 0; i <= n; i++) {\n const a = ((a0 + ((a1 - a0) * i) / n) * Math.PI) / 180;\n pts.push([cx + rx * Math.cos(a), cy + ry * Math.sin(a)]);\n }\n return pts;\n}\n\nconst JUNCTION = 0.46;\nconst TOP_BOWL = { cy: (Y0 + JUNCTION) / 2, ry: (JUNCTION - Y0) / 2, rx: 0.2 };\nconst LOW_BOWL = {\n cy: (JUNCTION + Y1) / 2,\n ry: (Y1 - JUNCTION) / 2,\n rx: CX - R,\n};\nconst BOWL = { cy: 0.655, ry: Y1 - 0.655, rx: CX - R };\n\nconst GLYPHS: Record<string, Glyph> = {\n \"0\": { advance: DW, strokes: [arc(CX, 0.5, CX - R, 0.5 - R, 0, 360, 64)] },\n \"1\": {\n advance: DW,\n strokes: [\n [\n [0.13, 0.25],\n [0.4, Y0],\n [0.4, Y1],\n ],\n ],\n },\n \"2\": {\n advance: DW,\n strokes: [\n [...arc(CX, 0.3, CX - R, 0.3 - R, 182, 395), [X0, Y1], [X1 + 0.01, Y1]],\n ],\n },\n \"3\": {\n advance: DW,\n strokes: [\n arc(CX - 0.01, TOP_BOWL.cy, TOP_BOWL.rx, TOP_BOWL.ry, 200, 450),\n arc(CX, LOW_BOWL.cy, LOW_BOWL.rx, LOW_BOWL.ry, 270, 520),\n ],\n },\n \"4\": {\n advance: DW,\n strokes: [\n [\n [0.49, Y1],\n [0.49, Y0],\n [X0, 0.71],\n [X1 + 0.03, 0.71],\n ],\n ],\n },\n \"5\": {\n advance: DW,\n strokes: [\n [\n [X1, Y0],\n [0.15, Y0],\n [0.12, 0.5],\n ],\n arc(CX, BOWL.cy, BOWL.rx, BOWL.ry, 208, 512),\n ],\n },\n \"6\": {\n advance: DW,\n strokes: [\n arc(CX, BOWL.cy, BOWL.rx, BOWL.ry, 0, 360, 56),\n [\n [0.48, Y0],\n [0.13, 0.6],\n ],\n ],\n },\n \"7\": {\n advance: DW,\n strokes: [\n [\n [X0, Y0],\n [X1, Y0],\n [0.23, Y1],\n ],\n ],\n },\n \"8\": {\n advance: DW,\n strokes: [\n arc(CX, TOP_BOWL.cy, TOP_BOWL.rx, TOP_BOWL.ry, 0, 360, 48),\n arc(CX, LOW_BOWL.cy, LOW_BOWL.rx, LOW_BOWL.ry, 0, 360, 48),\n ],\n },\n \"9\": {\n advance: DW,\n strokes: [\n arc(CX, 1 - BOWL.cy, BOWL.rx, BOWL.ry, 0, 360, 56),\n [\n [0.5, 0.4],\n [0.15, Y1],\n ],\n ],\n },\n \".\": {\n advance: 0.27,\n strokes: [\n [\n [0.13, Y1],\n [0.13, Y1],\n ],\n ],\n },\n \"+\": {\n advance: DW,\n strokes: [\n [\n [0.07, 0.56],\n [0.57, 0.56],\n ],\n [\n [CX, 0.31],\n [CX, 0.81],\n ],\n ],\n },\n \"%\": {\n advance: 0.88,\n strokes: [\n arc(0.2, 0.24, 0.1, 0.13, 0, 360, 28),\n arc(0.68, 0.76, 0.1, 0.13, 0, 360, 28),\n [\n [0.7, Y0],\n [0.18, Y1],\n ],\n ],\n },\n k: {\n advance: 0.6,\n strokes: [\n [\n [X0, Y0],\n [X0, Y1],\n ],\n [\n [0.5, 0.4],\n [X0, 0.74],\n ],\n [\n [0.24, 0.6],\n [0.5, Y1],\n ],\n ],\n },\n \" \": { advance: 0.3, strokes: [] },\n};\nGLYPHS.K = GLYPHS.k;\n\nfunction layoutGlyphs(value: string) {\n const strokes: Pt[][] = [];\n const segs: Seg[] = [];\n let x = 0;\n const chars = Array.from(value);\n chars.forEach((ch, i) => {\n const g = GLYPHS[ch] ?? { advance: 0.4, strokes: [] };\n for (const s of g.strokes) {\n const moved = s.map(([px, py]) => [px + x, py] as Pt);\n strokes.push(moved);\n for (let k = 0; k < Math.max(1, moved.length - 1); k++) {\n const a = moved[k];\n const b = moved[Math.min(k + 1, moved.length - 1)];\n segs.push([a[0], a[1], b[0], b[1]]);\n }\n }\n x += g.advance + (i < chars.length - 1 ? TRACK : 0);\n });\n return { strokes, segs, width: x };\n}\n\nfunction segDist(px: number, py: number, s: Seg) {\n const [ax, ay, bx, by] = s;\n const dx = bx - ax;\n const dy = by - ay;\n const l2 = dx * dx + dy * dy;\n const t =\n l2 === 0\n ? 0\n : Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / l2));\n const qx = ax + dx * t - px;\n const qy = ay + dy * t - py;\n return Math.sqrt(qx * qx + qy * qy);\n}\n\nfunction hash(n: number) {\n const s = Math.sin(n * 127.1 + 311.7) * 43758.5453;\n return s - Math.floor(s);\n}\n\ntype Slot = {\n x: number;\n top: number;\n bottom: number;\n land: number;\n fall: number;\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\nfunction LineCascadeBase({\n value = \"240\",\n caption = \"launch films rendered with remocn today\",\n accent = \"#3B5BFD\",\n speed = 1,\n theme = \"dark\",\n}: LineCascadeProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H } = useVideoConfig();\n const u = H / 720;\n const stage = THEMES[theme];\n const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n const maskId = `m${uid}`;\n const fluteId = `f${uid}`;\n const fluteGlyphId = `fg${uid}`;\n const isDark = theme === \"dark\";\n const flute: Array<[number, string]> = isDark\n ? [\n [0, FLUTED[3]],\n [0.3, FLUTED[2]],\n [0.66, accent],\n [1, FLUTED[0]],\n ]\n : [\n [0, FLUTED[2]],\n [0.6, accent],\n [1, FLUTED[0]],\n ];\n\n const layout = useMemo(() => layoutGlyphs(value), [value]);\n const capSize = 24 * u;\n const gapBelow = 34 * u;\n const glyphH = Math.min(0.5 * H, (0.74 * W) / Math.max(layout.width, 0.5));\n const glyphW = layout.width * glyphH;\n const blockH = glyphH + (caption ? gapBelow + capSize * 1.3 : 0);\n const gx = (W - glyphW) / 2;\n const gy = (H - blockH) / 2 + 4 * u;\n const floorY = gy + glyphH;\n\n const pitch = 6.5 * u;\n const slotH = 13 * u;\n const hair = Math.max(1.5, 1.6 * u);\n const gapY = 3 * u;\n const lineLen = slotH - gapY;\n const fallSpeed = 0.072 * H;\n\n const slots = useMemo(() => {\n const out: Slot[] = [];\n const cols = Math.floor(glyphW / pitch);\n const offset = (glyphW - cols * pitch) / 2;\n const step = 1.5 * u;\n for (let c = 0; c < cols; c++) {\n const x = gx + offset + (c + 0.5) * pitch;\n const ux = (x - gx) / glyphH;\n const intervals: Array<[number, number]> = [];\n let start = -1;\n for (let y = gy - R * glyphH; y <= floorY + R * glyphH; y += step) {\n const uy = (y - gy) / glyphH;\n let inside = false;\n for (const s of layout.segs) {\n if (segDist(ux, uy, s) <= R) {\n inside = true;\n break;\n }\n }\n if (inside && start < 0) start = y;\n if (!inside && start >= 0) {\n intervals.push([start, y - step]);\n start = -1;\n }\n }\n if (start >= 0) intervals.push([start, floorY]);\n const colRate = 0.88 + 0.24 * hash(c * 3.1 + 7);\n const colLag = 5 * hash(c * 1.7 + 2);\n intervals.forEach(([a, b], iv) => {\n let bottom = b;\n let j = 0;\n while (bottom - a > 0.45 * slotH) {\n const top = Math.max(a, bottom - slotH);\n const level = (floorY - bottom) / glyphH;\n const jitter = 4 * hash(c * 91.7 + iv * 13.1 + j * 5.3);\n const land = Math.min(\n SNAP_AT - 5,\n RAIN_AT + 12 + level * RAIN_SPAN * colRate + colLag + jitter,\n );\n const target = bottom - gapY / 2;\n const fall = (target + lineLen * 3) / fallSpeed;\n out.push({ x, top: top + gapY / 2, bottom: target, land, fall });\n bottom = top;\n j++;\n }\n });\n }\n return out;\n }, [\n layout,\n gx,\n gy,\n glyphW,\n glyphH,\n floorY,\n pitch,\n slotH,\n gapY,\n lineLen,\n u,\n fallSpeed,\n ]);\n\n const floorDraw = EASE_IO(\n interpolate(t, [FLOOR_AT, FLOOR_END], [0, 1], CLAMP),\n );\n const floorFade = interpolate(t, [SNAP_AT, SNAP_END + 6], [1, 0], CLAMP);\n const snap = EASE_OUT(interpolate(t, [SNAP_AT, SNAP_END], [0, 1], CLAMP));\n const solid = EASE_IO(\n interpolate(t, [SNAP_AT + 2, SNAP_END - 1], [0, 1], CLAMP),\n );\n const pileOut = interpolate(t, [SNAP_END - 3, SNAP_END + 1], [1, 0], CLAMP);\n const pileOpacity = stage.pile + (1 - stage.pile) * snap;\n const lineW = hair + (pitch + 0.6 * u - hair) * snap;\n const growY = gapY * snap;\n const capIn = EASE_OUT(\n interpolate(t, [CAPTION_AT, CAPTION_AT + 16], [0, 1], CLAMP),\n );\n\n const falling: React.ReactNode[] = [];\n const landed: React.ReactNode[] = [];\n slots.forEach((s, i) => {\n if (t >= s.land) {\n landed.push(\n <rect\n key={i}\n x={s.x - lineW / 2}\n y={s.top - growY / 2}\n width={lineW}\n height={s.bottom - s.top + growY}\n />,\n );\n return;\n }\n const startT = s.land - s.fall;\n if (t < startT) return;\n const p = (t - startT) / s.fall;\n const head = -lineLen * 3 + p * (s.bottom + lineLen * 3);\n const streak = lineLen * (1 + 1.6 * Math.min(1, (1 - p) * 4));\n falling.push(\n <rect\n key={i}\n x={s.x - hair / 2}\n y={head - streak}\n width={hair}\n height={streak}\n />,\n );\n });\n\n return (\n <AbsoluteFill style={{ background: stage.bg, overflow: \"hidden\" }}>\n <svg\n width={W}\n height={H}\n viewBox={`0 0 ${W} ${H}`}\n style={{ position: \"absolute\", inset: 0 }}\n aria-hidden\n >\n <defs>\n <linearGradient\n id={fluteId}\n gradientUnits=\"userSpaceOnUse\"\n x1={0}\n x2={0}\n y1={gy - R * glyphH}\n y2={floorY + R * glyphH}\n >\n {flute.map(([o, c]) => (\n <stop key={o} offset={o} stopColor={c} />\n ))}\n </linearGradient>\n <linearGradient\n id={fluteGlyphId}\n gradientUnits=\"userSpaceOnUse\"\n x1={0}\n x2={0}\n y1={-R}\n y2={1 + R}\n >\n {flute.map(([o, c]) => (\n <stop key={o} offset={o} stopColor={c} />\n ))}\n </linearGradient>\n <mask\n id={maskId}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <g\n transform={`translate(${gx} ${gy}) scale(${glyphH})`}\n fill=\"none\"\n stroke=\"#fff\"\n strokeWidth={STROKE}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n {layout.strokes.map((s, i) => (\n <path\n key={i}\n d={`M${s.map((p) => `${p[0]} ${p[1]}`).join(\"L\")}`}\n />\n ))}\n </g>\n </mask>\n </defs>\n <rect\n x={gx - 0.04 * W}\n y={floorY + 8 * u}\n width={(glyphW + 0.08 * W) * floorDraw}\n height={Math.max(1, u)}\n fill={stage.floor}\n opacity={floorFade}\n />\n <g fill={stage.fg} opacity={stage.rain * (1 - snap)}>\n {falling}\n </g>\n <g\n transform={`translate(${gx} ${gy}) scale(${glyphH})`}\n fill=\"none\"\n stroke={`url(#${fluteGlyphId})`}\n strokeWidth={STROKE}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n opacity={solid}\n >\n {layout.strokes.map((s, i) => (\n <path key={i} d={`M${s.map((p) => `${p[0]} ${p[1]}`).join(\"L\")}`} />\n ))}\n </g>\n <g\n mask={`url(#${maskId})`}\n fill={`url(#${fluteId})`}\n opacity={pileOpacity * pileOut}\n >\n {landed}\n </g>\n </svg>\n {caption ? (\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: floorY + gapBelow + (1 - capIn) * 10 * u,\n textAlign: \"center\",\n fontFamily: sans,\n fontWeight: 400,\n fontSize: capSize,\n letterSpacing: \"-0.005em\",\n lineHeight: 1.3,\n color: stage.muted,\n opacity: capIn,\n }}\n >\n {caption\n .split(/(remocn)/i)\n .map((part, i) =>\n /^remocn$/i.test(part) ? (\n <RemocnLogo key={i} color={stage.fg} />\n ) : (\n part\n ),\n )}\n </div>\n ) : null}\n <Grain opacity={stage.grain} />\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 value: {\n type: \"text-content\",\n default: \"240\",\n description: \"Value\",\n },\n caption: {\n type: \"text-content\",\n default: \"launch films rendered with remocn today\",\n description: \"Caption\",\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\",\"value\",\"caption\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n theme: \"dark\",\n accent: \"#3B5BFD\",\n value: \"240\",\n caption: \"launch films rendered with remocn today\",\n speed: 1,\n};\n\ntype LineCascadeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof LineCascadeBase>;\n\nconst LineCascadeInner = forwardRef<\n HTMLDivElement,\n LineCascadeElementProps & { 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 ?? \"<LineCascade>\"}\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 <LineCascadeBase\n {...(componentProps as unknown as ComponentProps<typeof LineCascadeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const LineCascade = Interactive.withSchema({\n Component: LineCascadeInner,\n componentName: \"<LineCascade>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 124,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 124
}