xxxxxxxxxx
38
let allDots = [];
function setup() {
createCanvas(500, 500);
}
function draw() {
background(220);
for(let i = 0; i <allDots.length; i++ ){
allDots[i].display();
}
}
function mousePressed(){
let tempDot = new dot(mouseX,mouseY,25);
allDots.push(tempDot);
}
class dot{
constructor( posX, posY, size){
this._posX = posX;
this._posY = posY;
this._size = size;
this.alpha = 255;
}
display(){
fill(255,0,0,this.alpha);
noStroke();
circle(this._posX,this._posY,this._size);
this.alpha--;
}
}