-
Notifications
You must be signed in to change notification settings - Fork 0
/
roundButton.pde
59 lines (56 loc) · 1.08 KB
/
roundButton.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
class roundButton{
private String label, onText, offText;
private int x,y,d1,d2,txtSize;
private boolean value;
private color backgroundColor, Color, txtColor;
roundButton(int _x, int _y, int _d1, int _d2, color _Color, color _txtColor, String _offText, String _onText){
x=_x;
y=_y;
d1=_d1;
d2=_d2;
Color=_Color;
backgroundColor=color(_Color,90);
txtColor=_txtColor;
offText=_offText;
onText=_onText;
label=_offText;
}
boolean getValue(){
return value;
}
void setColors(color _Color, color _txtColor){
Color=_Color;
txtColor=_txtColor;
}
void setPosition(int _x, int _y) {
x=_x;
y=_y;
}
void setSize(int _d1, int _d2) {
d1=_d1;
d2=_d2;
}
void setText(String _offText, String _onText) {
offText=_offText;
onText=_onText;
}
void show(){
float dist=dist(x,y,mouseX,mouseY);
if (dist<d1/2 && dist<d2/2) {
if (mousePressed){
label=onText;
backgroundColor=Color;
value=true;
}else{
label=offText;
backgroundColor=color(Color,90);
value=false;
}
}
fill(backgroundColor);
ellipse(x,y,d1,d2);
fill(txtColor);
textAlign(CENTER);
text(label,x,y);
}
}