xxxxxxxxxx
34
var circleX = []; // x coordinates go here
var circleY = []; // y coordinates
var circleD = []; // diameters
function setup() {
createCanvas(800, 800);
frameRate(60);
fill(0);
}
function draw() {
//background(255);
var randomD = random(10, 400);
var randomX = random(randomD/2, width-randomD/2);
var randomY = random(randomD, height-randomD/2);
var overlaps = false;
for (var i=0; i < circleX.length; i=i+1) {
var d = dist(randomX, randomY, circleX[i], circleY[i]);
if (d < randomD/2 + circleD[i]/2) {
overlaps = true;
print("overlaps");
break; // stops a loop prematurely
}
}
if (overlaps == false) {
ellipse(randomX, randomY, randomD, randomD);
circleX.push(randomX);
circleY.push(randomY);
circleD.push(randomD);
}
}