Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "hatch-shade",
"title": "Hatch Shade",
"description": "A serif number is shaded in with engraving-style hatch lines on a copper plate.",
"dependencies": ["remotion", "@remotion/google-fonts"],
"files": [
{
"path": "registry/remocn/hatch-shade/index.tsx",
"content": "\"use client\";\n\nimport { loadFont as loadDisplay } from \"@remotion/google-fonts/Fraunces\";\nimport { useId } from \"react\";\nimport {\n AbsoluteFill,\n Easing,\n interpolate,\n useCurrentFrame,\n useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: display } = loadDisplay(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\nloadDisplay(\"italic\", { weights: [\"400\"], subsets: [\"latin\"] });\n\n// gradients.sh \"grain\" palette: a warm copper plate under the etching, and\n// the copper ink of the shading pass.\nconst GRAIN = [\"#ffd8b4\", \"#e0703b\", \"#8a2c1d\", \"#2b1015\"] as const;\n\nexport interface HatchShadeProps {\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 PEN = Easing.bezier(0.45, 0, 0.2, 1);\n\nconst CAP = 0.72;\n\nconst PASSES = [\n { at: 8, sweep: 30, draw: 11, angle: 45, gap: 8, ink: \"fg\" },\n { at: 40, sweep: 30, draw: 11, angle: -45, gap: 8, ink: \"fg\" },\n { at: 74, sweep: 26, draw: 10, angle: 0, gap: 6, ink: \"copper\" },\n] as const;\n\nconst OUTLINE_AT = 100;\nconst OUTLINE_END = 110;\nconst CAPTION_AT = 112;\n\nconst THEMES = {\n dark: {\n bg: \"#070505\",\n fg: \"#F6EEE6\",\n muted: \"#9A8E86\",\n ink: 0.66,\n ghost: 0.05,\n grain: 0.055,\n },\n light: {\n bg: \"#F5F2EC\",\n fg: \"#1A1210\",\n muted: \"#77695F\",\n ink: 0.72,\n ghost: 0.045,\n grain: 0.04,\n },\n} as const;\n\ntype Box = { x: number; y: number; w: number; h: number };\n\nfunction hatchLines(box: Box, angleDeg: number, gap: number) {\n const a = (angleDeg * Math.PI) / 180;\n const dx = Math.cos(a);\n const dy = Math.sin(a);\n const nx = -dy;\n const ny = dx;\n const cx = box.x + box.w / 2;\n const cy = box.y + box.h / 2;\n const half = Math.hypot(box.w, box.h) / 2;\n const spread = Math.abs(nx) * box.w + Math.abs(ny) * box.h;\n const n = Math.ceil(spread / gap);\n const lines: Array<{\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n k: number;\n }> = [];\n for (let i = 0; i <= n; i++) {\n const off = -spread / 2 + i * gap;\n const px = cx + nx * off;\n const py = cy + ny * off;\n lines.push({\n x1: px - dx * half,\n y1: py - dy * half,\n x2: px + dx * half,\n y2: py + dy * half,\n k: n === 0 ? 0 : i / n,\n });\n }\n return lines;\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={23}\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 HatchShade({\n value = \"24\",\n caption = \"new components, drawn for launch week\",\n accent = \"#3B5BFD\",\n speed = 1,\n theme = \"dark\",\n}: HatchShadeProps) {\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 bodyId = `b${uid}`;\n const shadeId = `s${uid}`;\n const rimId = `r${uid}`;\n const copperId = `c${uid}`;\n const isDark = theme === \"dark\";\n const drift = interpolate(t, [0, 160], [0, 1], CLAMP);\n\n const chars = Math.max(1, Array.from(value).length);\n const size = Math.min(0.68 * H, (0.8 * W) / (chars * 0.6));\n const capH = CAP * size;\n const capSize = 22 * u;\n const gapBelow = 40 * u;\n const blockH = capH + (caption ? gapBelow + capSize * 1.3 : 0);\n const top = (H - blockH) / 2;\n const baseline = top + capH;\n const cx = W / 2;\n const estW = chars * 0.66 * size;\n const box: Box = {\n x: cx - estW / 2 - 20 * u,\n y: top - 20 * u,\n w: estW + 40 * u,\n h: capH + 40 * u,\n };\n const shift = 0.034 * size;\n const hair = Math.max(1.5, 1.7 * u);\n\n const textProps = {\n x: cx,\n y: baseline,\n textAnchor: \"middle\" as const,\n fontFamily: display,\n fontWeight: 500,\n fontSize: size,\n letterSpacing: `${-0.02 * size}px`,\n };\n\n const outline = interpolate(t, [OUTLINE_AT, OUTLINE_END], [0, 1], CLAMP);\n const capIn = EASE_OUT(\n interpolate(t, [CAPTION_AT, CAPTION_AT + 16], [0, 1], CLAMP),\n );\n const ghost = interpolate(\n t,\n [0, 10, OUTLINE_AT, OUTLINE_END],\n [0, 1, 1, 0],\n CLAMP,\n );\n\n const passes = PASSES.map((pass, pi) => {\n const lines = hatchLines(box, pass.angle, pass.gap * u);\n const color = pass.ink === \"copper\" ? `url(#${copperId})` : stage.fg;\n const opacity = pass.ink === \"copper\" ? 1 : stage.ink;\n const els = lines.map((l, i) => {\n const order = pi === 1 ? l.k : l.k;\n const start = pass.at + order * pass.sweep;\n const p = PEN(interpolate(t, [start, start + pass.draw], [0, 1], CLAMP));\n if (p <= 0) return null;\n const taper = pi === 1 ? interpolate(l.k, [0.18, 0.8], [0, 1], CLAMP) : 1;\n if (taper * hair * 1.35 < 0.45) return null;\n return (\n <line\n key={i}\n strokeWidth={pi === 1 ? taper * hair * 1.35 : undefined}\n x1={l.x1}\n y1={l.y1}\n x2={l.x2}\n y2={l.y2}\n pathLength={1}\n strokeDasharray={p >= 1 ? undefined : \"1 1\"}\n strokeDashoffset={p >= 1 ? undefined : 1 - p}\n />\n );\n });\n return (\n <g\n key={pi}\n mask={`url(#${pi === 2 ? shadeId : bodyId})`}\n stroke={color}\n strokeWidth={hair}\n strokeLinecap=\"butt\"\n opacity={opacity}\n >\n {els}\n </g>\n );\n });\n\n return (\n <AbsoluteFill style={{ background: stage.bg, overflow: \"hidden\" }}>\n <AbsoluteFill\n style={{\n background: isDark\n ? [\n `radial-gradient(60% 45% at ${18 + drift * 4}% ${20 + drift * 3}%, ${GRAIN[2]}47 0%, transparent 62%)`,\n `linear-gradient(150deg, ${GRAIN[3]}e6 0%, ${GRAIN[3]}66 38%, transparent 70%)`,\n `radial-gradient(50% 40% at 88% 96%, ${GRAIN[2]}2e 0%, transparent 70%)`,\n ].join(\", \")\n : [\n `radial-gradient(60% 45% at ${18 + drift * 4}% ${20 + drift * 3}%, ${GRAIN[0]}8c 0%, transparent 60%)`,\n `linear-gradient(150deg, ${GRAIN[0]}66 0%, transparent 60%)`,\n ].join(\", \"),\n }}\n />\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={copperId}\n gradientUnits=\"userSpaceOnUse\"\n x1={box.x}\n y1={box.y}\n x2={box.x + box.w}\n y2={box.y + box.h}\n >\n <stop offset={0} stopColor={isDark ? GRAIN[0] : GRAIN[1]} />\n <stop offset={0.45} stopColor={isDark ? GRAIN[1] : GRAIN[2]} />\n <stop offset={1} stopColor={isDark ? GRAIN[2] : GRAIN[3]} />\n </linearGradient>\n <mask\n id={bodyId}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <text {...textProps} fill=\"#fff\">\n {value}\n </text>\n </mask>\n <mask\n id={shadeId}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={W}\n height={H}\n >\n <text {...textProps} fill=\"#fff\">\n {value}\n </text>\n <text\n {...textProps}\n x={cx - shift}\n y={baseline - shift}\n fill=\"#000\"\n >\n {value}\n </text>\n </mask>\n <filter\n id={rimId}\n x={0}\n y={0}\n width={W}\n height={H}\n filterUnits=\"userSpaceOnUse\"\n >\n <feMorphology\n in=\"SourceAlpha\"\n operator=\"erode\"\n radius={hair * 0.9}\n result=\"inner\"\n />\n <feComposite\n in=\"SourceAlpha\"\n in2=\"inner\"\n operator=\"out\"\n result=\"rim\"\n />\n <feFlood floodColor={stage.fg} />\n <feComposite in2=\"rim\" operator=\"in\" />\n </filter>\n </defs>\n <text {...textProps} fill={accent} opacity={ghost * stage.ghost}>\n {value}\n </text>\n {passes}\n <text\n {...textProps}\n fill=\"#000\"\n filter={`url(#${rimId})`}\n opacity={outline}\n >\n {value}\n </text>\n </svg>\n {caption ? (\n <div\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: baseline + gapBelow + (1 - capIn) * 10 * u,\n textAlign: \"center\",\n fontFamily: display,\n fontStyle: \"italic\",\n fontWeight: 400,\n fontSize: capSize * 1.2,\n letterSpacing: \"-0.005em\",\n lineHeight: 1.3,\n color: stage.muted,\n opacity: capIn,\n }}\n >\n {caption}\n </div>\n ) : null}\n <Grain opacity={stage.grain} />\n </AbsoluteFill>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/hatch-shade.tsx"
}
],
"type": "registry:component"
}