
ittybitty
Dither Light
A 1-bit torch that follows your pointer across a dark surface.
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-light.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-light" style="width: 100%; height: 480px; image-rendering: pixelated"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="dither-light" aria-hidden="true" style="width: 100%; height: 480px; display: block; image-rendering: pixelated"></canvas>
<script type="module">
import { ditherLight } from './dither-light.js';
const canvas = document.getElementById('dither-light');
const effect = ditherLight(canvas, {
showBackground: true,
speed: 0.5,
size: 0.45,
softness: 0.7,
intensity: 1,
pixel: 3,
pattern: 'bayer',
shape: 'circle',
interactive: true,
responsiveness: 0.5,
light: '#f3eadb',
background: '#121216',
// Performance
dpr: 2,
adaptive: true,
});
// Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
A pool of dithered light tracks the pointer, like a torch on an old monochrome screen. Without a pointer it drifts on its own. Set speed to 0 and it draws only while the pointer moves, then goes completely idle.
- Payload
- 6.7 KB brotli for dither-light.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.
- Frame rate
- Display rate while drifting or following; none at rest when drift is 0.
- When unseen
- Stops rendering when the canvas leaves the viewport or the tab is hidden, and resumes where it left off.
- Reduced motion
- The light stays put until you move the pointer; it still follows the pointer.
- 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.