createCanvas(windowWidth, windowHeight);
divideRect(10, 10, W - 20, H - 20, 10);
const divideRect = (x, y, w, h, n) => {
drawCheckerBox(0, 0, w, h,floor(random(2,20)),getColor(),getColor());
let randomW = random(w * 0.1, w * 0.9);
divideRect(x, y, randomW, h, n);
divideRect(x + randomW, y, w - randomW, h, n);
let randomH = random(h * 0.1, h * 0.9);
divideRect(x, y, w, randomH, n);
divideRect(x, y + randomH, w, h - randomH, n);
const drawCheckerBox = (x, y, w, h, n, clr1, clr2) => {
for (let j = 0; j < n; j++) {
for (let k = 0; k < n; k++) {
let clr = cnt % 2 == 0 ? clr1 : clr2;
rect(j * w_diff, k * h_diff, w_diff, h_diff);
getRandomInt = (max) => {
return Math.floor(Math.random() * max);
"#080708", "#080c20", "#091a6a", "#102ca1", '#295fe1', '#66d8fb', '#96f2fa', '#caf7f9', '#f5fcfd', '#fefcff', '#fbeb4e', '#f1a93b', '#ea4028', '#511c6d'
return a[getRandomInt(a.length)];