let border, dim, sectSize, section, boxNum, boxes, isGenerating;
colorMode(HSL, 100, 100, 100);
createCanvas(min(windowWidth, windowHeight), min(windowWidth, windowHeight));
section = floor(random(3, 8));
border = floor(random(20, 80));
dim = min(width, height) - border * 2;
sectSize = dim / section;
boxes = new Array(boxNum);
if (isGenerating == 0) return;
for (let i = 0; i < boxNum; i++) {
return 1 - Math.pow(1 - x, 5);
function mouseClicked() {
constructor(x1, x2, y1, y2, h, s, l, sS) {
let startX = floor(random(0, section - 1) + 1) * sectSize + border;
let startY = floor(random(0, section - 1) + 1) * sectSize + border;
fill(this.h, this.s, this.l);
rect(this.xc1, this.yc1, this.xc2, this.yc2, this.sectSize);
let easedValue = ease(this.ease += 0.001);
this.xc1 = lerp(this.xc1, this.xf1, easedValue);
this.xc2 = lerp(this.xc2, this.xf2, easedValue);
this.yc1 = lerp(this.yc1, this.yf1, easedValue);
this.yc2 = lerp(this.yc2, this.yf2, easedValue);
for (let i = 0; i < boxNum; i++) {
let x1 = floor(random(0, section + 1)) * sectSize + border;
let x2 = floor(random(0, section + 1)) * sectSize + border;
let y1 = floor(random(0, section + 1)) * sectSize + border;
let y2 = floor(random(0, section + 1)) * sectSize + border;
let s = random(2) * 25 + 50;
let l = random(2) * 25 + 50;
boxes[i] = new Box(x1, x2, y1, y2, h, s, l, sectSize);
background(random(4) * 25, random(2) * 25, random(25) + floor(random(2)) * 75);