forked from Pomax/Pjs-2D-Game-Engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debugfunctions.pde
executable file
·38 lines (35 loc) · 976 Bytes
/
debugfunctions.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
/**
* Debug function for drawing bounding boxes to the screen.
*/
static void debugfunctions_drawBoundingBox(float[] bounds, PApplet sketch) {
sketch.stroke(255,0,0);
sketch.fill(0,50);
sketch.beginShape();
for(int i=0, last=bounds.length; i<last; i+=2) {
sketch.vertex(bounds[i],bounds[i+1]);
}
sketch.endShape(CLOSE);
}
/**
* Draw a nice looking grid
*/
void debugfunctions_drawBackground(float width, float height) {
background(255,255,252);
strokeWeight(1);
fill(0);
// fine grid
stroke(235);
float x, y;
for (x = -width; x < width; x += 10) {
line(x,-height,x,height); }
for (y = -height; y < height; y += 10) {
line(-width,y,width,y); }
// coarse grid
stroke(208);
for (x = -width; x < width; x += 100) {
line(x,-height,x,height); }
for (y = -height; y < height; y += 100) {
line(-width,y,width,y); }
// reset to black
stroke(0);
}