xxxxxxxxxx
let colourList = [
"#490a3d",
"#bd1550",
"#e97f02",
"#f8ca00",
"#8a9b0f"
]
function setup() {
createCanvas(800, 800);
noLoop();
}
function draw() {
background(150);
let y = 0;
while (y < height) {
drawOneRowOfBricks(y, 100);
y += 100
}
}
function drawWallOfBricks() {
drawOneRowOfBricks();
}
function drawOneRowOfBricks(y, brickHeight) {
let x = 0;
while (x < width) {
brickWidth = random(40, 200);
drawOneBrick(x, y, brickWidth);
x += brickWidth
brickWidth = random(40, 200);
}
}
function drawOneBrick(x, y, brickWidth) {
const brickHeight = 100;
fill(random(colourList));
rect(x, y, brickWidth, brickHeight);
const diceRoll = random([1, 2])
if (diceRoll === 1) {
drawPolkaDotDesign(x, y, brickWidth, brickHeight)
} else {
drawSquareDesign(x, y, brickWidth, brickHeight);
}
}
function drawPolkaDotDesign(x, y, brickWidth, brickHeight) {
const diameter = random(min(brickWidth, brickHeight));
fill(random(colourList));
circle((x + brickWidth / 2), (y + brickHeight / 2), diameter);
}
function drawSquareDesign(x, y, brickWidth, brickHeight) {
push()
fill(random(colourList));
rectMode(CENTER);
const size = random(min(brickWidth, brickHeight));
square(x + brickWidth / 2, y + brickHeight / 2, size);
pop()
}
function mousePressed() {
redraw()
}