-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDisplaySourceCode.pde
More file actions
54 lines (43 loc) · 1.08 KB
/
Copy pathDisplaySourceCode.pde
File metadata and controls
54 lines (43 loc) · 1.08 KB
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
class DisplaySourceCode extends AbstractDisplay {
String FILE_NAME = "sourcecode.txt";
String [] lines;
float fontSize = 8;
float waitDx;
float curFrame = 0;
int lineIndex = 0;
PGraphics lg;
float y = 0;
float lineSpacing = 0;
float inset = 8;
DisplaySourceCode(ARect b) {
super(b);
lines = loadStrings(FILE_NAME);
waitDx = 0.025 * frameRate;
lg = createGraphics(b);
}
void draw(PGraphics g) {
if(super.hidden) return;
if (lineIndex >= lines.length){
lineIndex = 0;
}
lg.beginDraw();
lg.textSize(fontSize);
if (curFrame >= waitDx) {
curFrame = 0;
lg.fill(0,250);
lg.rect(inset,0, bound.width, fontSize + inset + lineSpacing);
lg.fill(colorFromMap());
lg.noStroke();
lg.text(lines[lineIndex++], bound.width * 0.6 + inset, y);
y += inset + lineSpacing;
if (y > bound.height - inset) {
y = inset;
lg.background(0, 100);
curFrame = 0;
}
}
curFrame++;
lg.endDraw();
drawOn(lg,g,bound);
}
}