1. moveto

Sets the current point to specified coordinates, starting a new subpath.

1.1. Syntax

x y moveto → -

1.2. Stack Effects

Table 1. Before
Level Object

1

y (number)

0

x (number)

Table 2. After
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.4. PostScript Level

Level 1 and later

1.5. Examples

Starting a simple path
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)
Multiple moveto operations
50 50 moveto             % First moveto
100 100 moveto           % Second moveto replaces first
150 150 lineto           % Line starts from (100, 100)
Creating separate subpaths
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.6.1. Starting Every Path

newpath
72 72 moveto             % Move to 1 inch from origin
144 144 lineto
stroke

1.6.2. Drawing Disconnected Shapes

newpath
% First square
100 100 moveto
200 100 lineto
200 200 lineto
100 200 lineto
closepath

% Second square (separate subpath)
300 300 moveto
400 300 lineto
400 400 lineto
300 400 lineto
closepath

fill                     % Fill both squares

1.6.3. Text Positioning

/Helvetica findfont 24 scalefont setfont
100 500 moveto
(Hello, World!) show

1.7. Common Pitfalls

No Current Point Initially - After newpath, there is no current point. Always use moveto to establish one before operations like lineto or curveto.
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

[limitcheck]

Path becomes too complex for implementation

[stackunderflow]

Fewer than 2 operands on stack

[typecheck]

Operands are not numbers

1.9. Implementation Notes

  • moveto does 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 moveto operations have minimal overhead (only the last is retained)

1.11. See Also


Back to top

Copyright © 2025 Ribose. PostScript is a trademark of Adobe. Distributed under the MIT License.