xxxxxxxxxx
41
let circles = [];
let w, h;
function setup() {
cnv = createCanvas((w = windowWidth), (h = w / 2));
background(0);
for (let i = 0; i <= 25; i++) {
circles[i] = {
x: w / 10 + (4 * i * w) / 125,
y: h / 2,
r: random(10, h / 2)
};
}
noFill();
}
function draw() {
for (let i = 0; i < 1000; i++) {
inCircle = 0;
let x = random(0, w);
let y = random(0, h);
for (let j = 0; j < circles.length; j++) {
stroke(100);
circle(circles[j].x, circles[j].y, circles[j].r);
if (dist(circles[j].x, circles[j].y, x, y) < circles[j].r / 2) {
inCircle++;
}
}
if (inCircle % 2 === 0) {
stroke(255);
point(x, y);
} else if (inCircle % 2 === 1) {
stroke(100, 150, 205);
point(x, y);
}
}
}
function mousePressed(){
setup()
draw()
}