let ringArrayX = [];//Tree x variable
let ringArrayY = [];//Tree y variable
let nPoints = 250;//number of points in curves PLAY WITH THIS NUMBER!
let m = 2;
function setup(){
cnv = createCanvas(600,600)//create canvas
stroke(255);
}
function draw(){
background(0);
noFill();
translate(width/2,width/2)//make origin be in center
str1 = 'Npoints = '+str(nPoints);
str2 = 'multiplier = '+str(round(m,2));
text(str1,-width/2+10,width/2-20);
text(str2,-width/2+10,width/2-5);
rIn = 200
ringMakerInit(rIn,0);//initial ring
drawRing(ringArrayX[0],ringArrayY[0]);//draw ring function
}
function ringMakerInit(r,v){//initial growth
ringArrayX[0] = [];
ringArrayY[0] = [];
for (let i =0; i<=nPoints;i++){
ringArrayX[0][i] = r*sin(i*m*(nPoints)+frameCount/100);//CHANGE SPEED BY CHANGING THE 100 AND CHANGE 2 TO CHANGE SHAPE
ringArrayY[0][i] = r*cos(i*(nPoints)+frameCount/100);
}
}
function drawRing(X,Y){//draw ring
beginShape();
for (let i = 0;i<=nPoints;i++){
curveVertex(X[i],Y[i]);
}
endShape();
}
function mousePressed(){//reset with mousepress
background(255);
translate(-width/2,-width/2);
stroke(random(180,250),random(180,255),random(180,255));
nPoints = int(random(20,300));
text(nPoints,-width/2,-width/2);
frameCount = 0;
m = random(2,9);
draw();
}