let sArray=[];
let n=150,t=0,nSides=6;
function setup(){
cnv=createCanvas(600,600);
angleMode(DEGREES)
for(let i=0;i<n;i++){
sArray.push(new curly)
noStroke();
}
}
function draw(){
background(255);
t=180*sin(frameCount/1.5)
fill(0,0,0)
translate(width/2,width/2);
scale(1,-1);
for(let j=0;j<nSides;j++){
push()
rotate(j*(360/nSides)+t/10)
translate(width/4,0)
for(let i=0;i<n;i++){
sArray[i].move()
}
pop()
}
}
class curly{
constructor(){
this.x=0;
this.y=0;
this.r=(random(5,25));
this.b=(random(5,100));
this.theta=random(0,360);
this.old = 0
}
move(){
push()
this.old=this.y
rotate(this.theta)
this.x=t
this.y=this.b*sin(t/2+this.b)+this.b*sin(t/6)*cos(t)+this.b/2*cos(t/4-this.b)*sin(t*2-this.b);
circle(this.x/1.5,this.y/1.5,this.r-abs(this.x)/10)
pop()
}
}
function mousePressed(){
if (nSides<=12){
nSides = nSides+1;
}
if (nSides>12){
nSides = 1;
}
}