xxxxxxxxxx
63
var circles = [];
let size = 200;
let drawGate = false;
let counter = 0;
//let col = 100;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(255);
//colorMode(RGB, 100);
let newPos = createVector(random(width),random(height));
drawGate = true;
if(circles.length >= 1){
for(let circle of circles){
let distance = dist(newPos.x,newPos.y,circle.pos.x,circle.pos.y);
if(distance < (size/2+circle.size/2)){
drawGate = false;
}
}
}else{
drawGate = true;
}
if(drawGate){
append(circles,new Circle(newPos.x,newPos.y,size));
counter = 0;
}else{
counter ++;
}
for(let circle of circles){
circle.draw();
}
if(size == 1){
console.log("Finished");
noLoop();
}
if(counter >= 100){
size --;
//col --;
}
}
class Circle{
constructor(x,y,s){
this.pos = createVector(x,y);
this.size = s;
}
draw(){
stroke(0);
fill(200,100);
circle(this.pos.x,this.pos.y,this.size);
}
}