xxxxxxxxxx
30
function setup() {
noFill();
// make a canvas
let canvasSize = 750
createCanvas(canvasSize, canvasSize);
// setting colour variables
stroke(200); // grey stroke around the rects
// setting brick height
var brickHeight = 15;
// looping vertically
for (var i = 0; i < canvasSize; i += brickHeight) {
progress = 0; // tracking if end of line is reached
// looping horizontally
while (progress < 800) {
fill(random(190, 200), // red
random(80, 90), // green
84); // blue
brickWidth = random(20, 40); // random brick width
rect(progress, i, brickWidth, brickHeight); // draw a rect
progress += brickWidth; // add the width to progress
}
}
}