MARGIN = createVector(10, 10);
PALETTE = ['black', 'rgb(2,34,148)', 'rgb(152,38,37)', 'rgb(209,185,61)'];
RANDOM_SEED = int(random() * 1000000);
createCanvas(windowHeight * ASPECT_RATIO, windowHeight);
int((width - (2 * MARGIN.x)) / BLOCK_SIZE),
int((height - (2 * MARGIN.y)) / BLOCK_SIZE));
const true_dim = p5.Vector.mult(DIM, BLOCK_SIZE);
const diff = p5.Vector.sub(createVector(width, height), true_dim);
function recursive_rect(colour, min_pos, max_pos, max_width) {
if (max_width.x < 1 || max_width.y < 1) {
const pos_range = p5.Vector.sub(max_pos, min_pos);
createVector(random(), random()),
const dxdy = createVector(
min(DIM.x - pos.x, int(random(0.1, 0.9) * (max_width.x))),
min(DIM.y - pos.y, int(random(0.1, 0.9) * (max_width.y)))
rect(int(pos.x), int(pos.y), int(dxdy.x), int(dxdy.y));
p5.Vector.sub(pos, p5.Vector.mult(dxdy, 0.25)),
p5.Vector.add(p5.Vector.add(pos,dxdy), p5.Vector.mult(dxdy, 0.25)),
p5.Vector.mult(dxdy, 1.25));
translate(MARGIN.x, MARGIN.y);
for (let i = 0; i < 100; i++) {
PALETTE[int(random()*PALETTE.length)],
createVector(DIM.x/4, DIM.y/4));
save(`kawano_${RANDOM_SEED}`);