let cells = Math.floor(Math.random() * Math.floor(cellMax - 1)) + 2;
for (let i = 0; i < num; i++) {
images[i] = loadImage("https://picsum.photos/id/" + i + "/10/10/");
colorMode(HSB, 360, 100, 100, 100);
margin = offset / int(random(2, 4));
cellW = (width - offset * 2 - margin * (cols - 1)) / cols;
cellH = (height - offset * 2 - margin * (rows - 1)) / rows;
let x = map(i % cols, 0, cols - 1, offset, width - offset - cellW);
let y = map(int(i / rows), 0, rows - 1, offset, height - offset - cellH);
brushes.push(new Brush(x, y, cellW, cellH, img));
background(0, 0, 10, .1);
for (let brush of brushes) {
for (let i = arr.length - 1; i >= 0; i--) {
constructor(_x, _y, _w, _h, _img) {
this.angle = random(360);
this.xRatio = random(-5, 5) / 2.5;
this.yRatio = random(-5, 5) / 2.5;
this.countMax = random(3, 10) * 10;
translate(this.x + this.MaxW / 2, this.y + this.MaxH / 2);
rotate(frameCount * 1 / this.xRatio / 3);
this.cx = cos(this.angle + frameCount * this.xRatio) * this.MaxW / 2;
this.cy = sin(this.angle + frameCount * this.yRatio) * this.MaxH / 2;
this.w = sin(this.cx + frameCount / 10) * this.MaxW / 5;
image(this.img, this.cx, this.cy, this.w, this.h);
return this.count > this.countMax;