How to make pictures using postscript program (part 2) --------------Example Program 1---------------------------------------------- %!PS-Adobe-2.0 EPSF %%Title: A staircase %%BoundingBox: 0.0 0.0 550.0 800.0 /step {newpath 0 0 moveto 0 100 lineto 150 100 lineto stroke} def 60 100 translate step 150 100 translate step 150 100 translate step showpage ----------------------------------------------------------------------------- This draws three steps, and moves the coordinate system after each step 150 to the right, and 100 up, so that the next step connects to the previous one. The showpage command tells the printer that the page is now finished, and should be put on paper, so no further componentns will be added to it. The BoundingBox declarations gives lower right corner 0 0 and upper left corner 550 800; anything outside this box might not be printed. We can also put the translation in the definition of the step --------------Example Program 2---------------------------------------------- %!PS-Adobe-2.0 EPSF %%Title: A staircase %%BoundingBox: 0.0 0.0 550.0 800.0 /step {newpath 0 0 moveto 0 50 lineto 80 50 lineto stroke 80 50 translate } def 40 100 translate step step step step step step showpage ----------------------------------------------------------------------------- We can also rotate the coordinate system, the command 42 rotate rotates the coordinate system by 42 degrees in counterclockwise direction --------------Example Program 3---------------------------------------------- %!PS-Adobe-2.0 EPSF %%Title: Corner and rotated corner %%BoundingBox: 0.0 0.0 550.0 800.0 100 200 translate newpath 0 100 moveto 0 0 lineto 150 0 lineto stroke 200 0 translate 15 rotate newpath 0 100 moveto 0 0 lineto 150 0 lineto stroke showpage ----------------------------------------------------------------------------- Rotating is always done around the current point 0 0. ----------------------------------------------------------------------------- other commands that extend the current path are rlineto this is like lineto, but the coordinates are relative to the current point: so 0 20 rlineto draws a line 20 unit up moveto, rmoveto like lineto, rlineto, but they move the current point without adding a line to the path.