-
Notifications
You must be signed in to change notification settings - Fork 0
/
Slider.pde
61 lines (54 loc) · 1.03 KB
/
Slider.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
class slider {
private String txt;
private int x, y, w, h;
private float slValue;
private int value;
private color backgroundColor, txtColor, Color;
public slider(int _x, int _y, int _w, int _h, color _Color, color _txtColor, String _txt){
x=_x;
y=_y;
w=_w;
h=_h;
backgroundColor=color(_Color,90);
Color=_Color;
txtColor=_txtColor;
txt = _txt;
}
void setPosition(int _x, int _y) {
x=_x;
y=_y;
}
void setSize(int _w, int _h) {
w=_w;
h=_h;
}
void setText(String _txt) {
txt=_txt;
}
int getValue(){
return value;
}
void setColors(color _Color, color _txtColor) {
backgroundColor=color(_Color,90);
Color=_Color;
txtColor=_txtColor;
}
void show() {
fill(backgroundColor);
rect(x,y,w,h,30);
pushMatrix();
translate(x,y);
fill(Color);
rect(0,0,slValue,h,30);
fill(txtColor);
text(txt, w/2, (1.3*h)/2);
popMatrix();
if (mouseX>x && mouseX<x+w && mouseY>y && mouseY<y+h) {
if (mousePressed) {
slValue=mouseX-x;
if(slValue>=w-1)slValue=w;
value=(int)slValue*100/w;
}
}
}
}