-
Notifications
You must be signed in to change notification settings - Fork 1
/
Debugger.pde
48 lines (43 loc) · 897 Bytes
/
Debugger.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
/*
* Prints text on top of everything for real-time object tracking.
*/
class Debugger{
private ArrayList strings;
private PFont font;
private int fontSize;
private boolean isOn;
public Debugger(){
isOn = true;
strings = new ArrayList();
fontSize = 15;
font = createFont("Arial", fontSize);
}
public void addString(String s){
if(isOn){
strings.add(s);
}
}
/*
* Should be called after every frame
*/
public void clear(){
strings.clear();
}
/**
If the debugger is off, it will ignore calls to addString and draw saving
some processing time.
*/
public void toggle(){
isOn = !isOn;
}
public void draw(){
if(isOn){
int y = 20;
fill(255);
for(int i = 0; i < strings.size(); i++, y+=fontSize){
textFont(font);
text((String)strings.get(i),0,y);
}
}
}
}