swell

Water, drawn as dots.

Surf rolling in and breaking on the sand, waterfalls tearing into mist, geysers on their own clocks and fountains that dance, whirlpools spiralling to a dark eye, rain on a pond. No dependencies, one script.

Flags

The same surf four ways. They stack.

Use it

One script, then a canvas. Height is the size; a wider canvas gives the sea more room.

<script src="https://cdn.jsdelivr.net/gh/TonkaTuff/swell@v0.1.0/dist/swell.min.js"></script>
<canvas class="water" width="300" height="200" data-water-body="surf"></canvas>
attributevaluewhat it does
data-water-bodynameany name above
data-water-formopen · wide · tall · fountainopen water for surf (nothing breaks); a wide curtain or a tall thin drop for a waterfall; a fountain instead of a geyser
data-water-heightnumbersurf: how big the waves get (1); geyser: how high it throws, as a fraction of the height (0.7)
data-water-break / -setsnumbersurf: how far in the waves break, 0 horizon to 1 sand (0.6); how many wave trains fit in (1)
data-water-drop / -top / -width / -mistnumberwaterfall: the drop and where the lip sits as fractions of the height, half the curtain's width, and how much mist
data-water-period / -burst / -jets / -dancenumbergeyser: seconds between eruptions (14) and the fraction spent erupting (0.35); fountain: how many jets (5), 1 to make them dance
data-water-spin / -eye / -reach / -dirnumberwhirlpool: how fast it turns (1), the eye's size (0.1), the whole thing's size (1), -1 to turn the other way
data-water-slots / -period / -reachnumberpond: drops in the air at once (6), seconds between them (2.4), how far the rings run (0.25)
data-water-n / -temponumberhow many dots at a 64px height, scaled up with size · how fast it all happens (1)
data-water-ink / -lite / -ground1monochrome dots that follow the page theme · half the dots · a dusk behind
data-water-glow0no soft glow, just the dots on a clear canvas