let a=3.5;
let c=0.05;
let mArray=[];
let n=0;
function setup(){
createCanvas(windowWidth,windowHeight);
fill(0);
stroke(255)
noFill()
strokeWeight(0.7);
}
function draw(){
background(0, 52, 100);
translate(width/2,height/2);
t=90*sin(frameCount/500)*sin(frameCount/500);
fermatSpiral(t)
for (i=0;i<n;i++){
push()
translate(mArray[i][0],mArray[i][1])
fermatSpiral(abs(t-mArray[i][2]))
pop()
}
push()
translate(width/2-20,height/2-20)
scale(0.3,0.3)
fermatSpiral(10)
pop()
}
function fermatSpiral(n){
beginShape()
for (let i=n;i>0;i=i-c){
r=a*a*sqrt(i)
x = r * cos(i);
y = r * sin(i);
vertex(x,y)
}
endShape()
push()
scale(-1,-1)
beginShape()
for (let i=n;i>0;i=i-c){
r=a*a*sqrt(i)
x = r * cos(i);
y = r * sin(i);
vertex(x,y)
}
endShape()
pop()
}
function mousePressed(){
mArray[n]=[mouseX - width/2,mouseY - height/2,t]
n=n+1
if (n>25){
n=0;
mArray=[];
}
}