// fluid.js, one step
curl[i] = .5 * (v[i+1] - v[i-1] - u[i+w] + u[i-w]); // vorticity confinement
tmp[i] = this.sample(u, x - u[i], y - v[i]) * .99; // semi-Lagrangian advection
div[i] = -.5 * (u[i+1] - u[i-1] + v[i+w] - v[i-w]);
for (let k = 0; k < 14; k++) pressure[i] = (div[i] + pressure[i-1] + pressure[i+1] + pressure[i-w] + pressure[i+w]) * .25;
u[i] -= .5 * (pressure[i+1] - pressure[i-1]); // make it incompressibleColor drift
Move through the space and leave a little colour.
A passing gesture.
A trace of color.
Move to stir.
Pause to watch it settle.
Start somewhere new.
Color follows your gesture,
then finds its own way.
Move your pointer through the canvas, or drag with a finger.
A little pull.
A different pattern.
Move through the dots.
Move, curl, release.
The same space.
Another shape.
Choose a landscape.
Islands
One last gesture.
Then let it go.
Leave a little color on your way out.
Key CSS & implementation tricks
const steps = Math.min(16, Math.max(1, Math.ceil(Math.hypot(dx * fluid.w, dy * fluid.h) / 2)));
for (let i = 1; i <= steps; i++)
fluid.splat(x - dx * (1 - i / steps), y - dy * (1 - i / steps), dx * 1.5 / steps, dy * 1.5 / steps, color);const influence = Math.exp(-d * d / .11) * strength;
const turn = a + influence * (2.3 + Math.sin(time * .65 + d * 16) * .7);
const tx = p.bx + (pointer[0] + Math.cos(turn) * r + fold - p.bx) * strength;
p.vx = (p.vx + (tx - p.x) * .035) * .86; p.x += p.vx; // spring home when strength → 0for (let edge = 0; edge < 4; edge++) {
const a = values[edge], b = values[(edge + 1) % 4];
if ((a < level) !== (b < level)) hits.push(lerpPoint(edge, crossing(a, b, level)));
}
for (let k = 0; k + 1 < hits.length; k += 2) { ctx.moveTo(...hits[k]); ctx.lineTo(...hits[k + 1]); }
grid[i] = heightAt(px, py, oldMode, time) * (1 - blend) + heightAt(px, py, mode, time) * blend;