Now’s a good time to introduce a little documentation to your programming. Words appearing after a % are comments. (It’s just me, but I like to make them all caps.)

Run the following program in Distiller or Preview to make a PDF file, or in Ghostscript to make an image. You’ll see that all the lines end up running through the exact center of the page:

0 396 moveto 612 396 lineto % HORIZ LINE HALFWAY UP THE PAGE
306 0 moveto 306 792 lineto % VERTICAL LINE HALFWAY OVER
0 0 moveto 612 792 lineto % DIAGONAL LINE UP
0 792 moveto 612 0 lineto % DIAGONAL LINE DOWN
showpage % SEND TO OUTPUT


We need stroke to paint the current path. It expects nothing on the stack and doesn’t push anything onto the stack. The showpage command doesn’t expect any arguments either. It finally creates the PDF file or image.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s