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": "Halftone Cut",
"initialProps": null,
"slug": "halftone-cut",
"sourceCode": "import { loadFont as loadSerif } from \"@remotion/google-fonts/Fraunces\";\nimport { useId } from \"react\";\nimport { AbsoluteFill, Easing, interpolate, useCurrentFrame, useVideoConfig } from \"remotion\";\n\nconst { fontFamily: serif } = loadSerif(\"normal\", {\n weights: [\"500\"],\n subsets: [\"latin\"],\n});\nloadSerif(\"italic\", { weights: [\"400\"], subsets: [\"latin\"] });\n\nexport interface HalftoneCutProps {\n from?: string;\n to?: 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 T0 = 8;\nconst SPREAD = 34;\nconst SHRINK_LEN = 14;\nconst LAG = 12;\nconst GROW_LEN = 18;\nconst INK_LEAD = 6;\nconst INK_OUT = 10;\nconst INK_LAG = 8;\nconst INK_IN = 14;\nconst END = T0 + SPREAD + LAG + INK_LAG + INK_IN;\n\nconst SHRINK = Easing.bezier(0.45, 0, 0.6, 1);\nconst GROW = Easing.bezier(0.3, 0, 0.2, 1);\nconst SETTLE = Easing.bezier(0.22, 1, 0.36, 1);\n\ntype Blob = {\n c: string;\n x: number;\n y: number;\n w: number;\n h: number;\n a: number;\n};\n\n/** gradients.sh palettes: \"grain\" (dark) and \"smear\" (light). */\nconst STAGES = {\n dark: {\n bg: \"#0A0A0B\",\n fg: \"#F3F2EF\",\n base: \"#F5F4F0\",\n tint: 0.16,\n ground: \"#070505\",\n toFg: \"#FFF4EA\",\n sweep: [\"#ffd8b4\", \"#e0703b\", \"#8a2c1d\", \"#2b1015\"],\n blobs: [{ c: \"#ffd8b4\", x: 18, y: 20, w: 60, h: 45, a: 0.85 }] as Blob[],\n },\n light: {\n bg: \"#F5F4F0\",\n fg: \"#121214\",\n base: \"#121214\",\n tint: 0.07,\n ground: \"#efe8dc\",\n toFg: \"#17120E\",\n sweep: [] as string[],\n blobs: [\n { c: \"#f7b23b\", x: 20, y: 82, w: 62, h: 70, a: 0.85 },\n { c: \"#f2552c\", x: 82, y: 22, w: 56, h: 66, a: 0.78 },\n { c: \"#e889b5\", x: 10, y: 10, w: 52, h: 60, a: 0.8 },\n { c: \"#2f6b3f\", x: 100, y: 104, w: 30, h: 34, a: 0.28 },\n ] as Blob[],\n },\n};\n\n/** Fraunces advances (opsz 144), ASCII 32–126, per 1000 em: roman 500, italic 400. */\nconst ROMAN = [\n 162, 227, 276, 560, 518, 594, 882, 140, 308, 306, 568, 455, 190, 239, 187,\n 328, 602, 363, 542, 502, 554, 520, 558, 470, 530, 562, 177, 188, 432, 455,\n 432, 489, 740, 613, 632, 635, 707, 584, 530, 688, 742, 326, 374, 682, 546,\n 801, 670, 731, 610, 740, 650, 560, 609, 658, 598, 904, 634, 601, 562, 300,\n 317, 300, 298, 344, 221, 444, 494, 411, 498, 427, 268, 480, 508, 230, 230,\n 494, 236, 784, 508, 490, 510, 494, 375, 383, 290, 508, 434, 672, 446, 452,\n 402, 340, 222, 340, 482,\n];\nconst ITALIC = [\n 156, 278, 252, 548, 480, 572, 598, 128, 309, 308, 537, 455, 179, 263, 180,\n 388, 618, 384, 530, 498, 510, 506, 552, 428, 506, 548, 246, 249, 432, 455,\n 432, 391, 723, 551, 596, 596, 670, 574, 540, 648, 705, 335, 323, 638, 500,\n 773, 600, 686, 593, 688, 613, 521, 514, 606, 534, 851, 576, 520, 548, 324,\n 372, 324, 298, 350, 172, 459, 463, 383, 457, 385, 246, 428, 476, 246, 218,\n 470, 230, 713, 482, 438, 448, 437, 365, 356, 268, 481, 448, 658, 468, 406,\n 406, 330, 222, 327, 482,\n];\nconst TRACK = -0.025;\n\nfunction widthEm(text: string, table: number[]) {\n let w = 0;\n for (const ch of text) {\n const c = ch.charCodeAt(0);\n w += (c >= 32 && c < 127 ? table[c - 32] : 520) / 1000 + TRACK;\n }\n return Math.max(w - TRACK, 0.5);\n}\n\n/** CSS linear-gradient angle → SVG userSpace endpoints. */\nfunction cssLine(W: number, H: number, deg: number) {\n const a = (deg * Math.PI) / 180;\n const dx = Math.sin(a);\n const dy = -Math.cos(a);\n const half = (Math.abs(W * dx) + Math.abs(H * dy)) / 2;\n return {\n x1: W / 2 - dx * half,\n y1: H / 2 - dy * half,\n x2: W / 2 + dx * half,\n y2: H / 2 + dy * half,\n };\n}\n\nfunction Ground({\n id,\n W,\n H,\n stage,\n k,\n}: {\n id: string;\n W: number;\n H: number;\n stage: (typeof STAGES)[\"dark\"];\n k: number;\n}) {\n const line = cssLine(W, H, 150 - 6 * k);\n const n = stage.sweep.length;\n return (\n <g>\n <defs>\n {n > 0 ? (\n <linearGradient\n id={`${id}l`}\n gradientUnits=\"userSpaceOnUse\"\n {...line}\n >\n {stage.sweep.map((c, i) => (\n <stop key={c} offset={(0.7 * i) / (n - 1)} stopColor={c} />\n ))}\n <stop offset={0.85} stopColor={stage.ground} />\n </linearGradient>\n ) : null}\n {stage.blobs.map((b, i) => {\n const x = (b.x + (i % 2 === 0 ? 4 : -4) * k) / 100;\n const y = (b.y + (i % 2 === 0 ? 3 : -2) * k) / 100;\n return (\n <radialGradient\n key={b.c}\n id={`${id}r${i}`}\n cx={x}\n cy={y}\n r={b.w / 100}\n gradientTransform={`translate(${x} ${y}) scale(1 ${b.h / b.w}) translate(${-x} ${-y})`}\n >\n <stop offset={0} stopColor={b.c} stopOpacity={b.a} />\n <stop offset={0.68} stopColor={b.c} stopOpacity={0} />\n </radialGradient>\n );\n })}\n </defs>\n <rect width={W} height={H} fill={stage.ground} />\n {n > 0 ? <rect width={W} height={H} fill={`url(#${id}l)`} /> : null}\n {stage.blobs.map((b, i) => (\n <rect key={b.c} width={W} height={H} fill={`url(#${id}r${i})`} />\n ))}\n </g>\n );\n}\n\nfunction dot(cx: number, cy: number, r: number) {\n const x = cx - r;\n const d = 2 * r;\n return `M${x.toFixed(2)} ${cy.toFixed(2)}a${r.toFixed(2)} ${r.toFixed(2)} 0 1 0 ${d.toFixed(2)} 0a${r.toFixed(2)} ${r.toFixed(2)} 0 1 0 ${(-d).toFixed(2)} 0`;\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 function HalftoneCut({\n from = \"Draft one\",\n to = \"Final cut\",\n accent = \"#3B5BFD\",\n theme = \"dark\",\n speed = 1,\n}: HalftoneCutProps) {\n const t = useCurrentFrame() * speed;\n const { width: W, height: H } = useVideoConfig();\n const u = H / 720;\n const stage = STAGES[theme];\n const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n\n const pitch = 20 * u;\n const R = 0.74 * pitch;\n const cols = Math.ceil(W / pitch) + 1;\n const rows = Math.ceil(H / pitch) + 1;\n const ox = (W - (cols - 1) * pitch) / 2;\n const oy = (H - (rows - 1) * pitch) / 2;\n const ang = 0.52;\n const ca = Math.cos(ang);\n const sa = Math.sin(ang);\n const span = W * ca + H * sa;\n\n let pathA = \"\";\n let pathB = \"\";\n let inkA = \"\";\n let inkB = \"\";\n let aFull = true;\n let aEmpty = true;\n let bFull = true;\n let bEmpty = true;\n for (let j = 0; j < rows; j++) {\n for (let i = 0; i < cols; i++) {\n const cx = ox + i * pitch;\n const cy = oy + j * pitch;\n const d = Math.min(1, Math.max(0, (cx * ca + cy * sa) / span));\n const a0 = T0 + d * SPREAD;\n const pa = SHRINK(interpolate(t, [a0, a0 + SHRINK_LEN], [0, 1], CLAMP));\n const pb = GROW(\n interpolate(t, [a0 + LAG, a0 + LAG + GROW_LEN], [0, 1], CLAMP),\n );\n const ia = SHRINK(\n interpolate(t, [a0 - INK_LEAD, a0 - INK_LEAD + INK_OUT], [0, 1], CLAMP),\n );\n const ib = GROW(\n interpolate(\n t,\n [a0 + LAG + INK_LAG, a0 + LAG + INK_LAG + INK_IN],\n [0, 1],\n CLAMP,\n ),\n );\n const ra = R * (1 - pa);\n const rb = R * pb;\n if (ia < 1) inkA += dot(cx, cy, R * (1 - ia));\n if (ib > 0) inkB += dot(cx, cy, R * ib);\n if (ia > 0) aFull = false;\n if (ib < 1) bFull = false;\n if (ra > 0.15 * u) {\n aEmpty = false;\n pathA += dot(cx, cy, ra);\n }\n if (rb > 0.15 * u) {\n bEmpty = false;\n pathB += dot(cx, cy, rb);\n }\n }\n }\n\n const fsA = Math.min(176 * u, (0.8 * W) / widthEm(from, ITALIC));\n const fsB = Math.min(200 * u, (0.82 * W) / widthEm(to, ROMAN));\n const drift = interpolate(t, [0, 108], [0, 1], CLAMP);\n const driftA = 1 + 0.025 * interpolate(t, [0, T0 + SPREAD], [0, 1], CLAMP);\n const settle = SETTLE(\n interpolate(t, [T0 + LAG + 10, END + 14], [0, 1], CLAMP),\n );\n const scaleB = 1.045 - 0.045 * settle;\n const about = (k: number) =>\n `translate(${W / 2} ${H / 2}) scale(${k}) translate(${-W / 2} ${-H / 2})`;\n\n const title = (\n text: string,\n size: number,\n fill: string,\n k: number,\n italic: boolean,\n ) => (\n <text\n x={W / 2}\n y={H / 2 + 0.35 * size}\n textAnchor=\"middle\"\n fontFamily={serif}\n fontStyle={italic ? \"italic\" : \"normal\"}\n fontWeight={italic ? 400 : 500}\n fontSize={size}\n letterSpacing={TRACK * size}\n fill={fill}\n transform={about(k)}\n >\n {text}\n </text>\n );\n\n return (\n <AbsoluteFill style={{ background: stage.base, 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 <radialGradient\n id={`l${uid}`}\n cx={0.24 * W}\n cy={0}\n r={0.9 * W}\n gradientUnits=\"userSpaceOnUse\"\n >\n <stop offset=\"0\" stopColor={accent} stopOpacity={stage.tint} />\n <stop offset=\"0.7\" stopColor={accent} stopOpacity={0} />\n </radialGradient>\n <linearGradient id={`s${uid}`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"0\" stopColor=\"#FFFFFF\" stopOpacity={0.07} />\n <stop offset=\"0.45\" stopColor=\"#FFFFFF\" stopOpacity={0} />\n <stop offset=\"1\" stopColor=\"#000000\" stopOpacity={0.1} />\n </linearGradient>\n <mask\n id={`a${uid}`}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <path d={pathA} fill=\"#FFFFFF\" />\n </mask>\n <mask\n id={`ia${uid}`}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <path d={inkA} fill=\"#FFFFFF\" />\n </mask>\n <mask\n id={`ib${uid}`}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <path d={inkB} fill=\"#FFFFFF\" />\n </mask>\n <mask\n id={`b${uid}`}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <path d={pathB} fill=\"#FFFFFF\" />\n </mask>\n </defs>\n {aEmpty ? null : (\n <g mask={aFull ? undefined : `url(#a${uid})`}>\n <rect width={W} height={H} fill={stage.bg} />\n <rect width={W} height={H} fill={`url(#l${uid})`} />\n {aFull ? (\n title(from, fsA, stage.fg, driftA, true)\n ) : (\n <g mask={`url(#ia${uid})`}>\n {title(from, fsA, stage.fg, driftA, true)}\n </g>\n )}\n </g>\n )}\n {bEmpty ? null : (\n <g mask={bFull ? undefined : `url(#b${uid})`}>\n <Ground id={`d${uid}`} W={W} H={H} stage={stage} k={drift} />\n <rect width={W} height={H} fill={`url(#s${uid})`} />\n {bFull ? (\n title(to, fsB, stage.toFg, scaleB, false)\n ) : (\n <g mask={`url(#ib${uid})`}>\n {title(to, fsB, stage.toFg, scaleB, false)}\n </g>\n )}\n </g>\n )}\n </svg>\n <Grain opacity={theme === \"light\" ? 0.04 : 0.055} />\n </AbsoluteFill>\n );\n}",
"durationInFrames": 76,
"installationMode": "wrapped"
},
"durationInFrames": 76
}