swarm

Living things, drawn as dots.

A murmuration of starlings that wheels and folds, a bait ball that spins and flashes, fireflies over a meadow, bees round a swarm, jellyfish drifting up, a bioluminescent bay, an ant trail, a crowd crossing. No dependencies, one script.

Flags

The same flock four ways. They stack.

Use it

One script, then a canvas. Height is the size; a wider canvas gives them room to roam.

<script src="https://cdn.jsdelivr.net/gh/TonkaTuff/swarm@v0.3.0/dist/swarm.min.js"></script>
<canvas class="swarm" width="300" height="200" data-swarm-body="starlings"></canvas>
attributevaluewhat it does
data-swarm-bodynameany name above
data-swarm-nnumberhow many birds at a 64px height, scaled up with size (1800)
data-swarm-reachnumberthe flock's size as a fraction of the height (0.3)
data-swarm-wavenumberhow strongly density waves roll through it (1)
data-swarm-temponumberhow fast it all happens (1)
data-swarm-spin / -passesnumberbait balls: how fast the ball turns (0.5), how often a predator comes through (1)
data-swarm-sync / -period / -dutynumberfireflies: blink together with a wave (0 or 1), seconds per blink (2.2), how long each flash lasts as a fraction (0.22)
data-swarm-formghost · hive · scramble · marathonblue ghosts glow instead of blinking; a hive is entrance traffic instead of a cluster; a crowd can be a scramble crossing or a marathon
data-swarm-count / -bright / -leaf / -width / -lanesnumberjellyfish in the bloom (9); how bright the bay lights (1); 1 for ants carrying leaves; the trail's width (0.02); lanes across a concourse (5)
data-swarm-ink / -lite / -ground1monochrome dots that follow the page theme · half the dots · a dusk sky behind
data-swarm-glow0no soft glow, just the dots on a clear canvas