let url = "https://coolors.co/app/3e6990-aabd8c-101d42-eb4b98-2708a0";
colorMode(HSB, 360, 100, 100, 100);
pallete = createPallete(url);
let bn = int(random(pallete.length));
graphics = createGraphics(width, height);
graphics.colorMode(HSB, 360, 100, 100, 100);
drawNoiseBackground(100000, graphics);
cells = int(random(2, 10));
offset = width / (int(random(2, 5)) * 5);
cellW = (width - offset * 2 - margin * (cols - 1)) / cols;
cellH = (height - offset * 2 - margin * (cols - 1)) / rows;
for (let j = 0; j < rows; j++) {
for (let i = 0; i < cols; i++) {
let x = map(i, 0, cols - 1, offset, width - offset - cellW);
let y = map(j, 0, rows - 1, offset, height - offset - cellH);
let c1 = getRandomColor(pallete);
let c2 = getRandomColor(pallete);
line(0, 0, cellW, cellH);
p2 = createVector(cellW, cellH);
line(cellW, 0, 0, cellH);
p1 = createVector(0, cellH);
p2 = createVector(cellW, 0);
drawLineWithCircle(p1, p2, c1, c2);
function drawLineWithCircle(p1, p2, c1, c2) {
let angle = atan2(p2.y - p1.y, p2.x - p1.x);
let distance = p5.Vector.dist(p1, p2);
let dMax = width / cells / int(random(2,10));
for (let n = 0; n < distance; n += nStep) {
let c = lerpColor(color(c1),color(c2),n/distance);
let angle2 = map(n, 0, distance, 0, 360);
let d = map(sin(p1.x + p1.y + angle2), -1, 1, 0, dMax);
let x = x0 + cos(90 + n) * d / 2;
let y = y0 + sin(90 + n) * d / 2;
function getRandomColor(_pallete) {
_c = pallete[int(random(pallete.length))];
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++) {
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);