1. Path Construction

Commands for building vector paths in PostScript. Paths are the fundamental building blocks for all graphics operations - they define shapes that can then be filled, stroked, or used for clipping.

2. Overview

Path construction in PostScript follows a three-step process:

  1. Construct - Build the path using moveto, lineto, curveto, arc, etc.

  2. Paint - Apply fill, stroke, or clip operations

  3. Reset - Use newpath to start fresh

3. Command Categories

3.1. Basic Path Operations

Command Description

newpath

Initialize path to empty

moveto

Set current point (start new subpath)

lineto

Add straight line to current point

curveto

Add Bézier curve to path

closepath

Close current subpath

currentpoint

Get coordinates of current point

3.2. Relative Path Operations

Command Description

rmoveto

Relative moveto

rlineto

Relative lineto

rcurveto

Relative curveto

3.3. Arc Operations

Command Description

arc

Add counterclockwise circular arc

arcn

Add clockwise circular arc

arct

Add arc defined by tangent lines

arcto

Like arct but returns tangent points

4. Common Patterns

4.1. Rectangle

newpath
100 100 moveto
200 0 rlineto
0 150 rlineto
-200 0 rlineto
closepath

4.2. Circle

newpath
200 200 50 0 360 arc
closepath

4.3. Rounded Rectangle

/roundrect {  % x y width height radius
  /r exch def
  /h exch def
  /w exch def
  /y exch def
  /x exch def

  newpath
  x r add y moveto
  x w add y x w add y h add r arcto 4 { pop } repeat
  x w add y h add x y h add r arcto 4 { pop } repeat
  x y h add x y r arcto 4 { pop } repeat
  x y x w add y r arcto 4 { pop } repeat
  closepath
} def

50 50 200 100 10 roundrect

5. See Also