-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkern.pde
48 lines (40 loc) · 840 Bytes
/
kern.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
int bg = 0xffffff;
String buff = "";
String t = "hello, kern!";
boolean lines = true;
void setup ()
{
size (displayWidth, 500);
background (bg);
fill (0);
}
void kernedText (String s, int k, int x, int y)
{
pushMatrix ();
for (char c : s.toCharArray ()) {
text (c, x, y);
if (lines) {
line (x, y, x + 20, y);
}
translate (k, 0);
}
popMatrix ();
}
void keyReleased ()
{
if (keyCode == ENTER || keyCode == RETURN) {
t = buff;
buff = "";
} else if (key == '`') {
lines = !lines;
} else {
buff += key;
}
}
void draw ()
{
background (bg);
text ("Hit enter to replace the text with what you type: " + buff, 0, 30);
text ("Type '`' to toggle the lines", 0, 50);
kernedText (t, mouseY, 0, height / 2);
}