How a list of math expressions became a creative tool — and why switching between wave shapes makes sketches feel alive.
It started with a shared list of wave formulas — short math expressions, each producing a different pattern from a single input number. Sine, cosine, tangent, modulo, absolute value, rounding — combined in dozens of ways.
The original dataset came from the creative coding community. GenerativePunk and ffd8 contributed the core set of formulas that would become the foundation of this library. Each formula was small enough to read in a single line, expressive enough to recognise by its shape.
The moment everything clicked was a 16×16 binary grid. Two wave algorithms — one for rows, one for columns — combined into a black-and-white pattern. When the grid went all-black or all-white, it auto-advanced to the next formula pair.
That sketch was about 30 lines of draw logic. But watching it run was a revelation: predictable math producing patterns that felt alive. Each formula switch changed the character of the grid — from stripes to checkers to organic clusters to total silence, then back again.
This was the emotional benchmark. Every decision in the library since then has been measured against that feeling: would this make the grid sketch simpler or more expressive?
p5.js sketches are deterministic by default. Run the same code, get the same picture. That is a feature for learning, but a limitation for creative expression. The sketch looks identical every time — no variation, no discovery, no surprise.
p5.waves exists to change that. By giving you 34 formulas you can switch between, every run can produce a different result. Not random chaos — structured variation. The wave always has a recognisable shape. But which shape? That can change.
Seeding, morphing, shifting, wild mode — these are all mechanisms for the same idea: the sketch should feel different every time you reload, while staying recognizable. A different result every run, but never a broken one.
The design decisions were driven by simplicity. One function, one number back:
Waves.wave(y). No setup required. No configuration before you start.
The mental model mirrors noise(y) in p5.js — pass a coordinate, get a value.
Everything else layers on top: naming formulas, morphing between them, caching with samplers, sampling grids. But the entry point is always the same single function call. If user code becomes awkward to use the library, the fix belongs in the library — not in instructions telling the user to write differently.
Maker:
Sebastien Vanblaere — prjcts.be
Contributors (wave formula dataset):
tw@GenerativePunk — original dataset contributor
gh@ffd8 — original dataset contributor
Reference for rectangular/pulse formulas:
titanwolf.org – pulse/rectangular wave formulas
Reference for triangle formula:
p5.js editor – jeremydouglass triangle sketch