{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ruler-scrub",
  "title": "Ruler Scrub",
  "description": "A ruler scrubs past ticks until the year 2026 lands in a gradient numeral.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/ruler-scrub/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } 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: sans } = loadFont(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\nconst display = sans;\n\nexport interface RulerScrubProps {\n  from?: number;\n  to?: number;\n  step?: number;\n  format?: string | ((value: number) => 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 CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst SCRUB_END = 70;\nconst SUBDIV = 10;\n\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    stage: \"rgba(255,255,255,0.05)\",\n    fg: \"#F3F2EF\",\n    muted: \"#85848A\",\n    faint: \"#46464C\",\n    major: \"rgba(243,242,239,0.7)\",\n    minor: \"rgba(243,242,239,0.26)\",\n    future: 0.4,\n    grain: 0.065,\n    hero: (a: number) =>\n      `linear-gradient(${172 + a}deg, #fbeee4 0%, #f3d6c0 22%, #b9a6ff 58%, #8a7bff 78%, #5a5ef0 100%)`,\n    glow: [\n      \"color-mix(in oklab, #8a7bff 16%, transparent)\",\n      \"color-mix(in oklab, #3b3fd8 22%, transparent)\",\n    ],\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    stage: \"rgba(255,255,255,0.9)\",\n    fg: \"#121214\",\n    muted: \"#6E6C67\",\n    faint: \"#B9B6AE\",\n    major: \"rgba(18,18,20,0.66)\",\n    minor: \"rgba(18,18,20,0.24)\",\n    future: 0.45,\n    grain: 0.045,\n    hero: (a: number) =>\n      `linear-gradient(${155 + a}deg, #7a5cff 0%, #b04cd9 30%, #ff3d9a 62%, #ff8a3d 100%)`,\n    glow: [\n      \"color-mix(in oklab, #ff8a3d 10%, transparent)\",\n      \"color-mix(in oklab, #7a5cff 12%, transparent)\",\n    ],\n  },\n} as const;\n\ntype Palette = (typeof THEMES)[keyof typeof THEMES];\n\nfunction decimalsOf(step: number) {\n  const s = String(step);\n  const i = s.indexOf(\".\");\n  return i < 0 ? 0 : Math.min(4, s.length - i - 1);\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={31}\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 Ticks({\n  pos,\n  steps,\n  gap,\n  width,\n  u,\n  h,\n  p,\n  accent,\n  text,\n  centerLit,\n  heroOut,\n  labelSize,\n}: {\n  pos: number;\n  steps: number;\n  gap: number;\n  width: number;\n  u: number;\n  h: number;\n  p: Palette;\n  accent: string;\n  text: (i: number) => string;\n  centerLit: number;\n  heroOut: number;\n  labelSize: number;\n}) {\n  const span = width / 2 / gap + 1;\n  const first = Math.floor((pos - span) * SUBDIV);\n  const last = Math.ceil((pos + span) * SUBDIV);\n  const lines: React.ReactNode[] = [];\n  const labels: React.ReactNode[] = [];\n  for (let k = first; k <= last; k++) {\n    const x = width / 2 + (k / SUBDIV - pos) * gap;\n    const major = k % SUBDIV === 0;\n    const mid = !major && k % (SUBDIV / 2) === 0;\n    const len = h * (major ? 0.075 : mid ? 0.048 : 0.028);\n    const future = k / SUBDIV > steps + 1e-6 ? p.future : 1;\n    const isHero = k === steps * SUBDIV;\n    const lit = isHero ? centerLit : 0;\n    lines.push(\n      <line\n        key={k}\n        x1={x}\n        x2={x}\n        y1={0}\n        y2={-len * (1 + lit * 0.35)}\n        stroke={lit > 0.5 ? accent : major ? p.major : p.minor}\n        strokeWidth={(major ? 1.75 : 1.1) * u * (1 + lit * 0.4)}\n        opacity={future}\n      />,\n    );\n    if (major) {\n      const i = k / SUBDIV;\n      labels.push(\n        <div\n          key={`t${k}`}\n          style={{\n            position: \"absolute\",\n            left: x - gap / 2,\n            width: gap,\n            top: -h * 0.098 - labelSize,\n            textAlign: \"center\",\n            fontFamily: sans,\n            fontWeight: 500,\n            fontSize: labelSize,\n            lineHeight: 1,\n            letterSpacing: \"-0.005em\",\n            fontVariantNumeric: \"tabular-nums\",\n            color: isHero ? p.fg : p.muted,\n            opacity: future * (isHero ? 1 - heroOut : 1),\n          }}\n        >\n          {text(i)}\n        </div>,\n      );\n    }\n  }\n  return (\n    <>\n      <svg\n        width={width}\n        height={h * 0.12}\n        viewBox={`0 ${-h * 0.12} ${width} ${h * 0.12}`}\n        style={{\n          position: \"absolute\",\n          left: 0,\n          top: -h * 0.12,\n          overflow: \"visible\",\n        }}\n        aria-hidden\n      >\n        {lines}\n      </svg>\n      {labels}\n    </>\n  );\n}\n\nexport function RulerScrub({\n  from = 2012,\n  to = 2026,\n  step = 1,\n  format = \"{value}\",\n  label = \"The year launch videos became code\",\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: RulerScrubProps) {\n  const t = useCurrentFrame() * speed;\n  const { width, height } = useVideoConfig();\n  const u = height / 720;\n  const p: Palette = THEMES[theme];\n  const inc = step > 0 ? step : 1;\n  const steps = Math.max(1, Math.round((to - from) / inc));\n  const dec = decimalsOf(inc);\n  const fmt = (v: number) => {\n    const n = v.toFixed(dec);\n    return typeof format === \"function\"\n      ? format(Number(n))\n      : format.replace(\"{value}\", n);\n  };\n  const text = (i: number) => fmt(from + i * inc);\n\n  const gap = Math.max(width * 0.115, 96 * u);\n  const scrubAt = (f: number) => {\n    const x = Math.min(1, Math.max(0, f / SCRUB_END));\n    const main = (1 - (1 - x) ** 3) * 0.93 + x * 0.07;\n    if (f <= SCRUB_END) return steps * main;\n    const dt = f - SCRUB_END;\n    const v0 = (0.07 * steps) / SCRUB_END;\n    return steps + (v0 / 0.9) * Math.sin(dt * 0.9) * Math.exp(-dt * 0.5);\n  };\n  const pos = scrubAt(t);\n  const vel = (scrubAt(t) - scrubAt(t - 1)) * gap;\n  const ghost = interpolate(Math.abs(vel), [8 * u, 60 * u], [0, 1], CLAMP);\n\n  const lift = interpolate(t, [SCRUB_END + 6, SCRUB_END + 38], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const rulerY = interpolate(lift, [0, 1], [height * 0.56, height * 0.68]);\n  const centerLit = interpolate(\n    t,\n    [SCRUB_END - 4, SCRUB_END + 2],\n    [0, 1],\n    CLAMP,\n  );\n  const heroOut = interpolate(lift, [0, 0.06], [0, 1], CLAMP);\n  const enter = interpolate(t, [0, 10], [0, 1], { ...CLAMP, easing: EASE_OUT });\n  const flash = interpolate(\n    t,\n    [SCRUB_END - 2, SCRUB_END + 1, SCRUB_END + 14],\n    [0, 1, 0],\n    CLAMP,\n  );\n  const blur = Math.min(8 * u, Math.max(0, Math.abs(vel) - 6 * u) * 0.11);\n  const blurId = `b${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n\n  const labelSize = 21 * u;\n  const heroSize = Math.min(height * 0.34, width * 0.2);\n  const heroScale0 = labelSize / heroSize;\n  const heroStartY = rulerY - height * 0.098 - labelSize * 0.5;\n  const heroEndY = height * 0.34;\n  const heroY = interpolate(lift, [0, 1], [heroStartY, heroEndY]);\n  const heroScale =\n    interpolate(lift, [0, 1], [heroScale0, 1]) *\n    interpolate(t, [SCRUB_END + 38, SCRUB_END + 110], [1, 1.02], CLAMP);\n  const heroWeight = interpolate(lift, [0, 1], [450, 500]);\n  const sheen = interpolate(t, [SCRUB_END, SCRUB_END + 110], [-4, 4], CLAMP);\n\n  const markTop = -height * 0.075 * (1 + centerLit * 0.35) - 6 * u;\n  const markBottom = height * 0.034;\n\n  const labelIn = interpolate(t, [SCRUB_END + 30, SCRUB_END + 54], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n\n  const ghosts = [0.5, 1];\n  const fade =\n    \"linear-gradient(90deg, transparent 0%, #000 22%, #000 78%, transparent 100%)\";\n  const tickProps = {\n    pos,\n    steps,\n    gap,\n    width,\n    u,\n    h: height,\n    p,\n    accent,\n    text,\n    labelSize,\n  };\n\n  return (\n    <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{\n          background: [\n            `radial-gradient(ellipse 42% 46% at ${46 + sheen}% ${36 - 6 * (1 - lift)}%, ${p.glow[0]}, transparent 72%)`,\n            `radial-gradient(ellipse 70% 50% at 50% 100%, ${p.glow[1]}, transparent 72%)`,\n            `radial-gradient(ellipse 60% 60% at 50% 48%, ${p.stage}, transparent 75%)`,\n          ].join(\", \"),\n        }}\n      />\n      <svg width={0} height={0} style={{ position: \"absolute\" }} aria-hidden>\n        <filter id={blurId} x=\"-10%\" y=\"-10%\" width=\"120%\" height=\"120%\">\n          <feGaussianBlur stdDeviation={`${blur} 0`} />\n        </filter>\n      </svg>\n      <div\n        style={{\n          position: \"absolute\",\n          left: 0,\n          top: rulerY - height * 0.25,\n          width,\n          height: height * 0.3,\n          opacity: enter,\n          maskImage: fade,\n          WebkitMaskImage: fade,\n        }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            left: 0,\n            top: height * 0.25,\n            width,\n            height: Math.max(1, u),\n            background: p.minor,\n          }}\n        />\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            filter: blur > 0.4 ? `url(#${blurId})` : undefined,\n          }}\n        >\n          <div style={{ position: \"absolute\", left: 0, top: height * 0.25 }}>\n            {ghosts.map((g) =>\n              ghost > 0.01 ? (\n                <div\n                  key={g}\n                  style={{\n                    position: \"absolute\",\n                    left: 0,\n                    top: 0,\n                    opacity: ghost * 0.22 * (1.25 - g),\n                    transform: `translateX(${vel * g * 0.7}px)`,\n                  }}\n                >\n                  <Ticks {...tickProps} centerLit={0} heroOut={0} />\n                </div>\n              ) : null,\n            )}\n            <div style={{ position: \"absolute\", left: 0, top: 0 }}>\n              <Ticks {...tickProps} centerLit={centerLit} heroOut={heroOut} />\n            </div>\n          </div>\n        </div>\n      </div>\n\n      <div\n        style={{\n          position: \"absolute\",\n          left: width / 2 - u,\n          top: rulerY + markTop,\n          width: 2 * u,\n          height: markBottom - markTop,\n          background: accent,\n          borderRadius: u,\n          opacity: enter,\n        }}\n      />\n      <div\n        style={{\n          position: \"absolute\",\n          left: width / 2 - 4.5 * u,\n          top: rulerY + markBottom - 4.5 * u,\n          width: 9 * u,\n          height: 9 * u,\n          borderRadius: 9 * u,\n          background: accent,\n          opacity: enter,\n          boxShadow: `0 0 0 ${flash * 7 * u}px ${accent}2E`,\n        }}\n      />\n\n      <div\n        style={{\n          position: \"absolute\",\n          left: 0,\n          width,\n          top: heroY,\n          height: 0,\n          display: \"flex\",\n          justifyContent: \"center\",\n          alignItems: \"center\",\n          opacity: heroOut,\n        }}\n      >\n        <div\n          style={{\n            fontFamily: display,\n            fontWeight: heroWeight,\n            fontSize: heroSize,\n            lineHeight: 1,\n            letterSpacing: `${interpolate(lift, [0, 1], [-0.005, -0.05])}em`,\n            fontVariantNumeric: \"tabular-nums\",\n            color: \"transparent\",\n            backgroundImage: p.hero(sheen),\n            WebkitBackgroundClip: \"text\",\n            backgroundClip: \"text\",\n            padding: \"0.08em 0.06em\",\n            whiteSpace: \"nowrap\",\n            transform: `scale(${heroScale})`,\n          }}\n        >\n          {text(steps)}\n        </div>\n      </div>\n\n      <div\n        style={{\n          position: \"absolute\",\n          left: 0,\n          width,\n          top: height * 0.83,\n          display: \"flex\",\n          justifyContent: \"center\",\n          fontFamily: sans,\n          fontWeight: 400,\n          fontSize: 28 * u,\n          letterSpacing: \"-0.015em\",\n          color: p.fg,\n          opacity: labelIn,\n          transform: `translateY(${(1 - labelIn) * 14 * u}px)`,\n        }}\n      >\n        {label}\n      </div>\n      <Grain opacity={p.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/ruler-scrub.tsx"
    }
  ],
  "type": "registry:component"
}
