xxxxxxxxxx
palette = ["#f75c03", "#2191fb", "#d90368", "#820263", "#f3de2c"];
function setup() {
createCanvas(800, 800);
noLoop();
rectMode(CENTER);
}
function draw() {
background(10);
grid();
tile();
}
function grid() {
let c = 50;
let w = width / c;
let col = random(palette);
for (let i = 0; i <= c; i++) {
for (let j = 0; j <= c; j++) {
let x = i * w;
let y = j * w;
col = random(palette);
noStroke();
fill(col);
rect(x, y, w * 0.3, w * 0.3);
strokeWeight(2);
stroke(col);
noiseLine(x, y);
}
}
}
function tile() {
let c = 400;
let w = width / c;
noFill();
stroke(180, 50);
strokeWeight(0.5);
for (let i = 0; i < c; i++) {
for (let j = 0; j < c; j++) {
let x = i * w;
let y = j * w;
rect(x, y, w, w);
}
}
}
function noiseLine(x, y) {
let c = 50;
let px = x;
let py = y;
for (let i = 0; i < c; i++) {
let ns = 0.0025;
let n = 10;
let angle = int(noise(x * ns, y * ns, i * 0.0001) * 20) * PI / 4;
line(x, y, px, py);
px = x;
py = y;
x += cos(angle) * 4;
y += sin(angle) * 4;
}
}
function getCol() {
let n = hue + 180 * int(random(2));
let col = color(n, random(80), random(90, 100));
if (random(1) < 0.15) {
col = color(n, random(90, 100), random(90, 100));
} else if (random(1) < 0.16) {
col = color(random(20));
}
return col;
}