-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.pde
More file actions
45 lines (41 loc) · 929 Bytes
/
Copy pathButton.pde
File metadata and controls
45 lines (41 loc) · 929 Bytes
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
class Button {
float x,y;
int bW, bH;
int textSize;
boolean isHovering;
boolean isSelected;
String buttonText;
Button(float _x, float _y, int _width, int _height, String _buttonText, int _textSize){
x = _x;
y = _y;
bW = _width;
bH = _height;
buttonText = _buttonText;
textSize = _textSize;
}
void drawButton(){
noStroke();
rectMode(CORNER);
if (inside() || isSelected){
fill(#2c1752);
}else{
fill(#8376ff);
}
rect(x, y, bW, bH, 7); //draw the button and round the corners
textAlign(CENTER, CENTER); //centers text
if (inside() || isSelected){
fill(#ffffff);
}else{
fill(#000000);
}
textSize(textSize);
text(buttonText, x+(bW/2), y+(bH/2)-2);
}
boolean inside(){
if (mouseX >= x && mouseX <= x+bW && mouseY >= y && mouseY <= y+bH) {
return true;
} else {
return false;
}
}
}