Comments

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:

%!PS
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
stroke % PAINT THE CURRENT PATH
showpage % SEND TO OUTPUT

Lines

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.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s