Components / Animations / Bitmap Image
Bitmap Image
An image thresholded into newsprint. The source is box-filtered down to the cell grid first, so every cell has a real antialiased grey before it is dithered — which is the difference between newsprint and broken JPEG.
Model
(v) => String(v.dither).startsWith("bayer") ? "out = level(tone + (M(x, y)/n² − ½)/levels)" : v.dither === "none" ? "out = round(tone · (levels − 1)) / (levels − 1)" : "e = tone − out; e spreads to unvisited neighbours by the kernel’s weights"M the Bayer matrix, n its size · error diffusion carries each cell’s rounding error forward, so tone is conserved over area
Props
| Property | Type | Default | Description |
|---|---|---|---|
cell | number | 4 | Pixels per cell. Smaller is finer and costs more per frame. |
levels | number | 2 | Tone steps. 2 is one-bit; higher posterises. |
dither | DitherKernel | 'floyd' | What turns tone into dots: bayer2 to bayer16 are fixed patterns that hold still, floyd, atkinson and jarvis diffuse the error and follow the picture more closely but can crawl as it changes, none just posterises. |
ditherAmount | number | 1 | 0 passes the tone through untouched, 1 applies the kernel in full. |
serpentine | boolean | true | Alternate scan direction. Error-diffusion kernels only. |
contrast | number | 1.1 | Stretch of the tones around mid-grey before dithering. 1 leaves them alone, above 1 is harder, below 1 is flatter. |
brightness | number | 0 | Added to every tone before dithering. 0 leaves them alone. |
invert | boolean | false | Swaps lit and unlit cells. |
warp | number | 0 | Flow-field shear, in cells. |
cursorRadius | number | 160 | Reach of the pointer's influence, in px. |
cursorStrength | number | 0 | Outward push at the centre of that reach, in px. |
cursorLift | number | 0 | Luminance added at the centre of that reach. |
color | string | '#e8e4dc' | Colour of the lit cells. |
background | string | null | '#0a0b0e' | null renders transparent. |
paused | boolean | false | Stops the frame loop without unmounting. |
respectReducedMotion | boolean | true | Honour prefers-reduced-motion, and keep honouring it if it changes. |
fullscreen | boolean | false | Position the field to the viewport rather than its container. |
src | string | — | Address of the picture. One from another origin needs CORS headers, or it cannot be read and onStatus reports tainted. |
alt | string | '' | As on <img>: describe the picture, or leave empty to mark it decorative. |
fit | 'cover' | 'contain' | 'fill' | 'cover' | cover fills the box and crops the overflow, contain shows the whole picture and leaves the rest empty, fill stretches it to the box. |
focusX | number | 0.5 | Crop anchor, 0..1. |
focusY | number | 0.5 | Crop anchor on the vertical axis, 0..1. |
onStatus | (status: 'ready' | 'empty' | 'tainted') => void | — | Reports ready when there is a picture to draw, empty when there is not (no src, or it failed to load), and tainted when the picture is cross-origin without CORS and cannot be read. |