{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "raster-paint",
  "title": "Raster Paint",
  "description": "A pixelated 10x is painted tile by tile in warm-to-blue colours.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/raster-paint/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/GeistMono\";\nimport { useId, useMemo } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: mono } = loadFont(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\n\nexport interface RasterPaintProps {\n  title?: string;\n  label?: string;\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\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 SCAN = Easing.bezier(0.45, 0, 0.55, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    fg: \"#F3F2EF\",\n    muted: \"#9A999F\",\n    slot: \"rgba(255,255,255,0.035)\",\n    light: \"rgba(255,255,255,0.045)\",\n    band: 0.16,\n    // gradients.sh \"halo\", top-left to bottom-right through the bitmap\n    halo: [\"#fff4ec\", \"#ffb36b\", \"#e2457a\", \"#3d4dff\"],\n    grain: 0.06,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    muted: \"#6E6C67\",\n    slot: \"rgba(18,18,20,0.04)\",\n    light: \"rgba(255,255,255,0.75)\",\n    band: 0.12,\n    halo: [\"#f59a52\", \"#e2457a\", \"#3d4dff\", \"#2b2f9e\"],\n    grain: 0.045,\n  },\n} as const;\n\nconst LINE_IN = 2;\nconst SCAN_AT = 10;\nconst SCAN_DUR = 58;\nconst SWEEP = 4;\nconst TRAIL = 12;\nconst LABEL_AT = SCAN_AT + SCAN_DUR + 6;\n\nconst GLYPHS: Record<string, string[]> = {\n  \"0\": [\".###.\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \".###.\"],\n  \"1\": [\"..#\", \".##\", \"#.#\", \"..#\", \"..#\", \"..#\", \"..#\"],\n  \"2\": [\".###.\", \"#...#\", \"....#\", \"...#.\", \"..#..\", \".#...\", \"#####\"],\n  \"3\": [\"#####\", \"...#.\", \"..#..\", \"...#.\", \"....#\", \"#...#\", \".###.\"],\n  \"4\": [\"...#.\", \"..##.\", \".#.#.\", \"#..#.\", \"#####\", \"...#.\", \"...#.\"],\n  \"5\": [\"#####\", \"#....\", \"####.\", \"....#\", \"....#\", \"#...#\", \".###.\"],\n  \"6\": [\"..##.\", \".#...\", \"#....\", \"####.\", \"#...#\", \"#...#\", \".###.\"],\n  \"7\": [\"#####\", \"....#\", \"...#.\", \"..#..\", \".#...\", \".#...\", \".#...\"],\n  \"8\": [\".###.\", \"#...#\", \"#...#\", \".###.\", \"#...#\", \"#...#\", \".###.\"],\n  \"9\": [\".###.\", \"#...#\", \"#...#\", \".####\", \"....#\", \"...#.\", \".##..\"],\n  \".\": [\"..\", \"..\", \"..\", \"..\", \"..\", \"##\", \"##\"],\n  \",\": [\"..\", \"..\", \"..\", \"..\", \"##\", \".#\", \"#.\"],\n  \"%\": [\"##..#\", \"##..#\", \"...#.\", \"..#..\", \".#...\", \"#..##\", \"#..##\"],\n  \"+\": [\".....\", \"..#..\", \"..#..\", \"#####\", \"..#..\", \"..#..\", \".....\"],\n  \"-\": [\".....\", \".....\", \".....\", \"####.\", \".....\", \".....\", \".....\"],\n  \"!\": [\"#\", \"#\", \"#\", \"#\", \"#\", \".\", \"#\"],\n  x: [\".....\", \".....\", \"#...#\", \".#.#.\", \"..#..\", \".#.#.\", \"#...#\"],\n  A: [\".###.\", \"#...#\", \"#...#\", \"#####\", \"#...#\", \"#...#\", \"#...#\"],\n  B: [\"####.\", \"#...#\", \"#...#\", \"####.\", \"#...#\", \"#...#\", \"####.\"],\n  C: [\".###.\", \"#...#\", \"#....\", \"#....\", \"#....\", \"#...#\", \".###.\"],\n  D: [\"####.\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \"####.\"],\n  E: [\"#####\", \"#....\", \"#....\", \"####.\", \"#....\", \"#....\", \"#####\"],\n  F: [\"#####\", \"#....\", \"#....\", \"####.\", \"#....\", \"#....\", \"#....\"],\n  G: [\".###.\", \"#...#\", \"#....\", \"#.###\", \"#...#\", \"#...#\", \".####\"],\n  H: [\"#...#\", \"#...#\", \"#...#\", \"#####\", \"#...#\", \"#...#\", \"#...#\"],\n  I: [\".###.\", \"..#..\", \"..#..\", \"..#..\", \"..#..\", \"..#..\", \".###.\"],\n  J: [\"..###\", \"...#.\", \"...#.\", \"...#.\", \"...#.\", \"#..#.\", \".##..\"],\n  K: [\"#...#\", \"#..#.\", \"#.#..\", \"##...\", \"#.#..\", \"#..#.\", \"#...#\"],\n  L: [\"#....\", \"#....\", \"#....\", \"#....\", \"#....\", \"#....\", \"#####\"],\n  M: [\"#...#\", \"##.##\", \"#.#.#\", \"#.#.#\", \"#...#\", \"#...#\", \"#...#\"],\n  N: [\"#...#\", \"#...#\", \"##..#\", \"#.#.#\", \"#..##\", \"#...#\", \"#...#\"],\n  O: [\".###.\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \".###.\"],\n  P: [\"####.\", \"#...#\", \"#...#\", \"####.\", \"#....\", \"#....\", \"#....\"],\n  Q: [\".###.\", \"#...#\", \"#...#\", \"#...#\", \"#.#.#\", \"#..#.\", \".##.#\"],\n  R: [\"####.\", \"#...#\", \"#...#\", \"####.\", \"#.#..\", \"#..#.\", \"#...#\"],\n  S: [\".####\", \"#....\", \"#....\", \".###.\", \"....#\", \"....#\", \"####.\"],\n  T: [\"#####\", \"..#..\", \"..#..\", \"..#..\", \"..#..\", \"..#..\", \"..#..\"],\n  U: [\"#...#\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \".###.\"],\n  V: [\"#...#\", \"#...#\", \"#...#\", \"#...#\", \"#...#\", \".#.#.\", \"..#..\"],\n  W: [\"#...#\", \"#...#\", \"#...#\", \"#.#.#\", \"#.#.#\", \"#.#.#\", \".#.#.\"],\n  X: [\"#...#\", \"#...#\", \".#.#.\", \"..#..\", \".#.#.\", \"#...#\", \"#...#\"],\n  Y: [\"#...#\", \"#...#\", \".#.#.\", \"..#..\", \"..#..\", \"..#..\", \"..#..\"],\n  Z: [\"#####\", \"....#\", \"...#.\", \"..#..\", \".#...\", \"#....\", \"#####\"],\n  \" \": [\"...\", \"...\", \"...\", \"...\", \"...\", \"...\", \"...\"],\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\nfunction rasterize(text: string) {\n  const rows: string[] = Array.from({ length: 7 }, () => \"\");\n  const chars = text.split(\"\");\n  chars.forEach((ch, i) => {\n    const g = GLYPHS[ch] ?? GLYPHS[ch.toUpperCase()] ?? GLYPHS[\" \"];\n    for (let r = 0; r < 7; r++)\n      rows[r] += g[r] + (i < chars.length - 1 ? \".\" : \"\");\n  });\n  return rows.map((row) => row.split(\"\").map((c) => (c === \"#\" ? 1 : 0)));\n}\n\nfunction scale2x(src: number[][]) {\n  const h = src.length;\n  const w = src[0]?.length ?? 0;\n  const at = (r: number, c: number) =>\n    r < 0 || c < 0 || r >= h || c >= w ? 0 : src[r][c];\n  const out: number[][] = Array.from({ length: h * 2 }, () =>\n    new Array(w * 2).fill(0),\n  );\n  for (let r = 0; r < h; r++) {\n    for (let c = 0; c < w; c++) {\n      const p = src[r][c];\n      const a = at(r - 1, c);\n      const b = at(r, c + 1);\n      const cc = at(r, c - 1);\n      const d = at(r + 1, c);\n      out[r * 2][c * 2] = cc === a && cc !== d && a !== b ? a : p;\n      out[r * 2][c * 2 + 1] = a === b && a !== cc && b !== d ? b : p;\n      out[r * 2 + 1][c * 2] = d === cc && d !== b && cc !== a ? cc : p;\n      out[r * 2 + 1][c * 2 + 1] = b === d && b !== a && d !== cc ? d : p;\n    }\n  }\n  return out;\n}\n\nfunction parseHex(hex: string) {\n  const m = /^#?([0-9a-f]{6})$/i.exec(hex.trim());\n  if (!m) return null;\n  const n = Number.parseInt(m[1], 16);\n  return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n}\n\nconst toLin = (v: number) => {\n  const c = v / 255;\n  return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n};\nconst toSrgb = (v: number) => {\n  const c = v <= 0.0031308 ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055;\n  return Math.round(Math.min(1, Math.max(0, c)) * 255);\n};\n\nfunction toOklab([r8, g8, b8]: number[]) {\n  const r = toLin(r8);\n  const g = toLin(g8);\n  const b = toLin(b8);\n  const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n  const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n  const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n  return [\n    0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,\n    1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,\n    0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,\n  ];\n}\n\nfunction fromOklab([L, A, B]: number[]) {\n  const l = (L + 0.3963377774 * A + 0.2158037573 * B) ** 3;\n  const m = (L - 0.1055613458 * A - 0.0638541728 * B) ** 3;\n  const s = (L - 0.0894841775 * A - 1.291485548 * B) ** 3;\n  return [\n    toSrgb(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),\n    toSrgb(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),\n    toSrgb(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s),\n  ];\n}\n\n/** Perceptual (OKLab) mix, so warm-to-blue transitions stay vivid. */\nfunction mix(a: number[], b: number[], k: number) {\n  const la = toOklab(a);\n  const lb = toOklab(b);\n  return fromOklab(la.map((v, i) => v + (lb[i] - v) * k));\n}\n\nconst css = (c: number[]) => `rgb(${c[0]},${c[1]},${c[2]})`;\n\nfunction ramp(stops: number[][], k: number) {\n  const x = Math.min(1, Math.max(0, k)) * (stops.length - 1);\n  const i = Math.min(stops.length - 2, Math.floor(x));\n  return mix(stops[i], stops[i + 1], x - i);\n}\n\nexport function RasterPaint({\n  title = \"10x\",\n  label = \"Faster renders in remocn 2.0\",\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: RasterPaintProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = H / 720;\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const pal = THEMES[theme];\n\n  const bitmap = useMemo(() => scale2x(rasterize(title)), [title]);\n  const rows = bitmap.length;\n  const cols = bitmap[0]?.length ?? 1;\n\n  const p = Math.min((H * 0.44) / rows, (W * 0.76) / cols);\n  const sq = p * 0.86;\n  const blockW = cols * p;\n  const blockH = rows * p;\n  const labelSize = 28 * u;\n  const labelGap = label ? 44 * u : 0;\n  const groupH = blockH + (label ? labelGap + labelSize * 1.2 : 0);\n  const left = W / 2 - blockW / 2;\n  const top = H / 2 - groupH / 2;\n\n  const accRgb = parseHex(accent) ?? [59, 91, 253];\n  const hotRgb = accRgb.map((v) => v + (255 - v) * 0.35);\n  const haloRgb = pal.halo.map((c) => parseHex(c) ?? accRgb);\n  const drift = interpolate(t, [0, 120], [-0.06, 0.06], CLAMP);\n\n  const scanK = interpolate(t, [SCAN_AT, SCAN_AT + SCAN_DUR], [0, 1], CLAMP);\n  const headRow = -1.5 + SCAN(scanK) * (rows + 3);\n  const headY = top + headRow * p;\n  const rowTime = (r: number) => {\n    const target = (r + 0.5 + 1.5) / (rows + 3);\n    let lo = 0;\n    let hi = 1;\n    for (let i = 0; i < 18; i++) {\n      const mid = (lo + hi) / 2;\n      if (SCAN(mid) < target) lo = mid;\n      else hi = mid;\n    }\n    return SCAN_AT + lo * SCAN_DUR + 1 + hash(r * 3.17) * 2.4;\n  };\n\n  const rects: React.ReactNode[] = [];\n  for (let r = 0; r < rows; r++) {\n    const tr = rowTime(r);\n    if (t < tr) continue;\n    const y = top + r * p + (p - sq) / 2;\n    for (let c = 0; c < cols; c++) {\n      if (!bitmap[r][c]) continue;\n      const tp = tr + (c / cols) * SWEEP;\n      const age = t - tp;\n      if (age < 0) continue;\n      const on = EASE_OUT(interpolate(age, [0, 3], [0, 1], CLAMP));\n      const cool = EASE_OUT(interpolate(age, [1, TRAIL], [0, 1], CLAMP));\n      const settled = ramp(\n        haloRgb,\n        (r / rows) * 0.72 + (c / cols) * 0.28 + drift,\n      );\n      const fill = css(\n        cool < 0.5\n          ? mix(hotRgb, accRgb, cool * 2)\n          : mix(accRgb, settled, (cool - 0.5) * 2),\n      );\n      const s = sq * (0.82 + 0.18 * on);\n      rects.push(\n        <rect\n          key={`${r}-${c}`}\n          x={left + c * p + (p - s) / 2}\n          y={y + (sq - s) / 2}\n          width={s}\n          height={s}\n          fill={fill}\n          opacity={on}\n        />,\n      );\n    }\n  }\n\n  const over = 40 * u;\n  const lineIn = EASE_OUT(\n    interpolate(t, [LINE_IN, SCAN_AT + 4], [0, 1], CLAMP),\n  );\n  const lineOut = interpolate(\n    t,\n    [SCAN_AT + SCAN_DUR - 6, SCAN_AT + SCAN_DUR + 2],\n    [1, 0],\n    CLAMP,\n  );\n  const lineAlpha = lineOut;\n  const halfLen = (blockW / 2 + over) * lineIn;\n  const bandH = p * 7;\n  const labelK = EASE_OUT(\n    interpolate(t, [LABEL_AT, LABEL_AT + 16], [0, 1], CLAMP),\n  );\n  const cam = interpolate(t, [0, LABEL_AT + 30], [1.03, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const tick = 6 * u;\n\n  return (\n    <AbsoluteFill style={{ background: pal.bg, overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{\n          background: `radial-gradient(ellipse 55% 60% at 50% 46%, ${pal.light}, transparent 75%)`,\n        }}\n      />\n      <AbsoluteFill\n        style={{ transform: `scale(${cam})`, transformOrigin: \"50% 50%\" }}\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 id={`${uid}-band`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n              <stop offset=\"0\" stopColor={accent} stopOpacity={0} />\n              <stop offset=\"1\" stopColor={accent} stopOpacity={pal.band} />\n            </linearGradient>\n          </defs>\n          <g opacity={lineIn * lineOut}>\n            {Array.from({ length: cols }, (_, c) => (\n              <rect\n                key={`s${c}`}\n                x={left + c * p + (p - sq) / 2}\n                y={headY + (p - sq) / 2 - p * 0.5}\n                width={sq}\n                height={sq}\n                fill={pal.slot}\n              />\n            ))}\n          </g>\n          {rects}\n          <g opacity={lineAlpha}>\n            <rect\n              x={W / 2 - halfLen}\n              y={headY - bandH}\n              width={halfLen * 2}\n              height={bandH}\n              fill={`url(#${uid}-band)`}\n            />\n            <rect\n              x={W / 2 - halfLen}\n              y={headY - 1.25 * u}\n              width={halfLen * 2}\n              height={2.5 * u}\n              fill={accent}\n            />\n            <rect\n              x={W / 2 - halfLen}\n              y={headY - tick}\n              width={2.5 * u}\n              height={tick * 2}\n              fill={accent}\n              opacity={lineIn}\n            />\n            <rect\n              x={W / 2 + halfLen - 2.5 * u}\n              y={headY - tick}\n              width={2.5 * u}\n              height={tick * 2}\n              fill={accent}\n              opacity={lineIn}\n            />\n          </g>\n        </svg>\n        {label ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: 0,\n              width: W,\n              top: top + blockH + labelGap,\n              display: \"flex\",\n              justifyContent: \"center\",\n              alignItems: \"center\",\n              gap: 14 * u,\n              opacity: labelK,\n              transform: `translateY(${(1 - labelK) * 10 * u}px)`,\n            }}\n          >\n            <div\n              style={{\n                width: 11 * u,\n                height: 11 * u,\n                background: accent,\n              }}\n            />\n            <div\n              style={{\n                fontFamily: mono,\n                fontWeight: 400,\n                fontSize: labelSize,\n                lineHeight: 1.2,\n                letterSpacing: \"-0.01em\",\n                color: pal.muted,\n              }}\n            >\n              {label}\n            </div>\n          </div>\n        ) : null}\n      </AbsoluteFill>\n      <svg\n        width=\"100%\"\n        height=\"100%\"\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          opacity: pal.grain,\n          pointerEvents: \"none\",\n        }}\n        aria-hidden\n      >\n        <filter id={`${uid}-grain`}>\n          <feTurbulence\n            type=\"fractalNoise\"\n            baseFrequency=\"0.9\"\n            numOctaves={2}\n            seed={21}\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(#${uid}-grain)`} />\n      </svg>\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/raster-paint.tsx"
    }
  ],
  "type": "registry:component"
}
