-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVertex.js
38 lines (30 loc) · 794 Bytes
/
Vertex.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Vertex {
constructor(num, x, y) {
this.num = num;
this.x = x;
this.y = y;
this.r = vertexRadius;
}
move(x, y) {
this.x = x;
this.y = y;
}
mouseIn() {
return dist(this.x, this.y, mouseX, mouseY) <= this.r;
}
// update() {
// if (this.mouseIn()) this.clicked();
// }
// clicked() {
// }
display() {
stroke(0, this.mouseIn() ? 255 : 50); strokeWeight(3); fill(255);
circle(this.x, this.y, 2 * this.r);
textAlign(CENTER, CENTER); textSize(30); fill(0, this.mouseIn() ? 255 : 50); noStroke();
text(this.num, this.x, this.y);
}
highlight() {
stroke(255, 0, 0); noFill();
circle(this.x, this.y, 2 * this.r);
}
}