xxxxxxxxxx
32
let total;
let angles = []; //our angles here represent the x-positions
let r = 5;
function setup() {
createCanvas(400, 400);
total = floor(width / (r * 2));
for (let i = 0; i < total; i++) {
angles[i] = map(i, 0, total, 0, TWO_PI);
}
}
function draw() {
background(0);
translate(200, 200);
stroke(255);
// fill(252, 0, 200);
noFill();
beginShape();
for (let i = 0; i < total; i++) {
let y = map(sin(angles[i]), -0.1, 1, -100, 200);
let x = map(i, 0, total, -i, i);
// circle(x, y, r*2); //circle takes diameter
// line(x,0,x,y);
vertex(x, y);
endShape();
let increment = TWO_PI/160;
angles[i]+=increment;
}
}