-
Notifications
You must be signed in to change notification settings - Fork 1
/
TextUtils.pde
66 lines (52 loc) · 1.19 KB
/
TextUtils.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
public class TextUtils
{
private String _text;
private Integer _x, _y, _colour, _outlineColour, _size, _hAlign = LEFT, _vAlign = BOTTOM;
private Boolean _outline;
TextUtils() {
_size = 10;
_colour = 0;
_outline = false;
}
public void Text(String text, Integer x, Integer y) {
_text = text;
_x = x;
_y = y;
Display();
};
public TextUtils Size(Integer size) {
_size = size;
return this;
}
public TextUtils Colour(Integer colour) {
_colour = colour;
return this;
}
public TextUtils OutlineColour(Integer outlineColour) {
_outlineColour = outlineColour;
_outline = true;
return this;
}
public TextUtils Align(Integer hAlign, Integer vAlign) {
_hAlign = hAlign;
_vAlign = vAlign;
return this;
}
public Integer TextWidth(String text) {
textSize(_size);
return round(textWidth(text));
}
private void Display() {
textSize(_size);
textAlign(_hAlign, _vAlign);
if (_outline) {
fill(_outlineColour);
text(_text, _x - 1, _y);
text(_text, _x + 1, _y);
text(_text, _x, _y - 1);
text(_text, _x, _y + 1);
}
fill(_colour);
text(_text, _x, _y);
}
}