1. rmoveto
Sets the current point relative to the previous point, starting a new subpath.
1.2. Stack Effects
| Level | Object |
|---|---|
1 |
|
0 |
|
| Level | Object |
|---|---|
(empty) |
Stack cleared of operands |
1.3. Description
rmoveto (relative moveto) starts a new subpath of the current path in the same manner as moveto. However, the number pair is interpreted as a displacement relative to the current point (x, y) rather than as an absolute coordinate. That is, rmoveto makes (x + dx, y + dy) the new current point, without connecting it to the previous point.
If the current point is undefined because the current path is empty, rmoveto executes the [nocurrentpoint] error.
1.5. Examples
100 100 moveto % Start at (100, 100)
50 0 rmoveto % Move to (150, 100)
0 50 rmoveto % Move to (150, 150)
-50 0 rmoveto % Move to (100, 150)
0 -50 rmoveto % Back to (100, 100)
newpath
100 100 moveto % Start at corner
100 0 rlineto % Right edge
0 100 rlineto % Top edge
-100 0 rlineto % Left edge
closepath
newpath
100 100 moveto
100 0 rlineto
closepath
50 50 rmoveto % New subpath offset by (50, 50)
100 0 rlineto
closepath
1.6. Common Use Cases
1.6.1. Relative Path Construction
/drawSquare {
% Stack: size
/size exch def
0 size rlineto
size 0 rlineto
0 size neg rlineto
closepath
} def
100 100 moveto
50 drawSquare
1.7. Common Pitfalls
newpath
10 10 rmoveto % Error: nocurrentpoint
| Displacement Not Position - The arguments are displacements (dx, dy), not absolute coordinates. Negative values move in the opposite direction. |
100 100 moveto
-50 -50 rmoveto % Moves to (50, 50), not (-50, -50)
Use for Relative Layouts - rmoveto is ideal for creating shapes or text layouts where elements are positioned relative to each other.
|
1.8. Error Conditions
| Error | Condition |
|---|---|
[ |
Path becomes too complex for implementation |
[ |
Current path is empty (no current point defined) |
[ |
Fewer than 2 operands on stack |
[ |
Operands are not numbers |
1.9. Implementation Notes
-
Displacements are in user space coordinates
-
The transformation by CTM happens after adding displacement to current point
-
Creates a new subpath (breaks any line continuation)
-
More efficient than calculating absolute coordinates manually
-
Negative displacements move in opposite directions
1.11. See Also
-
moveto- Absolute moveto -
rlineto- Relative lineto -
rcurveto- Relative curveto -
currentpoint- Get current point coordinates -
newpath- Initialize empty path