xxxxxxxxxx
38
//you can make variations by adjusting amplitude (the height of the sine wave), period (the full cycle of each sine wave), and phase (an offset to the x-position).
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*2);
}
}
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]),-1,1,-100,100);
let x = map(i,0,total,-200,200);
circle(x, y, r*2); //circle takes diameter
//line(x,0,x,y);
// vertex(x,y)
// endShape();
let increment = TWO_PI/60;
angles[i]+=increment;
}
}