let cnv;
let c = 0;
let t;
let waveA = [];
function setup() {
cnv = createCanvas(windowWidth, windowHeight);
angleMode(DEGREES);
curvies();
}
function draw() {
background(0,0,0, 1);
translate(width / 2, height / 2);
t = (-width / 2) * cos(frameCount / (width/100));
noStroke();
fill(
100 * sin(frameCount / 3) * sin(frameCount / 3),
200 * sin(frameCount / 4) * sin(frameCount / 4),
250 * cos(frameCount / 2) * cos(frameCount / 2),
100
);
for (let i = 0; i < c; i++) {
waveA[i].move();
waveA[i].display();
}
if(frameCount%50===0){
curvies();
}
}
function curvies() {
if (c < 100) {
waveA.push(new waveMe(c));
c = c + 1;
}
}
class waveMe {
constructor(n) {
this.x = 0;
this.y = 100;
this.n = n;
}
move() {
this.x = t;
this.y = 100 + 100 * sin(t) * cos(this.n * t) + 10 * sin((this.n * t) / 2);
}
display() {
circle(this.x, this.y, 2);
circle(-this.x, -this.y, 2);
}
}
function mousePressed(){
c = 0;
waveA = [];
setup();
}