hexagons-lite draws animated honeycomb backgrounds built from regular hexagons: hexagon line art on canvas, where the colour gradient runs along the edges, plus a filled low-poly mode when you want the opposite. Zero dependencies, about 6.5 KB gzipped. Two knobs span the whole variant space: seed spins the geometry, brand spins the colours.
Three modes
field— depth. Regular hexagons scattered through depth, drifting toward the viewer and overlapping at different scales. Each one faces the viewer, so it stays exactly regular at any distance; some carry a concentric inner ring, a few use the accent colour, and the field drifts with the pointer.hive— the honeycomb. The real 6.6.6 tiling, with a soft band of light sweeping across the walls.bondrandomly fuses neighbouring cells,insetturns the outlines into parallel double walls, andorientationis pointy or flat.fill— the crumpled crystal. A filled, faceted honeycomb over a diagonal brand gradient that assembles itself once with a staggered entrance, then stays a static painting — zero CPU after the reveal.
Brand-aware auto-palette
You do not pick five colours — you pass your brand's one, for example brand: '#7c5cff'. The library derives the background, halo, gradient stops, accent and sweep colour from that single hex in CIE LCh, so the hue stays your hue and contrast floors keep the lines visible. Multi-colour brands pass an array; theme gives a dark or light version of the same brand. Hexagons.palette() exposes the derivation on its own.
How to use it
Install with npm install hexagons-lite or load hexagons.min.js from a CDN, then call:
Hexagons.init('.bg', { mode: 'hive' });
The script defines one global, Hexagons, and the canvas fills the container you give it. The instance can set() options live, stop(), start(), step() one frame, and destroy() itself.
Beyond the animation
- Static pattern.
pattern()returns a seamless SVG honeycomb pattern as a ready-to-usebackground-image— nothing animates and nothing runs afterwards. Hexagons stay legible down to roughly 14 px. - Offline rendering. With a
seed, a transparent background andstep(dt)on your own clock, the same seed gives identical frames — ready to screenshot for video. - Performance. The loop sleeps when the container is off screen or the tab is hidden, gradients are built once, and the device pixel ratio is capped at 2.
The family and licence
hexagons-lite is the 6 of a small family of zero-dependency polygon backgrounds: trigons-lite for triangles and octagons for octagons. MIT licence, built by 301ST for spintax.net.