-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDebug.pde
More file actions
99 lines (74 loc) · 1.64 KB
/
Copy pathDebug.pde
File metadata and controls
99 lines (74 loc) · 1.64 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
PFont debugFont;
int debugFontSize = 12;
int debug_y = debugFontSize;
float framesToShowLogEntries = 24;
color C_RED = color(200,0,0,200);
color C_WHITE = color(200,200);
color C_PINK = color(244,0,245);
color C_GREEN = color(0,220,0);
PGraphics logG;
ArrayList<LogEntry> logList = new ArrayList();
class LogEntry {
String text; //<>//
color colour; //<>//
LogEntry(String s, color c){
this.text = s;
this.colour = c;
}
}
void _addLogList(String s, color c) {
if (logList.size() > 50) {
logList = new ArrayList();
}
LogEntry e = new LogEntry(s,c);
logList.add(e);
}
void pdebug(String txt) {
pdebug(txt,C_WHITE);
}
void pdebug(String txt, color c) {
if(DEBUG) {
_addLogList(txt, C_WHITE);
println(txt);
}
}
void showLogList(PGraphics g) {
if(!DEBUG) return;
if(int(frameCount) % int(framesToShowLogEntries) == 0) {
logG = createGraphics(width,height);
logG.beginDraw();
logG.textSize(debugFontSize);
logG.translate(5,0);
for(LogEntry e: logList) {
logG.fill(e.colour);
logG.text(e.text, 0, 0);
logG.translate(0, debugFontSize);
}
logG.endDraw();
}
if (DEBUG){
g.push();
g.image(logG, 0, 0);
g.pop();
}
}
void pdebug(String txt, int x, int y, PGraphics g) {
if (DEBUG)
pdebug(txt,x,y,g, color(255));
}
void pdebug(String txt, int x, int y, PGraphics g, color c) {
if(!DEBUG) return;
g.push();
g.textSize(debugFontSize);
g.fill(c);
g.text(txt, x, y);
g.pop();
}
void debugRed(String txt, int x, int y, PGraphics g) {
if(!DEBUG) return;
g.push();
g.textSize(debugFontSize);
g.fill(255,0,0);
g.text(txt, x, y);
g.pop();
}