xxxxxxxxxx
50
const CANVAS_DIM = 1000;
const MIN_PROPORTION = 0.35;
const MAX_PROPORTION = 0.5;
const MIN_RECT_DIM = 10;
const BORDER = 0;
let colors = ["#a39193", "#aa6f73", "#eea990", "#f6e0b5"];
function setup() {
createCanvas(CANVAS_DIM, CANVAS_DIM);
background("#332a2f");
strokeWeight(0.15);
fill(random(colors));
rect(BORDER, BORDER, CANVAS_DIM - 2 * BORDER);
strokeWeight(0.15);
generateRects(
BORDER,
BORDER,
CANVAS_DIM - 2 * BORDER,
CANVAS_DIM - 2 * BORDER,
round(random(0, 3)) % colors.length
);
}
function draw() {}
function generateRects(positionX, positionY, baseWidth, baseHeight, count) {
if ((baseWidth < MIN_RECT_DIM) | (baseHeight < MIN_RECT_DIM)) return;
let w1 = random(MIN_PROPORTION * baseWidth, MAX_PROPORTION * baseWidth);
let h1 = random(MIN_PROPORTION * baseHeight, MAX_PROPORTION * baseHeight);
fill(random(colors));
fill(colors[count % colors.length]);
fill(round(random(7,15) * 10));
rect(positionX, positionY, w1, h1);
let w2 = baseWidth - w1;
let h2 = baseHeight - h1;
rect(positionX + w1, positionY + h1, w2, h2);
generateRects(positionX, positionY + h1, w1, h2, count + 1);
generateRects(positionX + w1, positionY, w2, h1, count + 1);
}