
ittybitty
Dot Field
A calm grid of dots that swells and brightens around the pointer.
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 dot-field.js, ittybitty-shader.js, runtime.js, pointer.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="dot-field" style="width: 100%; height: 480px;"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="dot-field" aria-hidden="true" style="width: 100%; height: 480px; display: block"></canvas>
<script type="module">
import { dotField } from './dot-field.js';
const canvas = document.getElementById('dot-field');
const effect = dotField(canvas, {
showBackground: true,
shape: 'dots',
interactive: true,
responsiveness: 0.5,
idle: true,
speed: 0.5,
spacing: 22,
size: 1.6,
reach: 180,
swell: 1.4,
color: '#3a3a44',
accent: '#8f7bff',
background: '#101014',
// Performance
dpr: 2,
adaptive: true,
});
// Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
Dots near the pointer grow, take the accent colour and lean away from it. With no pointer, a slow wave rolls across the field. Spacing and sizes are in CSS pixels, so it looks the same on any screen.
- Payload
- 5.4 KB brotli for dot-field.js and ittybitty-shader.js and runtime.js and pointer.js, measured at build time. See the method.
- Resolution
- Device pixel ratio capped at 2, so dots stay round and crisp.
- Frame rate
- Display rate.
- When unseen
- Stops rendering when the canvas leaves the viewport or the tab is hidden, and resumes where it left off.
- Reduced motion
- The wave holds still; dots still respond to 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.