-
Notifications
You must be signed in to change notification settings - Fork 0
/
smile.pde
executable file
·192 lines (181 loc) · 5.54 KB
/
smile.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
class Smiley extends visual {
String id;
//translations
int x, y;
//scale and fade
//fade is a number between 0 and 1 that will control the opacity
float s, f;
float wi, he;
float w = 20;
int radialSegments = 100;
float angle = PI/5;
float incr = 0.04;
float t = 0;
float sc = 3.5;
color[] faceColors = new color[5];
boolean hasCamSettings;
Smiley(String id, int x, int y, float s, float f, boolean hasCamSettings) {
super(id, x, y, s, f, true);
this.wi = x;
this.he = y;
colorMode(RGB);
this.hasCamSettings = hasCamSettings;
for (int i = 0; i < faceColors.length; i++) {
faceColors[i] = color(random(255), random(255), random(255));
}
}
void feed(Boolean [] t) {
if (t[0] == true){
faceColors[0] = color(random(255), random(255), random(255));
}
else if (t[1] == true){
faceColors[1] = color(random(255), random(255), random(255));
}
else if (t[2] == true){
faceColors[2] = color(random(255), random(255), random(255));
}
else if (t[3] == true){
faceColors[3] = color(random(255), random(255), random(255));
}
}
void show() {
//ortho(-width/2, width/2, -height/2, height/2);
background(0);
angle = t/10;
t += incr;
drawHollowCillinder(0, 0, 80, 100, faceColors[0]);
drawHollowCillinder(-27, -30, 0, 15, faceColors[1]);
drawHollowCillinder(27, -30, 0, 15, faceColors[2]);
drawArc(0, 40, 34, 50, faceColors[3]);
}
void addGui(ControlP5 cp5, int x, int y) {
}
void removeGui(ControlP5 cp5) {
}
void controlEvent(ControlEvent theEvent) {
}
float[] getCamSettings() {
float[] settings = new float[4];
settings[0] = x/2;
settings[1] = y/2;
settings[2] = x/2;
settings[3] = 700;
return settings;
}
void drawArc(float X, float Y, float r, float R, color c) {
float x, y, z;
pushMatrix();
scale(sc);
rotateY(angle);
translate(X, Y);
noStroke();
fill(c);
beginShape(QUAD_STRIP);
for (int i = 0; i < radialSegments+1; i++) {
x = r * cos(PI*(float(i)/float(radialSegments)));
y = r * sin(-PI*(float(i)/float(radialSegments)));
z = -w/2;
vertex(x, y, z);
x = r * cos(PI*(float(i)/float(radialSegments)));
y = r * sin(-PI*(float(i)/float(radialSegments)));
z = w/2;
vertex(x, y, z);
}
endShape();
beginShape(QUAD_STRIP);
for (int i = 0; i < radialSegments+1; i++) {
x = R * cos(PI*(float(i)/float(radialSegments)));
y = R * sin(-PI*(float(i)/float(radialSegments)));
z = -w/2;
vertex(x, y, z);
x = R * cos(PI*(float(i)/float(radialSegments)));
y = R * sin(-PI*(float(i)/float(radialSegments)));
z = w/2;
vertex(x, y, z);
}
endShape();
beginShape(QUAD_STRIP);
for (int i = 0; i < radialSegments+1; i++) {
x = r * cos(PI*(float(i)/float(radialSegments)));
y = r * sin(-PI*(float(i)/float(radialSegments)));
z = w/2;
vertex(x, y, z);
x = R * cos(PI*(float(i)/float(radialSegments)));
y = R * sin(-PI*(float(i)/float(radialSegments)));
z = w/2;
vertex(x, y, z);
}
endShape();
beginShape(QUAD_STRIP);
for (int i = 0; i < radialSegments+1; i++) {
x = r * cos(PI*(float(i)/float(radialSegments)));
y = r * sin(-PI*(float(i)/float(radialSegments)));
z = -w/2;
vertex(x, y, z);
x = R * cos(PI*(float(i)/float(radialSegments)));
y = R * sin(-PI*(float(i)/float(radialSegments)));
z = -w/2;
vertex(x, y, z);
}
endShape();
popMatrix();
}
void drawHollowCillinder(float X, float Y, float r, float R, color c) {
float x, y, z;
pushMatrix();
scale(sc);
rotateY(angle);
translate(X, Y);
fill(c);
noStroke();
beginShape(QUAD_STRIP);
for (int i = 0; i < radialSegments+1; i++) {
x = r * cos(2*PI*(float(i)/float(radialSegments)));
y = r * sin(2*PI*(float(i)/float(radialSegments)));
z = -w/2;
vertex(x, y, z);
x = r * cos(2*PI*(float(i)/float(radialSegments)));
y = r * sin(2*PI*(float(i)/float(radialSegments)));
z = w/2;
vertex(x, y, z);
}
endShape();
beginShape(QUAD_STRIP);
for (int i = 0; i < radialSegments+1; i++) {
x = R * cos(2*PI*(float(i)/float(radialSegments)));
z = -w/2;
y = R * sin(2*PI*(float(i)/float(radialSegments)));
vertex(x, y, z);
x = R * cos(2*PI*(float(i)/float(radialSegments)));
z = w/2;
y = R * sin(2*PI*(float(i)/float(radialSegments)));
vertex(x, y, z);
}
endShape();
beginShape(QUAD_STRIP);
for (int i = 0; i < radialSegments+1; i++) {
x = r * cos(2*PI*(float(i)/float(radialSegments)));
z = -w/2;
y = r * sin(2*PI*(float(i)/float(radialSegments)));
vertex(x, y, z);
x = R * cos(2*PI*(float(i)/float(radialSegments)));
z = -w/2;
y = R * sin(2*PI*(float(i)/float(radialSegments)));
vertex(x, y, z);
}
endShape();
beginShape(QUAD_STRIP);
for (int i = 0; i < radialSegments+1; i++) {
x = r * cos(2*PI*(float(i)/float(radialSegments)));
z = w/2;
y = r * sin(2*PI*(float(i)/float(radialSegments)));
vertex(x, y, z);
x = R * cos(2*PI*(float(i)/float(radialSegments)));
z = w/2;
y = R * sin(2*PI*(float(i)/float(radialSegments)));
vertex(x, y, z);
}
endShape();
popMatrix();
}
}