forked from biomurph/PulseSensor_Visualizer_Record_Playback
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathradioButtons.pde
More file actions
60 lines (54 loc) · 1.17 KB
/
radioButtons.pde
File metadata and controls
60 lines (54 loc) · 1.17 KB
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
class Radio {
int _x,_y;
int size, dotSize;
color baseColor, overColor, pressedColor;
boolean over, pressed;
int me;
Radio[] radios;
Radio(int xp, int yp, int s, color b, color o, color p, int m, Radio[] r) {
_x = xp;
_y = yp;
size = s;
dotSize = size - size/3;
baseColor = b;
overColor = o;
pressedColor = p;
radios = r;
me = m;
}
boolean pressRadio(float mx, float my){
if (dist(_x, _y, mx, my) < size/2){
for(int i=0; i<numPorts+1; i++){
radios[i].pressed = true;
if(i != me){ radios[i].pressed = false; }
}
return true;
} else {
return false;
}
}
boolean overRadio(float mx, float my){
if (dist(_x, _y, mx, my) < size/2){
for(int i=0; i<numPorts+1; i++){
radios[i].over = true;
if(i != me){ radios[i].over = false; }
}
return true;
} else {
return false;
}
}
void displayRadio(){
noStroke();
fill(baseColor);
ellipse(_x,_y,size,size);
if(over){
fill(overColor);
ellipse(_x,_y,dotSize,dotSize);
}
if(pressed){
fill(pressedColor);
ellipse(_x,_y,dotSize,dotSize);
}
}
}