gsave … grestore

To keep that string from affecting the path of the line, save the graphics state with a gsave command before showing the string. Then, restore it with grestore before the next lineto:

%!PS
0 0 moveto 306 396 lineto
% CURRENT POINT IS 306 396
gsave
/Helvetica 10 selectfont
(the effect of showing this string is isolated) show
% CURRENT POINT IS AT END OF STRING (306+? 396)
grestore
% CURRENT POINT IS AT BEGIN OF STRING (306 396)
612 792 lineto
stroke
showpage % END OF PROGRAM

gsavegrestore

Get it? The current point (within the graphics state) at the end of the first line is saved to be used by the start of the second line. The effect of changing the current point by showing the string is thus negated.

Advertisements

Line Graphics

Lines are drawn from point to point on the page. The positions of each point are given by two coordinates, the x and y coordinates. They are the number of the point across the page horizontally from the left, and the number of the point vertically from the bottom, respectively. So, the bottom left point is 0 0, and on a letter size page, the top right point is 612 792.

The lineto command is an operator requiring two operands, or arguments. Use it to make a line from the current point (set by the “moveto” command) to the point specified by the lineto arguments. Thus, to create a diagonal from the bottom left to the top right of the page:

0 0 moveto
612 792 lineto