let circles;
function setup() {
createCanvas(600, 600);
circles = [];
nRot = int(random(5, 20));
rad1 = random(width / 7, width / 4);
rad2 = random(width / 10, width / 2);
for (let i = 0; i < nRot; i++) {
circles[i] = {
x: rad1 * cos((TAU / nRot) * i),
y: rad1 * sin((TAU / nRot) * i)
};
}
}
function draw() {
translate(width / 2, height / 2);
rotate(frameCount / 500);
noStroke();
for (let x = -width / 1.5; x < width / 1.5; x += 8) {
for (let y = -height / 1.5; y < height / 1.5; y += 8) {
minD = width;
for (let k = 0; k < nRot; k++) {
d1 =
dist(x, y, circles[k].x, circles[k].y) - rad1 * sin(frameCount / 100);
minD = min(minD, d1);
}
let brightness = map(abs(minD), 0, width / 2, 285, 0);
fill(brightness - 80, brightness - 50, brightness, 20);
circle(x, y, 10);
}
}
}
function border() {
noFill();
stroke(20, 50, 60);
strokeWeight(4);
rect(0, 0, width - 20, height - 20);
}
function mousePressed() {
frameCount = 0;
setup();
draw();
}
function keyPressed() {}