xxxxxxxxxx
48
let ponds = [];
function setup() {
createCanvas(600, 600);
}
function draw() {
background(100,100,200);
for (let i=0; i<ponds.length; i++) {
ponds[i].show();
}
if (ponds.length>3) {
ponds.shift();
}
}
function mousePressed() {
ponds.push(new Pond(mouseX, mouseY, 5));
return false;
}
class Pond {
constructor(x, y, t) {
this.x = x;
this.y = y;
this.r = 30;
this.t = t;
this.alph = 255;
}
show() {
for (let i=1; i <this.t+1; i++){
noFill();
stroke(255,255,255,this.alph);
ellipse(this.x, this.y, this.r*pow(i,0.75));
}
this.grow();
}
grow() {
this.r += this.r/50;
this.alph -= 1;
}
}