{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "moire-reveal",
  "title": "Moire Reveal",
  "description": "A big 10x resolves out of a moire line pattern with a small pill caption.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/moire-reveal/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadGeist } from \"@remotion/google-fonts/Geist\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: geist } = loadGeist(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\n\nexport interface MoireRevealProps {\n  value?: string;\n  shape?: \"text\" | \"mark\";\n  caption?: 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 TURN_END = 86;\nconst START_ANGLE = 11;\nconst DRIFT = 3;\nconst LOCK_AT = 100;\nconst LOCK_END = 114;\nconst CAPTION_AT = 110;\n\nconst TURN = Easing.bezier(0.3, 0.15, 0.25, 1);\nconst LOCK = Easing.bezier(0.5, 0, 0.1, 1);\nconst SETTLE = Easing.bezier(0.22, 1, 0.36, 1);\n\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    fg: \"#F3F2EF\",\n    line: \"#D9D8DD\",\n    lineAlpha: 0.72,\n    muted: \"#8B8A90\",\n    hair: \"rgba(255,255,255,0.14)\",\n    grain: 0.05,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    line: \"#2A2A2E\",\n    lineAlpha: 0.8,\n    muted: \"#6E6C67\",\n    hair: \"rgba(18,18,20,0.16)\",\n    grain: 0.035,\n  },\n} as const;\n\n/** gradients.sh \"beam\" palette, re-stopped per stage so every stop reads on the ground. */\nconst BEAM = {\n  dark: [\"#F4F7FF\", \"#8FB4FF\", \"#3D5BFF\", \"#4B3FD6\"],\n  light: [\"#1A1660\", \"#3D5BFF\", \"#5A72FF\", \"#7F95FF\"],\n} as const;\n\n/** The remocn.dev \"R\" mark (viewBox 124.06 × 134.26). */\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/** Advance widths (em) for Geist 500 (proportional figures), -0.035em tracking. */\nfunction widthEm(text: string) {\n  let w = 0;\n  for (const ch of text) {\n    if (ch === \" \") w += 0.24;\n    else if (\"ijlI.,:;'!|\".includes(ch)) w += 0.25;\n    else if (\"ftr\".includes(ch)) w += 0.36;\n    else if (\"mwMW%\".includes(ch)) w += 0.82;\n    else if (ch === \"1\") w += 0.42;\n    else if (ch >= \"0\" && ch <= \"9\") w += 0.6;\n    else if (ch >= \"A\" && ch <= \"Z\") w += 0.64;\n    else w += 0.56;\n    w -= 0.035;\n  }\n  return Math.max(w, 0.5);\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={4}\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 Lines({\n  pitch,\n  weight,\n  span,\n  phase,\n  fill,\n}: {\n  pitch: number;\n  weight: number;\n  span: number;\n  phase: number;\n  fill: string;\n}) {\n  const count = Math.ceil(span / pitch) + 4;\n  const first = -Math.ceil(count / 2);\n  const rows = [];\n  for (let k = 0; k < count; k++) {\n    const y = (first + k) * pitch + phase - weight / 2;\n    rows.push(\n      <rect\n        key={k}\n        x={-span / 2}\n        y={y}\n        width={span}\n        height={weight}\n        fill={fill}\n      />,\n    );\n  }\n  return <>{rows}</>;\n}\n\nexport function MoireReveal({\n  value = \"10×\",\n  shape = \"text\",\n  caption = \"faster first frame on remocn render\",\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: MoireRevealProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = H / 720;\n  const stage = THEMES[theme];\n  const raw = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const clipId = `mc${raw}`;\n  const maskId = `mm${raw}`;\n  const gradId = `mg${raw}`;\n  const beam = BEAM[theme];\n\n  const pitch = 7 * u;\n  const weight = Math.max(1, 1.25 * u);\n  const span = Math.hypot(W, H) + 8 * pitch;\n  const cx = W / 2;\n  const cy = H * 0.43;\n\n  const turn = TURN(interpolate(t, [0, TURN_END], [0, 1], CLAMP));\n  const angle = START_ANGLE * (1 - turn);\n  const phase = DRIFT * pitch * turn;\n  const detune = TURN(interpolate(t, [32, TURN_END - 4], [0, 1], CLAMP));\n  const inner = pitch * (1 + 0.1 * detune);\n  const lock = LOCK(interpolate(t, [LOCK_AT, LOCK_END], [0, 1], CLAMP));\n  const locked = t >= LOCK_AT;\n  const innerWeight = weight + (inner * 0.66 - weight) * lock;\n  const fieldDim = interpolate(\n    t,\n    [LOCK_AT + 4, LOCK_END + 10],\n    [1, theme === \"dark\" ? 0.34 : 0.3],\n    CLAMP,\n  );\n\n  const capIn = SETTLE(\n    interpolate(t, [CAPTION_AT, CAPTION_AT + 20], [0, 1], CLAMP),\n  );\n  const capSize = Math.max(15, 22 * u);\n\n  let shapeNode: React.ReactNode;\n  let shapeTop: number;\n  let shapeBottom: number;\n  let shapeW: number;\n  if (shape === \"mark\") {\n    const hgt = 0.5 * H;\n    const k = hgt / 134.26;\n    shapeW = 124.06 * k;\n    shapeTop = cy - hgt / 2;\n    shapeBottom = cy + hgt / 2;\n    shapeNode = (\n      <path\n        d={REMOCN_R_PATH}\n        transform={`translate(${cx - shapeW / 2} ${shapeTop}) scale(${k})`}\n      />\n    );\n  } else {\n    const size = Math.min(480 * u, (0.74 * W) / widthEm(value));\n    const baseline = cy + 0.36 * size;\n    shapeW = widthEm(value) * size;\n    shapeTop = baseline - 0.72 * size;\n    shapeBottom = baseline;\n    shapeNode = (\n      <text\n        x={cx}\n        y={baseline}\n        textAnchor=\"middle\"\n        fontFamily={geist}\n        fontWeight={500}\n        fontSize={size}\n        letterSpacing={`${-0.035 * size}px`}\n      >\n        {value}\n      </text>\n    );\n  }\n\n  // The beam gradient runs diagonally across the hero shape; its axis\n  // drifts a few degrees over the shot, never more. Coordinates live in the\n  // line group's space (translated to the centre; the angle is 0 once locked).\n  const drift = interpolate(t, [0, 150], [-6, 6]);\n  const gAng = ((128 + drift) * Math.PI) / 180;\n  const gLen = Math.hypot(shapeW, shapeBottom - shapeTop) / 2;\n  const gcy = (shapeTop + shapeBottom) / 2;\n  const gx = Math.cos(gAng) * gLen;\n  const gy = Math.sin(gAng) * gLen;\n\n  const rot = `translate(${cx} ${cy}) rotate(${angle})`;\n  const flat = `translate(${cx} ${cy})`;\n  const capTop = Math.min(shapeBottom + 70 * u, H * 0.84 - capSize);\n  const capW = caption ? Math.min(0.8 * W, caption.length * capSize * 0.56) : 0;\n  const plateW = capW + 68 * u;\n  const plateH = capSize + 28 * u;\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          <clipPath id={clipId}>{shapeNode}</clipPath>\n          <mask id={maskId} maskUnits=\"userSpaceOnUse\">\n            <rect x={0} y={0} width={W} height={H} fill=\"#fff\" />\n            <g fill=\"#000\">{shapeNode}</g>\n          </mask>\n          <linearGradient\n            id={gradId}\n            gradientUnits=\"userSpaceOnUse\"\n            x1={-gx}\n            y1={gcy - cy - gy}\n            x2={gx}\n            y2={gcy - cy + gy}\n          >\n            <stop offset=\"0\" stopColor={beam[0]} />\n            <stop offset=\"0.34\" stopColor={beam[1]} />\n            <stop offset=\"0.68\" stopColor={beam[2]} />\n            <stop offset=\"1\" stopColor={beam[3]} />\n          </linearGradient>\n        </defs>\n        <g opacity={fieldDim * stage.lineAlpha}>\n          <g transform={flat}>\n            <Lines\n              pitch={pitch}\n              weight={weight}\n              span={span}\n              phase={0}\n              fill={stage.line}\n            />\n          </g>\n          <g mask={`url(#${maskId})`}>\n            <g transform={rot}>\n              <Lines\n                pitch={pitch}\n                weight={weight}\n                span={span}\n                phase={phase}\n                fill={stage.line}\n              />\n            </g>\n          </g>\n        </g>\n        <g clipPath={`url(#${clipId})`}>\n          {locked ? (\n            <rect\n              x={0}\n              y={0}\n              width={W}\n              height={H}\n              fill={stage.bg}\n              opacity={lock}\n            />\n          ) : null}\n          <g opacity={locked ? 1 : fieldDim * stage.lineAlpha}>\n            <g transform={rot}>\n              <Lines\n                pitch={inner}\n                weight={innerWeight}\n                span={span}\n                phase={(phase * inner) / pitch}\n                fill={stage.line}\n              />\n            </g>\n            {locked ? (\n              <g transform={rot} opacity={lock}>\n                <Lines\n                  pitch={inner}\n                  weight={innerWeight}\n                  span={span}\n                  phase={(phase * inner) / pitch}\n                  fill={`url(#${gradId})`}\n                />\n              </g>\n            ) : null}\n          </g>\n        </g>\n      </svg>\n      {caption ? (\n        <div\n          style={{\n            position: \"absolute\",\n            left: cx - plateW / 2,\n            top: capTop - 13 * u,\n            width: plateW,\n            height: plateH,\n            background: stage.bg,\n            boxShadow: `inset 0 0 0 ${Math.max(1, u)}px ${stage.hair}`,\n            borderRadius: plateH / 2,\n            display: \"flex\",\n            alignItems: \"center\",\n            justifyContent: \"center\",\n            fontFamily: geist,\n            fontWeight: 400,\n            fontSize: capSize,\n            letterSpacing: \"-0.015em\",\n            whiteSpace: \"nowrap\",\n            color: stage.fg,\n            opacity: capIn,\n            transform: `translateY(${(1 - capIn) * 12 * u}px)`,\n          }}\n        >\n          <span\n            style={{\n              width: 8 * u,\n              height: 8 * u,\n              borderRadius: \"50%\",\n              background: accent,\n              marginRight: 12 * u,\n              flexShrink: 0,\n            }}\n          />\n          {caption}\n        </div>\n      ) : null}\n      <Grain opacity={stage.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/moire-reveal.tsx"
    }
  ],
  "type": "registry:component"
}
