Graph paper
Jul. 24th, 2004 11:21 pmI balked at the idea of actually learning to write a Windows application, or any kind of usable PC application for that matter (I have about one day's experience with Cocoa on the Mac), but then realized that I didn't have to do that. I could just write a very simple PostScript program with easy-to-customize parameters, which for reasons of my former employment I am actually able to do, and Sam was more than capable of editing it and running Ghostscript to print it out. This evening I spent a few minutes banging it out.
%!PS
%
% graph.ps, Matt McIrvin, July 2004
%
% A customizable sheet of graph paper for Sam's knitting.
/unit /in def % possible values: in or cm
/length 4 def % the length over which the number of stitches is defined
/stitchesX 25 def % stitches in the horizontal direction
/stitchesY 25 def % stitches in the vertical direction
0 setgray % lightness of the lines; 0 means black
% Replace this line with <r> <g> <b> setrgbcolor,
% <c> <m> <y> <k> setcmykcolor for other options;
% 1 0 0 0 setcmykcolor is light blue-green (cyan)
0 setlinewidth % line width in points (1/72 inch)
% zero here means a single-pixel hairline
/lengthPts
unit /in eq
{
length 72 mul
}
{
length 2.54 div 72 mul
}
ifelse
def
/pageWidth 8.5 72 mul def
/pageHeight 11 72 mul def
% draw the vertical lines
0
lengthPts stitchesX div
pageWidth
{
dup 0 moveto pageHeight lineto stroke
}
for
% draw the horizontal lines
0
lengthPts stitchesY div
pageHeight
{
dup 0 exch moveto pageWidth exch lineto stroke
}
for
showpage