-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextLabel.pde
More file actions
42 lines (32 loc) · 884 Bytes
/
TextLabel.pde
File metadata and controls
42 lines (32 loc) · 884 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
class TextLabel extends SceneElement {
// ----- Fields
public Color tint = new Color(0);
public int alpha = 255;
public int outlineThickness;
public Color outlineColor = new Color(0);
private final int textSize;
protected String message;
// ----- Constructors
public TextLabel(String message, int textSize) {
this.message = message;
this.textSize = textSize;
}
// ----- Methods
@Override
public void draw() {
textAlign(CENTER, CENTER);
textSize(textSize);
drawOutline();
fill(tint, alpha);
text(message, 0, 0);
}
private void drawOutline() {
if (alpha < 25) return;
fill(outlineColor, alpha);
for (int dx = -outlineThickness; dx <= outlineThickness; dx++) {
for (int dy = -outlineThickness; dy <= outlineThickness; dy++) {
text(message, dx, dy);
}
}
}
}