Harmonograph Trails
Emulating mechanical pendulums to draw incredibly complex, looping geometric trails.
60 FPS • p5.js
p5.js Sketch Code
p.setup = () => {
p.createCanvas(p.container.clientWidth, p.container.clientHeight);
p.background(10);
};
let t = 0;
p.draw = () => {
p.translate(p.width/2, p.height/2);
p.stroke(255, 100);
let f1 = p.map(p.mouseX, 0, p.width, 1, 5) || 2;
let f2 = p.map(p.mouseY, 0, p.height, 1, 5) || 3;
let x = p.sin(t * f1) * p.exp(-0.001*t) * 150;
let y = p.sin(t * f2 + p.PI/2) * p.exp(-0.001*t) * 150;
p.point(x, y);
t += 0.1;
if (t > 1000) { t=0; p.background(10); }
};
p.windowResized = () => { if(p.container) p.resizeCanvas(p.container.clientWidth, p.container.clientHeight); }; Properties
#p5js#harmonograph#math
Author: Math Art Core Target: 60 FPS