let url = "https://coolors.co/app/d37804-fe859b-e4c5cd-0fbbf7-003c9b";
colorMode(HSB, 360, 100, 100, 100);
graphics = createGraphics(width, height);
graphics.colorMode(HSB, 360, 100, 100, 100);
drawNoiseBackground(100000, graphics);
pallete = createPallete(url);
background(int(random(12)) * 360 / 12, 100, 10);
cells = int(random(8, 20));
margin = offset * -1 / 5;
let w = sqrt(sq(width) + sq(height));
cellW = (w - offset * 2 - margin * (cols - 1)) / cols;
cellH = (w - offset * 2 - margin * (rows - 1)) / rows;
center = createVector(width / 2, height / 2);
translate(center.x, center.y);
for (let j = 0; j < rows; j++) {
for (let i = 0; i < cols; i++) {
let x = map(i, 0, cols - 1, -w / 2 + offset, w / 2 - offset - cellW);
let y = map(j, 0, rows - 1, -w / 2 + offset, w / 2 - offset - cellW);
let d = new DotGraphics(x, y, cellW, cellH, pallete);
constructor(_x, _y, _w, _h, _pallete) {
this.pallete = _pallete.concat();
this.cn = int(random(this.pallete.length));
this.g = createGraphics(_w, _h);
this.g.colorMode(HSB, 360, 100, 100, 100);
let cells = int(random(5, 10));
let cellW = (this.g.width - margin * (cols - 1)) / cols;
let cellH = (this.g.height - margin * (rows - 1)) / rows;
for (let j = 0; j < rows; j++) {
for (let i = 0; i < cols; i++) {
x = map(i, 0, cols - 1, 0, this.g.width - cellW - margin);
y = map(j, 0, rows - 1, 0, this.g.height - cellH);
x = map(i, 0, cols - 1, 0, this.g.width - cellW);
y = map(j, 0, rows - 1, 0, this.g.height - cellH);
this.g.fill(random(100) < 30 ? color(0, 0, 0, 0) : color(this.pallete[this.cn]));
this.g.rect(x, y, cellW, cellH);
while (this.cn == this.prevCn) {
this.cn = int(random(this.pallete.length));
let graphics_copy = createGraphics(this.g.width, this.g.height);
graphics_copy.copy(this.g, 0, 0, this.g.width / 2, this.g.height,
0, 0, this.g.width / 2, this.g.height);
graphics_copy.scale(-1, 1);
graphics_copy.image(graphics_copy, -graphics_copy.width + 1, 0, graphics_copy.width, graphics_copy.height);
image(graphics_copy, _x, _y);
function drawNoiseBackground(_n, _graphics) {
let c = color(0, 0, 100, 3);
for (let i = 0; i < _n; i++) {
let x = random(1) * width;
let y = random(1) * height;
_graphics.ellipse(x, y, w, h);
function createPallete(_url) {
let slash_index = _url.lastIndexOf('/');
let pallate_str = _url.slice(slash_index + 1);
let arr = pallate_str.split('-');
for (let i = 0; i < arr.length; i++) {