-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.pde
47 lines (41 loc) · 999 Bytes
/
button.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
class button {
int xPos = 0;
int yPos = 0;
int myWidth;
int myHeight;
String label;
color backgroundColor = color(80, 80, 80);
color inactiveColor = color(150, 150, 150);
color forgroundColor = color(200, 200, 200);
int pressed = 0;
button(int xPos, int yPos, int myWidth, int myHeight, String label) {
this.xPos = xPos;
this.yPos = yPos;
this.myWidth = myWidth;
this.myHeight = myHeight;
this.label = label;
}
void draw() {
pushMatrix();
translate(xPos, yPos);
noStroke();
fill(backgroundColor);
rect(0, 0, myWidth, myHeight, 8);
fill(forgroundColor);
textFont(myFontUI);
textSize(20);
textAlign(CENTER, CENTER);
text(label,myWidth/2, myHeight/2);
fill(backgroundColor);
popMatrix();
}
void mousePressed() {
if (insideRect(mouseX, mouseY, xPos, yPos, myWidth, myHeight)) { //<>//
pressed = 1;
}
}
void changeLabel(String label)
{
this.label = label;
}
}