-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLine.pde
67 lines (50 loc) · 1.23 KB
/
Line.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
class Line {
String str;
float textsize;
color textcolor;
float linewidth;
float xPos, yPos;
boolean important;
float rotation;
int number;
Line () {
update("");
}
void update(String _str) {
str = _str;
textsize = random(135, 150);
textcolor = color(0);
important = false;
if (random(1)>0.8) { // bigger text and red
important = true;
}
linewidth = textWidth (str);
textSize(textsize);
while (textWidth (str) > width*0.85) { // fit it into width
textsize--;
linewidth = textWidth (str);
textSize(textsize);
}
rotation = random(radians(-4), radians(4));
}
void calculatePosition() {
xPos = random(-30,10);
yPos = -lineheight*(lines.length+1)/2+(lineheight*(number+1)) - height*0.05;
}
void render() {
noStroke();
fill(textcolor);
textSize(textsize);
pushMatrix();
translate(width/2 + xPos, height/2 + yPos);
rotate(rotation);
text(str, 0, 0);
if (important) { // underline for text
stroke(0);
//if (important) stroke(0, 100, 100);
strokeWeight(15);
line(-textWidth(str)/2*0.9, textsize*0.4+10, textWidth(str)/2, textsize*0.4*0.95+10);
}
popMatrix();
}
}