1. moveto
Sets the current point to specified coordinates, starting a new subpath.
1.2. Stack Effects
| Level | Object |
|---|---|
1 |
|
0 |
|
| Level | Object |
|---|---|
(empty) |
Stack cleared of operands |
1.3. Description
moveto starts a new subpath of the current path by setting the current point in the graphics state to the user space coordinate (x, y) without adding any line segments to the current path.
If the previous path construction operation was also a moveto or rmoveto, that point is deleted from the current path and the new moveto point replaces it.
The coordinates are interpreted as user space coordinates and are transformed by the current transformation matrix (CTM) to device space when the path is constructed.
1.5. Examples
100 200 moveto % Set current point to (100, 200)
200 200 lineto % Draw line to (200, 200)
200 100 lineto % Draw line to (200, 100)
50 50 moveto % First moveto
100 100 moveto % Second moveto replaces first
150 150 lineto % Line starts from (100, 100)
newpath
100 100 moveto
200 100 lineto
closepath % Close first subpath
300 100 moveto % Start new subpath
400 100 lineto
closepath % Close second subpath
1.6. Common Use Cases
1.7. Common Pitfalls
newpath
200 200 lineto % Error: nocurrentpoint
Consecutive moveto - Multiple consecutive moveto operations cause only the last one to be effective. The previous points are discarded.
|
newpath
10 10 moveto
20 20 moveto
30 30 moveto % Only this moveto is in the path
40 40 lineto % Line starts from (30, 30)
Use for Positioning - moveto is essential for positioning before drawing or showing text. It doesn’t consume the current point—it sets it.
|
1.8. Error Conditions
| Error | Condition |
|---|---|
[ |
Path becomes too complex for implementation |
[ |
Fewer than 2 operands on stack |
[ |
Operands are not numbers |
1.9. Implementation Notes
-
movetodoes not add any segments to the path -
Coordinates are immediately transformed by CTM to device space
-
The point becomes the start of a new subpath
-
Subsequent path operations use this as the current point
-
Does not affect the path if it’s the only operation (creates an empty path)
1.10. Performance Considerations
-
Very lightweight operation
-
No path segments are created
-
Transformation happens immediately
-
Multiple consecutive
movetooperations have minimal overhead (only the last is retained)