Click anywhere to change the visualization mode. Press [space] to pause. Use [<-] and [->] to control the speed.
xxxxxxxxxx
// By Roni Kaufman
let phi = 0;
let incr = 3e-4;
let c = 20;
let modes = ["CURVE", "LINE", "DOTS", "QUADRATIC"];
let current = 0;
let paused = false;
function setup() {
createCanvas(windowWidth, windowHeight);
colorMode(HSB, 100);
noFill();
stroke(5);
}
function draw() {
background(95);
let mode = modes[current];
beginShape();
vertex(width/2 + c * cos(phi), height/2 + c * sin(phi));
for (let n = 1; n <= 150; n++) {
let theta = phi * n;
let r = sqrt(n) * c;
let x = width/2 + r * cos(theta);
let y = height/2 + r * sin(theta);
if (mode === "CURVE") {
curveVertex(x, y);
} else if (mode === "LINE") {
vertex(x, y);
} else if (mode === "DOTS") {
circle(x, y, 5);
} else if (mode === "QUADRATIC") {
quadraticVertex(width/2, height/2, x, y);
//quadraticVertex(noise(x/100)*width, noise(y/100)*height, x, y);
}
}
endShape();
if (!paused) {
phi += incr;
}
}
function mousePressed() {
current = (current + 1) % modes.length;
}
function keyPressed() {
if (key === " ") {
paused = !paused;
} else if (keyCode === RIGHT_ARROW) {
incr *= 1.5;
} else if (keyCode === LEFT_ARROW) {
incr /= 1.5;
}
}