
Dither Haze
A drifting haze of dithered ink for plain page backgrounds.
This browser cannot run WebGL2, so this is a still image. The code below works wherever WebGL2 is available.
Code
The usage always matches the preview, layers and performance settings included. No build step or package.
Copy embed gives one block to paste into any page or site builder, no setup. For your own code: add dither-haze.js, ittybitty-shader.js, runtime.js, glyphs.js, pointer.js, texture.js next to this page. Highlighted values follow the controls.
<!-- Quickest: one element. Size it with CSS; it fills its box. -->
<script type="module" src="./ittybitty-shader.js"></script>
<ittybitty-shader effect="dither-haze" style="position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="dither-haze" aria-hidden="true" style="position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1"></canvas>
<script type="module">
import { ditherHaze } from './dither-haze.js';
const canvas = document.getElementById('dither-haze');
const effect = ditherHaze(canvas, {
showBackground: true,
speed: 0.15,
density: 0.2,
variation: 0.8,
scale: 1,
pixel: 2,
pattern: 'noise',
interactive: true,
responsiveness: 0.5,
ink: '#bdb6a8',
background: '#f5f4f1',
// Performance
dpr: 2,
adaptive: true,
});
// Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
An almost flat background, scattered with dithered ink whose density drifts like weather: thick in places, gone in others. It gives a page texture and depth without competing with content, and runs at 20 frames a second because nothing faster would show.
- Payload
- 6.5 KB brotli for dither-haze.js and ittybitty-shader.js and runtime.js and glyphs.js and pointer.js and texture.js, measured at build time. See the method.
- Resolution
- Device pixel ratio capped at 2, so dots stay crisp.
- Frame rate
- Capped at 20 frames a second.
- When unseen
- Stops rendering when the canvas leaves the viewport or the tab is hidden, and resumes where it left off.
- Reduced motion
- Shows a still texture. Controls still update it.
- Layers
- Up to five effects fuse into one shader and one draw call. Filters such as dithering and halftone process the layers beneath them.
- Browsers
- Any browser with WebGL2: Chrome and Edge 56+, Firefox 51+, Safari 15+.
- Licence
- MIT. Copy it, change it, ship it.