xxxxxxxxxx
65
var bgColor = 0;
let coralRectangles;
function setup() {
createCanvas(600, screen.height);
coralRectangles = new rectSet();
}
function draw() {
background(bgColor);
coralRectangles.render();
}
class rectSet {
constructor() {
this.numRects = 10;
this.rectOffset = 30;
this.rectArray = [];
this.populateArray();
}
populateArray() {
for (let i = 1; i <= this.numRects; i++) {
this.rectArray.push(new coralRect(width/2, height/2, 115 + (i * this.rectOffset), 247 + (i * this.rectOffset), 255));
}
}
render() {
for (let i= 0; i < this.rectArray.length; i++) {
this.rectArray[i].render();
}
}
}
class coralRect {
constructor(x, y, width, height, color) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.color = color;
this.thickness = 4;
}
render() {
rectMode(CENTER);
fill(0, 0, 0, 0.0);
stroke(this.color);
strokeWeight(this.thickness);
rect(this.x, this.y, this.width, this.height);
}
}