let a, b, c, s, n, w, h, k, p;
function setup() {
c = min(windowWidth, windowHeight);
cnv = createCanvas(c, c);
angleMode(DEGREES);
background(255);
noLoop();
a = random(1, 9);
b = random(2, 9);
c = random(0, 20);
s = random(10, 55);
n = int(random(1, 13));
k = random(50, 120);
p = (-180, 180);
}
function draw() {
for (let i = 0; i < 7000; i++) {
x = random(width * 0.25, width * 0.95);
y = random(height * 0.25, height * 0.95);
r = random(10 + (10 * a) / 4, 150 * abs(cos(y + x * a) * sin(x * b + x)));
g = random((60 * a) / 4, 100 + 150 * abs(sin(x * b + y / a)));
b = random(200, 200 + 150 * abs(sin(x * a + y * b)));
randomStroke(x, y, r, g, b);
}
for (let i = 0; i < n; i++) {
randomBox();
}
}
function randomStroke(x, y, r, g, b) {
noFill();
for (let i = 0; i < 25; i++) {
strokeWeight(random(0.1, 3));
stroke(r + random(-10, 10), g + random(-10, 10), b + random(-10, 10), 50);
arc(x - k, y - k + i * random(0, 1), k, k, p, p + s);
}
}
function randomBox() {
a = random(0, 2);
b = random(0, 9);
w = random(5, width / 4);
h = random(5, height / 4);
x1 = random(width * 0.3, width * 0.9 - w);
y1 = random(height * 0.3, height * 0.9 - h);
for (let i = 0; i < 1000; i++) {
x = random(x1, x1 + w);
y = random(y1, y1 + h);
r = random(h + 50, 150 * abs(cos(10 * a) * cos(y1 / w - x1 / a)));
g = random(w + 50, 100 + 150 * abs(cos((y * x) / a + y / y1)));
b = random(w + 50, 200 + 150 * abs(cos(a * b + x1 * b)));
randomStroke(x, y, r, g, b);
}
}
function keyPressed() {
setup();
draw();
}