Post Script

The PostScript Format

Links to tutorials etc.

Simple example of drawing lines and rectangles

%!
%% Draws a one square inch box and inch in from the bottom left

/inch {72 mul} def      % Convert inches->points (1/72 inch)

newpath                 % Start a new path
1 inch 1 inch moveto    % an inch in from the lower left
2 inch 1 inch lineto    % bottom side
2 inch 2 inch lineto    % right side
1 inch 2 inch lineto    % top side
closepath               % Automatically add left side to close path
stroke                  % Draw the box on the paper
% 2)
5E-1 setgray            % set color for next action(s) (50% gray)
newpath                 % Start a new path
2 inch 2 inch moveto    % 2 inches in from the lower left
1 inch 0 inch rlineto   % bottom side relative to starting point
0 inch 1 inch rlineto   % right side (relative)
-1 inch 0 inch rlineto  % top side (relative)
closepath               % Automatically add left side to close path
fill                    % Fill with set color
% 3)
1 setgray               % color: white
newpath                 %
2 inch 2 inch moveto    % back to lower left of square 2
1 inch 1 inch rlineto   % diagonal to upper right corner
stroke                  % draw
0 setgray               % color: black
%newpath                 %
2 inch 3 inch moveto    % top-left-corner of gray square
1 inch -1 inch rlineto  % diagonal to bottom-right corner
stroke                  % make it a line
showpage                % We're done... eject the page