The live demo starts when it’s in view.Click for sparkles · drag the line to compare with the vector drawing
Draw with ordinary Canvas 2D calls (circles, gradients, paths) at a low resolution, and get true pixel art.
What it costs a frame
CPU
2.31 ms
02468101216.7 ms
GPU
not used
CPU, median
2.31 ms
CPU, 95th pct
4.91 ms
Draw calls
0
Weight
Heavy
Measured 13 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged CPU 2.25–2.35 ms). What ran: Measured with the world stepping at 12 frames a second and a burst of 28 particles every 0.7 s (they move every frame), so the frames hold the drawing of the three planes at art resolution, the composite (ordered dither, palette snap and outline over about 130,000 art pixels a plane at 1920×1080 with 4 px art pixels) and the vector half of the comparison. At rest nothing is drawn. Phones: tiers are being measured next.
apple · Apple A19 Proin a browser tab · 16 November 2026
not timed
3.62
8.08
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026
not timed
1.79
3.67
Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.
What it needs
Renders with
Canvas 2DA 2D canvas: every current browser.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages
What it’s for
Retro and playful themes
Game menus and HUDs in pixel art
Pixel-art backgrounds behind a DOM interface
Turning vector drawings into pixel art
Limited-palette effects (two inks, four greens)
Pixel banners and titles
Pitfalls, in brief
Pixel art needs every art pixel to be a whole number of device pixels, or columns come out one pixel wider than their neighbours.
Put the layer at a whole device pixel.
Each render reads the planes back with getImageData: keep the art resolution low (an art pixel of 3 px or more), render only when something changed, and pass render(from) the first plane that changed, so a still background is reused.
Planes are 2D contexts made with willReadFrequently, so they live on the CPU: draw on them with the usual calls, but do not draw a large image onto them every frame.
Resizing the host clears the planes (their canvases change size): redraw them in onResize, or the next render shows an empty picture.
3 more in brief
Snapping to a palette uses a 15-bit table (5 bits a channel): two palette colours closer than about 8 levels in every channel can map to the same entry.
Text in the picture is decoration.
The demo moves the world in steps (12 a second) like sprite animation, and stops under reduced motion; particles still move every frame while they live.
8 pitfalls in full, the hook-up guide, the module source and its tests come with the part.
Where it comes from
From HaTac. Fully custom code.
Bryce Bayer (1973): the ordered-dither threshold matrices (4×4 and 8×8)
Thiadmer Riemersma, “Colour metric” (CompuPhase): the red-mean weighted colour distance used to find the nearest palette colour
Crisp text at 2% or 6400%: glyphs rasterised on first use with Canvas 2D, turned into signed distance fields by an exact distance transform, packed into one…