-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathState.pde
45 lines (38 loc) · 898 Bytes
/
State.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
class State extends Canvas {
private int mX, mY;
private int mWidth, mHeight;
private color mColorDefault;
private color mColorText;
private color mColorActual;
private String mText;
// Constructor
State(int x, int y, int _width, int _height, color colorDefault) {
mX = x;
mY = y;
mWidth = _width;
mHeight = _height;
mColorDefault = colorDefault;
mColorActual = colorDefault;
mText = "";
}
// Draw
public void draw(PGraphics pg) {
pg.fill(mColorActual);
pg.rect(mX, mY, mWidth, mHeight);
pg.fill(mColorText);
pg.textAlign(CENTER);
pg.textSize(14);
pg.text(mText, mX + mWidth/2, mY + mHeight/1.4);
}
public void reset() {
mColorActual = mColorDefault;
mText = "";
}
/*
** Set
*/
public void setState(color colorActual, String text) {
mColorActual = colorActual;
mText = text;
}
}