let pallete = ["#FFB4A2", "#E5989B", "#FFCDB2", "#B5838D", "#6D6875"];
colorMode(HSB, 360, 100, 100, 100);
matter.mouseInteraction(canvas);
matter.changeGravity(0, 0.6);
let num = map(cells, 0, 3, 8, 20, 10);
for (let j = 0; j < rows; j++) {
for (let i = 0; i < cols; i++) {
if (random(100) > 95 && objects.length < cols * rows * num) {
let x = map(i, 0, cols - 1, offset, width - offset - w);
let y = map(j, 0, rows - 1, offset, height - offset - h);
let ow = random(w / 4, w / 10);
let oh = random(h / 4, h / 10);
let oc = pallete[int(random(pallete.length))];
obj = new Obj(ox, oy, ow, oh, oc);
for (let obj of objects) {
function mousePressed() {
let nx = int(map(constrain(mouseX, offset, width - offset - w), offset, width - offset - w, 0, cols - 1));
let ny = int(map(constrain(mouseY, offset, width - offset - w), offset, height - offset - h, 0, rows - 1));
let wall_num = nx + ny * cols;
let n = int(random(walls.length));
for (let wall of walls[wall_num]) {
walls[wall_num].length = 0;
cells = int(random(2, 8));
offset = width / cols * 1 / int(random(2, 6));
margin = offset / int(random(2, 4));
w = (width - offset * 2 - margin * (cols - 1)) / cols;
h = (height - offset * 2 - margin * (rows - 1)) / rows;
graphics = createGraphics(width, height);
graphics.colorMode(HSB, 360, 100, 100, 100);
drawNoiseBackground(100000, graphics);
for (let j = 0; j < rows; j++) {
for (let i = 0; i < cols; i++) {
let x = map(i, 0, cols - 1, offset, width - offset - w);
let y = map(j, 0, rows - 1, offset, height - offset - h);
function drawNoiseBackground(_n, _graphics) {
for (let i = 0; i < _n; i++) {
let x = random(1) * width;
let y = random(1) * height;
_graphics.fill(0, 0, 100, 3);
_graphics.ellipse(x, y, w, h);
function makeWalls(_x, _y, _w, _h) {
let floor = matter.makeBarrier(_x + _w / 2, _y + _h + depth / 2, _w + depth * 2, depth);
let leftWall = matter.makeBarrier(_x - depth / 2, _y + _h / 2, depth, _h);
let rightWall = matter.makeBarrier(_x + _w + depth / 2, _y + _h / 2, depth, _h);
constructor(_x, _y, _w, _h, _c) {
this.obj = matter.makeBall(_x, _y, _d, option);
this.obj = matter.makeBlock(_x, _y, _w, _h, option);
if (this.obj.isOffCanvas(100)) {