-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.pde
43 lines (40 loc) · 901 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
abstract class Button {
int x;
int y;
int bWidth;
int bHeight;
color innerColor;
String text;
String name;
boolean mouseHover = false;
Button(int x, int y, int w, int h, color c, String t, String n) {
this.x = x;
this.y = y;
this.bWidth = w;
this.bHeight = h;
this.innerColor = c;
this.text = t;
this.name = n;
}
void update() {
mouseHover = false;
if (mouseX < x + bWidth &&
mouseX > x &&
mouseY < y + bHeight &&
mouseY > y) {
mouseHover = true;
}
}
void draw() {
fill(innerColor);
if (mouseHover) {
fill(color(min(red(innerColor)+50, 255), min(green(innerColor)+50, 255), min(blue(innerColor)+50, 255)));
}
rect(x, y, bWidth, bHeight);
textAlign(CENTER, CENTER);
textFont(arial_bold_30);
fill(255, 255, 255);
text(text, x, y, bWidth, bHeight);
update();
}
}