#17

feat: icon — SVG→dither compiler (Bayer entrance, controlled progress)

OpenDloomPlzwants to merge intofrom

Summary

Adds <DitherIcon> — an SVG→dither compiler. Give it any SVG icon component (a lucide icon, a logo): it serializes the SVG, rasterizes it at cell resolution on an offscreen canvas, reads the alpha channel, and re-emits it through the ordered-dither texture the rest of the kit is made of.

<DitherIcon icon={Wallet} color="blue" size={40} />
<DitherIcon icon={Wallet} size={40} cell={2} strokeWidth={2.5} />  // chunky pixel-art
<DitherIcon icon={Wallet} progress={scrollProgress} />             // scroll-linked reveal
  • Bayer materialize entrance — cells sweep in with the same matrix the texture dithers with (same recipe as the avatar).
  • Controlled progress (0–1) — overrides the entrance for scroll-linked reveals; an in-flight entrance yields the moment progress arrives.
  • Density caps at 0.85 so solid fills keep the texture (a saturated cell map would just be a flat icon).
  • Colours are irrelevant to compilation — currentColor is pinned before serializing; only coverage matters, so anti-aliased edges dither out naturally.
  • Standalone item like avatar/button/gradient (pixel.ts + palette.ts only). Canvas backing is sized once per compiled model, never per frame. Honors prefers-reduced-motion; decorative by default (ariaLabel={null} → aria-hidden), role="img" when labeled.

Details

  • alphaToDensity exported + unit-tested; mount tests pin the labeled/decorative aria contract with a dependency-free inline SVG (happy-dom safe — sampling no-ops without a real canvas).
  • Registry item + barrel export + COMPONENTS.md sections; r/ JSON regenerated.
  • Suite: 30/30.

Activity

2
tripwire-dev[bot]4mo ago

passed — nothing tripped. good to merge.