-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.pde
81 lines (65 loc) · 1.48 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class Button {
float x, y, w, h;
Button(float x, float y, float w, float h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
boolean mouseOver() {
return (mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h);
}
void draw() {
stroke(80);
fill(mouseOver() ? 255 : 220);
rect(x,y,w,h);
}
}
class ZoomButton extends Button {
boolean in = false;
ZoomButton(float x, float y, float w, float h, boolean in) {
super(x, y, w, h);
this.in = in;
}
void draw() {
super.draw();
stroke(0);
line(x+3,y+h/2,x+w-3,y+h/2);
if (in) {
line(x+w/2,y+3,x+w/2,y+h-3);
}
}
}
class PanButton extends Button {
int dir = UP;
PanButton(float x, float y, float w, float h, int dir) {
super(x, y, w, h);
this.dir = dir;
}
void draw() {
super.draw();
stroke(0);
switch(dir) {
case UP:
line(x+w/2,y+3,x+w/2,y+h-3);
line(x-3+w/2,y+6,x+w/2,y+3);
line(x+3+w/2,y+6,x+w/2,y+3);
break;
case DOWN:
line(x+w/2,y+3,x+w/2,y+h-3);
line(x-3+w/2,y+h-6,x+w/2,y+h-3);
line(x+3+w/2,y+h-6,x+w/2,y+h-3);
break;
case LEFT:
line(x+3,y+h/2,x+w-3,y+h/2);
line(x+3,y+h/2,x+6,y-3+h/2);
line(x+3,y+h/2,x+6,y+3+h/2);
break;
case RIGHT:
line(x+3,y+h/2,x+w-3,y+h/2);
line(x+w-3,y+h/2,x+w-6,y-3+h/2);
line(x+w-3,y+h/2,x+w-6,y+3+h/2);
break;
}
}
}