xxxxxxxxxx
let grid, SZE, NX, NY, NUM = 40, C_NUM = 4, C_PAD = 2;
function setup() {
createCanvas(windowWidth, windowHeight);
SZE = min(width, height) / NUM;
grid = arrCreate2D(NUM, NUM);
background(212);
stroke(32);
for (let x = 0; x < width; x += SZE) line(x, 0, x, height);
noStroke();
fill(0, 128);
}
function draw() {
const x = ~~random(width/SZE) * SZE; // random(width);
const y = ~~random(height/SZE) * SZE;
const w = SZE;
const h = SZE / ~~(random()*random()*4+1)
rect(x, y, w, h);
}
function arrCreate2D(x, y, val = 0) {
let arr = [];
for (let j = 0; j < y; j++) {
arr[j] = [];
for (let i = 0; i < x; i++) {
arr[j][i] = val;
}
}
return arr;
}