xxxxxxxxxx
38
/*
Based on Interrupted Grid from Code as a Creative Medium
https://github.com/CodeAsCreativeMedium/exercises/blob/main/02_iteration/12_interrupted_grid/interrupted_grid_js/interrupted_grid_js.js
*/
let size;
let padding;
function setup() {
createCanvas(windowWidth, windowHeight);
noFill();
stroke(255);
strokeWeight(2);
smooth();
noLoop();
}
function draw() {
background(0);
size = min(width / 10, height / 10);
padding = size * 0.2;
for (let x = 0; x < width - size; x += size) {
for (let y = 0; y < height - size; y += size) {
let chance = random(1);
if (chance < 0.05) {
circle(x + size * 0.6, y + size * 0.6, size - padding);
} else {
square(x + padding, y + padding, size - padding);
}
}
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}