-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEdge.pde
More file actions
40 lines (37 loc) · 781 Bytes
/
Edge.pde
File metadata and controls
40 lines (37 loc) · 781 Bytes
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
39
40
class Edge {
int w;
Node A, B;
int direction;
float ratio;
boolean visited;
Edge(int _w, Node _A, Node _B) {
w = _w;
A = _A;
B = _B;
direction = 0;
ratio = 1;
visited = false;
}
void move() {
ratio += animation_velocity*direction;
if (ratio > 1) {
ratio = 1;
direction = 0;
} else if (ratio < 0) {
ratio = 0;
direction = 0;
}
}
void show() {
if (w != 0) {
fill(255);
text(w, abs(A.pos.x - B.pos.x), abs(A.pos.y - A.pos.y));
}
stroke(edge_col);
strokeWeight(str_weight_edge);
PVector l = PVector.sub(B.pos, A.pos);
l.mult(ratio);
PVector end = PVector.add(A.pos, l);
line(A.pos.x, A.pos.y, end.x, end.y);
}
}