You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
517 B
27 lines
517 B
class Circle{
|
|
|
|
constructor(x, y, r){
|
|
this.x = x;
|
|
this.y = y;
|
|
this.r = r;
|
|
this.done = false;
|
|
this.valid = true;
|
|
}
|
|
|
|
draw(){ellipse(this.x, this.y, this.r * 2, this.r * 2);}
|
|
|
|
grow(){this.r ++;}
|
|
|
|
touchesEdges(){
|
|
if (this.x + this.r > windowWidth || this.x - this.r < 0
|
|
|| this.y + this.r > windowHeight || this.y - this.r < 0) return true;
|
|
}
|
|
|
|
touchesCircle(){
|
|
for (var c of circles){
|
|
if (c == this) continue;
|
|
if (dist(this.x, this.y, c.x, c.y) < this.r + c.r) return true;
|
|
}
|
|
}
|
|
|
|
} |