var cnt =-12;//x-value and counter for each polynomial
var a=0.01,t=0;//initial values for coefficients, and reset counter t
function setup() {
createCanvas(400, 400);
background(20);
strokeWeight(0.1);//thin lines
}
function draw() {
translate(width/2,width/2)
fill(200, 250-10*t, 250,40)//gradient fill
x1 = cnt;
y1 = a*pow((x1),3)//Polynomial y value ax^3+bx^2+cx
if(y1>-200 && y1 <200){
circle(x1*15,y1,cnt*3)//draw a circle for a point on the polynomial
}
cnt=cnt+0.3;
if (cnt>12){//draw the next polynomial
newCoeff();// function to change coefficients
}
}
function newCoeff(){
a = a*1.5
cnt = -12;//reset cnt
t = t+1;
if (t> 20){
noLoop()//stops when done - uncomment previous two lines to loop and comment this one
}
}