xxxxxxxxxx
40
let rectangles = [];
function setup() {
createCanvas(400, 400);
for(let i = 0;i<100;i++){
rectangles [i] = new Rectangle();
}
rectMode(CENTER);
}
function draw() {
stroke(1);
background(250);
for(let i = 0;i<800;i++){
rectangles[i].display();
}
}
class Rectangle {
constructor (x,y,width,height,colorR,colorG,colorB,translationX,translationY) {
this.x = random(350);
this.y = random(350);
this.width = random(50);
this.height = random(50);
this.colorR = random(255);
this.colorG = random(255);
this.colorB = random(255);
}
display(){
stroke(1);
fill(this.colorR,this.colorG,this.colorB);
rect(this.x,this.y,this.width,this.height);
}
pop(){
this.colorR = random(255);
this.colorG = random(255);
this.colorB = random(255);
}
}