-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCusromGrid.pde
42 lines (39 loc) · 1003 Bytes
/
CusromGrid.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
class CustomGrid{
CustomGrid(){
}
int largeText = 26;
void draw(int xGrid, int yGrid){
background(0);
float gw = 1.0*width/xGrid;
float gh = 1.0*height/yGrid;
// sub grid
stroke(127);
strokeWeight(1.0);
for(int x = 0; x < xGrid; ++x){
line((x+0.5)*gw, 0, (x+0.5)*gw, height);
}
for(int y = 0; y < yGrid; ++y){
line(0, (y+0.5)*gh, width, (y+0.5)*gh);
}
// main grid
stroke(255);
strokeWeight(2.0);
for(int x = 0; x <= xGrid; ++x){
line(x*gw, 0, x*gw, height);
}
for(int y = 0; y <= yGrid; ++y){
line(0, y*gh, width, y*gh);
}
textFont(font);
textSize(largeText);
fill(255);
textAlign(CENTER, CENTER);
text("0,0", gw/4.0, gh/4.0);
textAlign(CENTER, CENTER);
text("1,0", width-gw/4.0, gh/4.0);
textAlign(CENTER, CENTER);
text("0,1", gw/4.0, height-gh/4.0);
textAlign(CENTER, CENTER);
text("1,1", width-gw/4.0, height-gh/4.0);
}
}