graphpaperLogo

graphpaper.ps

Download

Current version: 1.0

graphpaper.ps (2.8 KB)

To use it:

Send it to a printer. The printer will know what to do.

On Windows: Start->Settings->Printers, then drag this file onto a printer icon. If that doesn't work, try downloading this program: http://www.cs.wisc.edu/~ghost/
On UNIX: lpr [-Pprinter] graphpaper.ps
On Macintosh: If you have a printer icon on your desktop, drag graphpaper.ps onto it. Or, try this: select graphpaper.ps, then click File->Print. If those don't work, try downloading this program: http://www.cs.wisc.edu/~ghost/

What is it?

graphpaper.ps is a program that prints graph paper. Here's the story:

I was sitting around one day, and I wanted sketch some things out in a relatively precise way (I think I was trying to lay out some furniture or something). I knew exactly what I needed: graph paper! Unfortunately, I didn't have any on me, it was too late to buy some somewhere, and why on earth would I buy graph paper when there's a 600dpi printer down the hall?

So I figured, surely there's a decent, free, graph paper-printing program on the web. Alas, I was wrong. A bunch of people have crappy gifs and jpegs that you can print out, and there are a few programs out there for printing graph paper (some of them even have an unbelievable number of cool features). None of them, unfortunately, would produce print-outs that were of reasonable quality, given the high resolution device I had on hand.

Being the stubborn person that I am, I figured I would just have to produce my own graph paper, and the program downloadable above is the result. The beauty, of course, is that the program is written in PostScript, which is a language that almost every modern printer in the world understands. This allows a very compact and parameterizable representation of the graph paper to be sent to the printer, which then produces the image with exactly as much precision as it's capable of. To see a much more interesting use of this idea, try this postscript raytracer.

FAQ

What is graphpaper.ps?

See above.

How much does graphpaper.ps cost?

It's FREE.  Enjoy.

Where do I report bugs, give feedback, and heap praise?

Please send all bugs, etc. to jason@jasonpratt.org.  No promises on actually doing anything, but I'll at least listen.

Where can I get the source?

See below

Who is Jason Pratt?

I wrote graphpaper.ps.  You can find out more about me here: http://jasonpratt.org/about/

Source code

In case you didn't realize that you can simply open up graphpaper.ps in a text editor and look at it, here's the source code:

%!

%
% graphpaper.ps  version 1.0
% (c) 2001 Jason Pratt; All rights reserved
% Free to use and redistribute.
% http://jasonpratt.org/software/graphpaper/
%

%
% How to use this program:
%
% Send it to a printer.  The printer will know what to do.
%
% On Windows: Start->Settings->Printers, then drag this file onto
%             a printer icon.  If that doesn't work, try downloading
%             this program: http://www.cs.wisc.edu/~ghost/
% On UNIX: lpr [-Pprinter] graphpaper.ps
% On Macintosh: If you have a printer icon on your desktop, drag
%               graphpaper.ps onto it.  Or, try this:
%               select graphpaper.ps, then click File->Print.
%               If those don't work, try downloading this program:
%               http://www.cs.wisc.edu/~ghost/
%
% If you have better instructions for printing postscript on any
% platform, please let me know: jason@jasonpratt.org
%
%
% If you're feeling frisky, you can play with the options below
%


%
% Note: all units of distance in this file are in millimeters,
%

% major: defines the spacing, in mm, between each major-line of the graph paper.
/major 30 def

% minor: defines the number of minor-lines to print for each major-line.
/minor 10 def

% majorWidth and minorWidth: define the width, in mm, of each major and minor line, respectively.
% 0 (zero) is a special value representing a "hairline", which is the thinnest possible
% line that the PostScript device is able to render.  I highly recommend using this for
% precise graphpaper.
/majorWidth 0 def
/minorWidth 0 def

% majorGray and minorGray: define the shade of gray to use for major and minor lines, respectively.
% 0 is black, 1 is white, and everything else is in-between.  Some printers don't print arbitrary
% shades of gray very well, so I recommend sticking with 0.0 or 0.5.
/majorGray 0.0 def
/minorGray 0.5 def

% pageWidth and pageHeight: define the width and height of the page in mm, respectively.
% currently set for A4 (210 by 297)
% 8.5in by 11in is (215.9 by 279.4)
/pageWidth 210 def
/pageHeight 297 def


% scale for metric units
254 72 div dup scale

% params: x, y, lineWidth, gray
/drawLine {
  gsave
  setgray
  setlinewidth
  rlineto
  closepath
  stroke
  grestore
} bind def

gsave
0 major pageHeight {
  1 1 minor 1 sub {
    /i exch def
    /y i minor div major mul def
    0 y moveto
    pageWidth 0 minorWidth minorGray drawLine
  } for
  0 0 moveto
  pageWidth 0 majorWidth majorGray drawLine
  0 major translate
} for
grestore

0 major pageWidth {
  1 1 minor 1 sub {
    /i exch def
    /x i minor div major mul def
    x 0 moveto
    0 pageHeight minorWidth minorGray drawLine
  } for
  0 0 moveto
  0 pageHeight majorWidth majorGray drawLine
  major 0 translate
} for

stroke
showpage
quit
jasonpratt.org