xxxxxxxxxx
29
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
rectMode(CENTER);
noFill();
stroke(255);
strokeWeight(2);
//minSize finds if the width or height is a smaller value
let minSize = min(width, height);
//either width or height / 30
let amount = minSize / 30;
for (let i = 1; i < amount; i++) {
//x value is random value between 1/2 width - amount & 1/2 width + amount
let x = random(width / 2 - amount, width / 2 + amount);
//y value is random value between 1/2 height - amount & 1/2 height + amount
let y = random(height / 2 - amount, height / 2 + amount);
//square width&height increases by 1 every time
square(x, y, amount * i);
}
}
function draw() {}
//the squares will all be drawn within the center area of the canvas