forked from andrewalbers/CardCreator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelement.pde
62 lines (58 loc) · 1.08 KB
/
element.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
public class Element
{
String name;
int type;
int x;
float realX;
int y;
float realY;
int wid;
float realWid;
int hei;
float realHei;
float hSquish = 1.0;
String fontString = ""; //this is a String for the font file to load.
PFont font;
int fontSize = 0;
String colorString = "FFFFFF";
color col = unhex("FFFFFFFF");
boolean selected = false;
boolean hovered = false;
Element (String nn, int tt, int xx, int yy, int ww, int hh)
{
name = nn;
type = tt;
x = xx;
realX = x;
y = yy;
realY = y;
wid = ww;
realWid = wid;
hei = hh;
realHei = hei;
}
/**
* Sets extra font variables if this is a text type element
*/
void setFont(String fstr, int fsiz, float hsq, String cstr)
{
fontString = fstr;
fontSize = fsiz;
font = loadFont(fstr);
hSquish = hsq;
colorString = cstr;
col = unhex("FF" + cstr);
}
void move( int dx, int dy )
{
realX += dx;
realY += dy;
}
void updatePosition()
{
x = int(realX);
y = int(realY);
wid = int(realWid);
hei = int(realHei);
}
}