-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHilbertNode.pde
51 lines (44 loc) · 1.01 KB
/
HilbertNode.pde
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
41
42
43
44
45
46
47
48
49
50
51
class HilbertNode {
float x,y;
float d;
float fat;
ArrayList<HilbertNode> cons = new ArrayList<HilbertNode>();
HilbertNode(float _x, float _y, float _d, float _fat) {
x = _x;
y = _y;
d = _d;
fat = _fat;
}
void renderGlow(float val) {
fill(255,22);
noStroke();
for (int k=0;k<3;k++) {
pushMatrix();
translate(x,y);
rotate(random(TWO_PI));
scale(1 - val*log(random(1.0)));
rect(-d/2,-d/2,d,d);
popMatrix();
}
}
void renderBase() {
fill(scolorVoid);
strokeWeight(fat);
stroke(scolorEdge);
ellipse(x,y,d+4,d+4);
}
void renderNode() {
fill(scolorNode);
noStroke();
ellipse(x,y,2+d/3,2+d/3);
}
void renderConnections(float val) {
noFill();
stroke(255,128);
for (HilbertNode nd:cons) if (random(1.0)<val) line(x,y,nd.x,nd.y);
}
boolean isConnectedTo(HilbertNode b) {
if (cons.contains(b)) return true;
return false;
}
}