Search documentation

Find a vivid-layer page or product.

Color Dithering

Ordered colour dithering with palettes, blue noise and coloured dots on transparent paper.

pnpm dlx shadcn@latest add @vivid-layer/color-dithering
Source image

JPEG, PNG, or WebP. Your image stays in this browser.

Customize

Pixel Size
2
Spread
0.9
Levels
5
Dot Scale
0.75
Paper Opacity
1
Brightness
0.02
Contrast
0.95
Saturation
1
Scale
1

API reference

The component dithers an image on a WebGL2 canvas in linear light: every cell is averaged from the source, quantised to display tones or a palette, and the choice between the two nearest tones follows the threshold pattern, so mixed areas average to the tone they stand in for. It renders once per change.

PropTypeDefaultDescription
imagestringrequiredA project image URL, data URL, or local blob URL. Remote servers must allow anonymous CORS image loading.
width / heightnumber | string"100%"CSS dimensions. Give the parent an explicit height.
className / stylestring / CSSProperties—Styles the outer container.
fit"cover" | "contain""cover"Fits and centers the image within the container.
scalenumber1Image zoom around the centre. The playground provides a range of 0.1–4.
algorithm"bayer-2x2" | "bayer-4x4" | "bayer-8x8" | "blue-noise" | "white-noise""bayer-4x4"The threshold pattern. Bayer matrices give the classic regular screen; blue noise (void-and-cluster, three independent 64×64 maps) is even and free of patterns; white noise is grainy.
pixelSizenumber2Cell size in CSS pixels, 1–24. Cells are aligned to whole device pixels.
spreadnumber0.5Dither strength, 0–1: 0 posterizes, 1 is full ordered dithering.
levelsnumber4Tones per RGB channel, 2–16, when no palette is set.
colorsstring[][]Up to 16 palette colours. Each pixel is dithered between its two nearest palette colours in Oklab; an empty list keeps the source colours.
chromaticSplitbooleanfalseOffsets the threshold pattern per channel to produce coloured dots. Ignored with a palette.
dotScalenumber1Dot coverage inside each cell, 0.1–1. Below 1, paper shows between the dots.
paperColorstring"#000000"Colour of the paper between dots.
paperOpacitynumber0Paper opacity, 0–1. At 0 the gaps are transparent and show what sits behind the canvas.
brightness / contrast / saturationnumber0 / 1 / 1Adjustments applied before dithering.
onError(error: Error) => void—Reports a missing WebGL2 context or an image-loading failure. The component hides the failed canvas and supplies no replacement image.

Newsprint is the print look from the Vivid Layer footer: a fine coloured screen with paper between the dots. Chromatic keeps the source colours with split RGB dots, Blue Noise the same tones without a visible pattern. Risograph and Game Boy are palette presets; swap in your own colours.

Credits

The default photograph is Jeremy Bishop's Monument Valley, used under the Unsplash License.