var cnt =-60;//counter
var p = -200;
function setup() {
createCanvas(400, 400);
background(25);
stroke(25);//gray background so first circle isn't seen
fill(25);//gray background
newABC();//initialize variables for drawing
strokeWeight(0.5);//thin lines
fill(255,30);//setting fill for circles to be transparent
}
function draw() {
translate(width/2,width/2)
stroke(50-cnt,200+cnt*2,255);//create a gradient color based on x value;
y1 = (-a1*pow(cnt,2) +b1*cnt+c1)/150
y2 = (-a2*pow(cnt,2) +b2*cnt+c2)/600
line(cnt*5,y1,cnt,y2)//draw line between points of both parabolas
cnt=cnt+1;
if (cnt>60){//draw a new set of parabolas
newABC();//calculate new a,b,and c values for parabolas
}
}
function newABC(){
circle(0,p,5)//draw artistic circles as timers for animation
circle(0,-p,15)
a = random(-1,1)//makes both parabolas face the same direction
a1 = random(-200,200)*a;//random a,b, and c variables:
b1 = random(-20,20)
c1 = random(-8000,8000)
a2 = random(-200,200)*a;
b2 = random(-20,20)
c2 = random(-8000,8000)
cnt = -60;//reset cnt
p = p+10;//increase circle counter and reset
if (p>210){//reset after the circle gets to the end
p = -200;
background(25);
}
}