1. arcto

Appends an arc defined by two tangent lines and returns the tangent points.

1.1. Syntax

x1 y1 x2 y2 r arcto → xt1 yt1 xt2 yt2

1.2. Stack Effects

Table 1. Before
Level Object

4

r (number - arc radius)

3

y2 (number - second tangent point y)

2

x2 (number - second tangent point x)

1

y1 (number - first tangent point y)

0

x1 (number - first tangent point x)

Table 2. After
Level Object

3

yt2 (number - second tangent point y)

2

xt2 (number - second tangent point x)

1

yt1 (number - first tangent point y)

0

xt1 (number - first tangent point x)

1.3. Description

arcto produces the same effect as arct. It also returns the two tangent point coordinates (xt1, yt1) and (xt2, yt2) in user space.

The arc is defined by: 1. A tangent line from the current point (x0, y0) to (x1, y1) 2. A tangent line from (x1, y1) to (x2, y2) 3. A radius r

The arc is tangent to both lines, and the tangent points are returned on the stack.

arcto is not allowed as an element of a user path, whereas arct is allowed.

1.4. PostScript Level

Level 1 and later

1.5. Examples

Getting tangent points
newpath
100 100 moveto
200 100 200 200 30 arcto
% Stack now has: xt1 yt1 xt2 yt2
% xt1, yt1 is where arc starts on first line
% xt2, yt2 is where arc ends on second line
pop pop pop pop              % Discard tangent points
stroke
Using tangent points for markers
/drawMarkerAtTangents {
  % x1 y1 x2 y2 radius
  arcto

  % Mark second tangent point
  gsave
  newpath
  0 5 rlineto
  5 0 rlineto
  0 -5 rlineto
  closepath
  fill
  grestore

  % Mark first tangent point
  gsave
  newpath
  0 5 rlineto
  5 0 rlineto
  0 -5 rlineto
  closepath
  fill
  grestore
} def

newpath
100 100 moveto
200 100 200 200 25 drawMarkerAtTangents
stroke
Calculating arc length
/arcLength {
  % Returns approximate arc length
  % x1 y1 x2 y2 radius -> length
  arcto

  % Calculate distance between tangent points
  /yt2 exch def /xt2 exch def
  /yt1 exch def /xt1 exch def

  xt2 xt1 sub dup mul
  yt2 yt1 sub dup mul
  add sqrt
} def

newpath
100 100 moveto
200 100 200 200 30 arcLength
% Returns approximate arc length

1.6. Common Use Cases

1.6.1. Precise Corner Construction

/preciseRoundedCorner {
  % Uses tangent points for exact positioning
  % x1 y1 x2 y2 radius
  arcto

  % Save tangent points for later use
  /yt2 exch def /xt2 exch def
  /yt1 exch def /xt1 exch def

  % Could use tangent points for:
  % - Adding decorations at corners
  % - Calculating dimensions
  % - Placing text labels
} def

1.6.2. Creating Annotated Diagrams

/annotatedArc {
  % x1 y1 x2 y2 radius label
  /label exch def
  /r exch def
  /y2 exch def /x2 exch def
  /y1 exch def /x1 exch def

  % Draw the arc and get tangent points
  x1 y1 x2 y2 r arcto
  /yt2 exch def /xt2 exch def
  /yt1 exch def /xt1 exch def

  % Place label at midpoint of arc
  gsave
  xt1 xt2 add 2 div yt1 yt2 add 2 div moveto
  label show
  grestore
} def

newpath
100 100 moveto
200 100 200 200 30 (Arc) annotatedArc

1.6.3. Measuring Corner Geometry

/measureCorner {
  % Returns corner dimensions
  % x1 y1 x2 y2 radius -> setback1 setback2 arclen
  5 copy arcto

  % Calculate setbacks (distances from corner to tangent points)
  /yt2 exch def /xt2 exch def
  /yt1 exch def /xt1 exch def

  % Setback on first line
  currentpoint
  /y0 exch def /x0 exch def
  xt1 x0 sub dup mul yt1 y0 sub dup mul add sqrt

  % Setback on second line (from x1,y1 to xt1,yt1)
  xt1 5 index sub dup mul yt1 4 index sub dup mul add sqrt

  % Arc length (approximate)
  xt2 xt1 sub dup mul yt2 yt1 sub dup mul add sqrt
} def

1.7. Common Pitfalls

Not for User Paths - Unlike arct, arcto cannot be used in user paths.
Stack Management - arcto leaves four values on the stack. Remember to pop them if not needed.
newpath
100 100 moveto
200 100 200 200 20 arcto
% Stack has 4 extra values!
stroke                        % May cause typecheck error
Use When You Need Tangent Points - If you don’t need the tangent points, use arct instead for cleaner stack management.

1.8. Error Conditions

Error Condition

[limitcheck]

Path becomes too complex for implementation

[nocurrentpoint]

Current path is empty (no current point defined)

[stackunderflow]

Fewer than 5 operands on stack

[typecheck]

Any operand is not a number

[undefinedresult]

Degenerate tangent configuration

1.9. Implementation Notes

  • Identical path construction to arct

  • Returns tangent points in user space coordinates

  • Tangent points are on the original tangent lines, not the arc

  • Useful for geometric calculations and annotations

  • Cannot be encoded in user paths

1.10. Performance Considerations

  • Slightly slower than arct due to returning tangent points

  • Overhead is minimal for most applications

  • Consider using arct if tangent points aren’t needed

1.11. See Also

  • arct - Arc by tangent (no tangent point return)

  • arc - Counterclockwise circular arc

  • arcn - Clockwise circular arc

  • currentpoint - Get current point


Back to top

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