-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tail.pde
84 lines (71 loc) · 1.82 KB
/
Tail.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
76
77
78
79
80
81
82
83
84
//-------------------------- TAIL CLASS --------------------------//
class Tail {
float x, yTop, yBot, xMin, xMax, w, r, gz, s1, s2, yCircle;
color cF, cS, cH;
FloatList gzList;
//~~~ CONSTRUCTOR ~~~//
public Tail (float startX, float topY, float bottomY, float minX, float maxX, float weightLine, float radiusBigCircle, color colFillBigCircle, color colStroke, color colHalfCircle) {
x = startX;
yTop = topY;
yBot = bottomY;
xMin = minX;
xMax = maxX;
w = weightLine;
r = radiusBigCircle;
cF = colFillBigCircle;
cS = colStroke;
cH = colHalfCircle;
s1 = x;
s2 = x;
yCircle = yTop+(yBot-yTop)/2;
gzList = new FloatList();
fillList();
}
//~~~ DRAW ~~~//
void draw() {
gz = childrenR[pos].getFloat("gz");
float n1 = Normalise(xMin, xMax);
float boundsCircle = (xMax-xMin)/4;
float n2 = Normalise(xMin+boundsCircle, xMax-boundsCircle);
s1 = lerp(s1, n1, .1);
s2 = lerp(s2, n2, .1);
drawLine();
drawBigCircle();
drawSmallCircle();
}
//~~~ LINE TAIL ~~~//
void drawLine() {
big.stroke(cS);
big.strokeWeight(w);
big.noFill();
big.line(s1, yTop, x, yBot);
}
//~~~ BIG CIRCLE TAIL ~~~//
void drawBigCircle() {
big.stroke(cS);
big.strokeWeight(w);
big.fill(cF);
big.ellipse(s2, yCircle, r, r);
}
//~~~ SMALL CIRCLE TAIL ~~~//
void drawSmallCircle() {
big.noStroke();
big.fill(cH);
big.arc(s2, yCircle, r/2+w/2, r/2+w/2, -QUARTER_PI, HALF_PI+QUARTER_PI);
big.stroke(cS);
big.strokeWeight(w);
big.noFill();
big.ellipse(s2, yCircle, r/2, r/2);
}
//~~~ FILL LIST ~~~//
void fillList() {
for (int i = 0; i < childrenR.length; i++) {
gzList.append(childrenR[i].getFloat("gz"));
}
}
//~~~ NORMALISE ~~~//
float Normalise(float minVal, float maxVal) {
float normVal = map(gz, gzList.min(), gzList.max(), minVal, maxVal);
return normVal;
}
}