p5.js addon library

p5.waves

34 wave shapes. One function call.
Pass a number in, get a number back. Use it for anything.

See all 34 waves ↓

Try It

Pick a wave, drag the sliders, see the code update live.

Wave Shift

One flag. The library picks a random wave, holds it, then smoothly morphs into the next one. Different every time you load the page.

3D Terrain

Two independent wave samplers drive X and Z height. Drag to rotate.

Get Started

Add the script tag. Call the function. Done.

<script src="p5.waves.js"></script> function draw() { for (let x = 0; x < width; x += 3) { let y = Waves.wave(x, { wave: 'mountain peaks', t: millis() / 1000, amplitude: 80 }); point(x, height / 2 + y); } }
Examples → Guide →