-
Notifications
You must be signed in to change notification settings - Fork 0
/
CloudsRenderer.pde
75 lines (61 loc) · 1.66 KB
/
CloudsRenderer.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import java.util.Collections;
class CloudsRenderer {
private VenationAlgorithm _va;
private PGraphics _g;
private int _size;
private color _c;
ArrayList<Integer> _reindex;
ArrayList<Float> _radii;
CloudsRenderer(VenationAlgorithm va, PGraphics g, int size, int c) {
_va = va;
_g = g;
_size = size;
_c = c;
_reindex = new ArrayList<Integer>();
_radii = new ArrayList<Float>();
}
void draw() {
VeinNode veinNode;
PVector p;
float rw, rh;
Object[] veinNodes = _va.getVeinNodes().toArray();
int numVeinNodes = veinNodes.length;
fillPoints();
_g.fill(_c);
_g.stroke(0);
_g.strokeWeight(2);
for (int i = 0; i < numVeinNodes; i++) {
veinNode = (VeinNode)veinNodes[_reindex.get(i)];
p = veinNode.getPositionRef();
rw = _radii.get(2*i);
rh = _radii.get(2*i+1);
_g.ellipse(_size * p.x, _size * p.y, rw, rh);
}
fill(_c);
noStroke();
for (int i = 0; i < numVeinNodes; i++) {
veinNode = (VeinNode)veinNodes[_reindex.get(i)];
p = veinNode.getPositionRef();
rw = _radii.get(2*i);
rh = _radii.get(2*i+1);
_g.ellipse(_size * p.x, _size * p.y, rw*0.8, rh*0.8);
}
}
void drawPoint(float x, float y) {
_g.line(x, y, x, y + 4);
}
private void fillPoints() {
float r;
int numPoints = _va.numVeinNodes();
while (_radii.size() < numPoints * 2) {
r = 25 + random(1) * 10;
_radii.add(r);
_radii.add(r * (1 + (2*random(1)-1) * 0.1));
}
_reindex = new ArrayList<Integer>();
while (_reindex.size() < numPoints) {
_reindex.add(_reindex.size());
}
Collections.shuffle(_reindex);
}
}