Last active
August 29, 2015 14:17
-
-
Save ordnungswidrig/f04ea5d9d4c975819410 to your computer and use it in GitHub Desktop.
Print rectangular grid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%!PS-Adobe-3.0 | |
% %%BoundingBox: 0 0 595 842 | |
/inch {72 mul} def | |
/cm {2.54 div inch} def | |
/grid { % stack: grid-size, width, height | |
/h exch def | |
/w exch def | |
/s exch def | |
/width w h lt {w} {h} ifelse def | |
/height w h lt {h} {w} ifelse def | |
/size s cm def | |
/minor 10 def | |
/msize size minor div def | |
gsave | |
% a4 | |
/offx 595 width size mul sub 2 div def | |
/offy 842 height size mul sub 2 div def | |
offx offy translate | |
0 -30 moveto | |
24 scalefont | |
setfont | |
height 2 string cvs show | |
(x) show | |
width 2 string cvs show | |
( \() show | |
s 10 string cvs show | |
(cm\)) show | |
1 setlinewidth | |
0 0 moveto | |
0.6 setgray | |
0 1 height minor mul | |
{ | |
/counter exch def | |
/y counter msize mul def | |
counter minor mod 0 ne { | |
newpath | |
0 y moveto | |
width size mul y lineto | |
closepath | |
stroke | |
} if | |
} for | |
0 1 width minor mul | |
{ | |
/counter exch def | |
/x counter msize mul def | |
counter minor mod 0 ne { | |
newpath | |
x 0 moveto | |
x height size mul lineto | |
closepath | |
stroke | |
} if | |
} for | |
0 setgray | |
0 1 height | |
{ | |
/counter exch def | |
/y counter size mul def | |
newpath | |
0 y moveto | |
width size mul y lineto | |
closepath | |
stroke | |
} for | |
0 1 width | |
{ | |
/counter exch def | |
/x counter size mul def | |
newpath | |
x 0 moveto | |
x height size mul lineto | |
closepath | |
stroke | |
} for | |
grestore | |
} def | |
/Helvetica findfont | |
1 8 4 grid % grid size in cm, width and height (will always print in portrait) | |
showpage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment