Backgrounds
Dither
A live field crushed to one bit through an ordered threshold matrix. The only background here that looks better the cheaper it gets, and the only one that runs the same on a decade-old laptop as on a workstation.
Install
bun add oglThen copy 2 files into your project:
- components/registry/dither/dither.tsx
- hooks/use-animation-loop.ts
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| pattern | "bayer2" | "bayer4" | "bayer8" | "halftone" | "noise" | "bayer8" | Which threshold matrix decides each cell. Bayer is the ordered one — a fixed lattice, so the texture is stable and never crawls between frames. Halftone rotates the grid forty-five degrees and clusters instead of scattering, which is what a printing press does. Noise drops the lattice entirely and pays for it with a pattern that shimmers the moment anything moves. |
| levels | number | 2 | Tones per channel after quantisation. Two is the honest one-bit case. Above four this stops being dithering and starts being a slightly cheap gradient — worth dragging once to see exactly where the effect stops earning its name. |
| pixelSize | number | 3 | Size of one dither cell, held in CSS pixels rather than device pixels. Held in device pixels the grid would halve on a retina screen and the effect would vanish on exactly the displays people judge it on. |
| field | "plasma" | "ridges" | "tunnel" | "drift" | "plasma" | What is being quantised underneath. The dither is indifferent to it — that is the point of a threshold matrix — but the four differ sharply in how much smooth gradient they hand it, and a pattern only shows its character on a gradient. |
| fieldSpeed | number | 0.3 | Rate the field evolves. At zero it parks, which is the clearest way to see the threshold matrix itself rather than the image passing through it. |
| fieldScale | number | 2.4 | Size of the field's features relative to the container. Small enough and the whole panel is one tone with nothing for the dither to resolve; large enough and every cell disagrees with its neighbour and the pattern turns to static. |
| frameHold | number | 0 | How many frames the field is held before it advances. Zero runs at display rate; three gives the deliberate stutter of a machine that could not keep up. The frame is still drawn either way and the held time is spent in one go when the hold expires — so this is a look, not a saving, and not a speed control in disguise. |
| contrast | number | 1 | Contrast applied around mid-grey before quantisation. This is the real control over how much of the field survives: at two levels there is exactly one threshold, so pushing contrast up does not brighten the image, it decides where the edge between black and white falls. |
| inkColor | string (hex) | "#e8e4d8" | The colour a lit cell takes. Warm off-white rather than pure white on purpose — a true #ffffff against near-black is the one pairing that makes the grid buzz. |
| paperColor | string (hex) | "#0b0b0d" | The colour an unlit cell takes. |
What It Demonstrates
- Loop
- An animation that repeats, a set number of times or infinitely.
- Stepped animation
- An animation that is divided into discrete steps, like a countdown timer.
- Idle animation
- Subtle motion that plays while an element is just sitting there, waiting to be interacted with.
- Compositing
- Letting the GPU move or fade an element on its own layer without redoing layout or paint.
- Hardware acceleration
- Animating transform and opacity lets the GPU keep motion smooth.
Related Components
Quicksilver
Molten chrome. Every other shader background emits light. This one reflects a studio that does not exist, built out of the surface normal: sharp softbox edges, a conductor's Fresnel wash, thin-film iridescence, and a wake that keeps moving where you dragged.
Mycelium
A slime mould foraging in the dark. Every other field here is a differential equation on a grid. This one is a population: up to a million agents, each carrying a position and a heading, sampling the trail ahead of itself, turning toward whatever smells strongest and laying down more of it as it goes. The veins, the junctions and the slow reorganisation are nowhere in the code.
Rainglass
Rain on a window with a city somewhere behind it. There is no scene being blurred. The backdrop is built out of focus to begin with, so the drops have something to bend without a render target or a blur pass anywhere in the frame. Each drop is a pure function of time inside its own grid cell, which is why a thousand of them cost the same as one and a resize cannot lose the rain. They descend the way water actually does: holding by surface tension, breaking loose, running fast, stopping again. The trail exists only above the drop that made it.
Waves
A woven field of flowing waves rendered on a WebGL line shader.
Grainient
An animated grainy mesh-gradient rendered on a WebGL2 shader.
Cathode
A cathode-ray tube slowed down until you can watch it work: the beam paints a test card line by line, and the phosphor it leaves behind fades until the next pass comes round.