-
Notifications
You must be signed in to change notification settings - Fork 1
/
Radio.pde
54 lines (49 loc) · 1.06 KB
/
Radio.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
////////////////////
//
// This class creates and manages a button for use on the screen to trigger actions.
//
// Created: Irene Vigue Guix, May 2016.
//
// Based on Processing's "Radio" example code
//
////////////////////
class Radio {
int x, y;
int size, dotSize;
color baseGray, dotGray;
boolean checked = false;
int me;
Radio[] others;
Radio (int xp, int yp, int s, color b, color d, int m, Radio[] o) {
x = xp;
y = yp;
size = s;
dotSize = size - size/3;
baseGray = b;
dotGray = d;
others = o;
me = m;
}
boolean press (float mx, float my) {
if (dist(x, y, mx, my)< size/2) {
checked = true;
for (int i=0; i< others.length; i++) {
if (i!=me) {
others[i].checked = false;
}
}
return true;
} else {
return false;
}
}
void display() {
noStroke();
fill(baseGray);
ellipse(x, y, size, size);
if (checked == true) {
fill(dotGray);
ellipse(x, y, dotSize, dotSize);
}
}
}