Useful Path Commands

# 5.4.2 Useful Path Commands

[arc] [arcn] [closepath] [fill] [lineto] [moveto] [newpath] [rlineto] [rmoveto] [stroke]

### arc

x-coord y-coord r ang1 ang2 arc -

This operator adds a circular arc to the current path. The arc is the a section of a circle of radius r and center (x-coord y-coord). The arc is drawn from from angle ang1 to angle ang2 in a counter clockwise fashion. Note: a straight line segment will connect the current point to the first point of the arc, if they are not the same.

### arcn

x-coord y-coord r ang1 ang2 arcn -

This operator works just like arc except the curve is drawn clockwise.

### closepath

- closepath -

This operator adds a line segment to the current path from the current point to the first point in the path. This closes the path so that it may be filled.

### fill

- fill -

This operator closes and fills the current path with the current color. Any ink within the path is obliterated. Note that fill blanks out the current path as if it had called newpath.

### lineto

x-coord y-coord lineto -

This operator adds a line into the path. The line is from the current point to the point (x-coord y-coord). After the line is added to the path, the current point is set to (x-coord y-coord). It is an error to call lineto without having a current point.

### moveto

x-coord y-coord moveto -

This operator moves the current point of the current path to the given point in user space. If a moveto operator immediately follows another moveto operator, the previous one is erased.

### newpath

- newpath -

The newpath operator clears out the current path and prepares the system to start a new current path. This operator should be called before starting any new path, even though some operators call it implicitly.

### rlineto

dx dy rlineto -

This operator adds a line into the path. The line is from the current point to a point found by adding dx to the current x and dy to the current y. After line is added to the path, the current point is set to the new point. It is an error to call lineto without having a current point.

### rmoveto

dx dy rmoveto -

This operator moves the current point of the current path by adding dx to the current x and dy to the current y.

### stroke

- stroke -

This operator draws a line along the current path using the current settings. This includes the current line thickness, current pen color, current dash pattern, current settings for how lines should be joined, and what kind of caps they should have. These settings are the settings at the time the stroke operator is invoked.

A closed path consisting of two or more points at the same location is a degenerate path. A degenerate path will be drawn only if you have set the line caps to round caps. If your line caps are not round caps, or if the path is not closed, the path will not be drawn. If the path is drawn, it will appear as a filled circle center at the point.

David Maxwell, who is still writing this, would like to hear your comments and suggestions. And remember, parts of this manual are based on P.J. Weingartner's work: A First Guide to PostScript.