1. arct

Appends an arc defined by two tangent lines to the current path.

1.1. Syntax

x1 y1 x2 y2 r arct → -

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

(empty)

Stack cleared of operands

1.3. Description

arct appends an arc of a circle to the current path, possibly preceded by a straight line segment. The arc is defined by a radius r and two tangent lines.

The tangent lines are: 1. From the current point (x0, y0) to (x1, y1) 2. From (x1, y1) to (x2, y2)

If the current point is undefined, arct executes the [nocurrentpoint] error.

The center of the arc is located at distance r perpendicular to both tangent lines, within the inner angle between them. The arc begins at the first tangent point (xt1, yt1) on the first tangent line, and ends at the second tangent point (xt2, yt2) on the second tangent line.

Before constructing the arc, arct adds a straight line from the current point to (xt1, yt1), unless those points are the same. The point (xt2, yt2) becomes the new current point.

If the two tangent lines are collinear, arct merely appends a straight line from (x0, y0) to (x1, y1).

1.4. PostScript Level

Level 2 and later

1.5. Examples

Creating a rounded corner
newpath
100 100 moveto
200 100 200 200 20 arct   % Round corner at (200, 100)
200 200 lineto
stroke
Drawing a rounded rectangle
/roundedRect {
  % x y width height radius
  /r exch def
  /h exch def
  /w exch def
  /y exch def
  /x exch def

  newpath
  x y r add moveto
  x y x w add y r arct
  x w add y x w add y h add r arct
  x w add y h add x y h add r arct
  x y h add x y r arct
  closepath
} def

50 50 200 150 25 roundedRect
stroke
Creating smooth path transitions
newpath
50 200 moveto
100 200 100 100 30 arct    % Smooth transition at (100, 200)
100 100 200 100 30 arct    % Smooth transition at (100, 100)
200 100 lineto
stroke

1.6. Common Use Cases

1.6.1. Rounding Sharp Corners

/roundCorner {
  % x1 y1 x2 y2 radius
  arct
} def

newpath
100 100 moveto
200 100 200 200 15 roundCorner
200 200 100 200 15 roundCorner
100 200 100 100 15 roundCorner
closepath
stroke

1.6.2. Creating UI Elements

/roundedButton {
  % x y width height radius
  /r exch def
  /h exch def
  /w exch def
  /y exch def
  /x exch def

  newpath
  x y moveto
  x w add y x w add y h add r arct
  x w add y h add x y h add r arct
  x y h add x y r arct
  x y x w add y r arct
  closepath

  0.9 0.9 0.9 setrgbcolor fill
  0 0 0 setrgbcolor stroke
} def

100 100 150 40 10 roundedButton

1.6.3. Smooth Path Connections

/connectWithArc {
  % Creates smooth connection between line segments
  % x1 y1 x2 y2 x3 y3 radius
  /r exch def
  /y3 exch def /x3 exch def
  /y2 exch def /x2 exch def
  /y1 exch def /x1 exch def

  x1 y1 lineto
  x2 y2 x3 y3 r arct
} def

newpath
50 50 moveto
100 50 150 100 200 100 20 connectWithArc
stroke

1.7. Common Pitfalls

Requires Current Point - arct needs a current point to define the first tangent line.
newpath
100 100 200 100 20 arct    % Error: nocurrentpoint
Collinear Points - If the three points are collinear, no arc is created, just a straight line to (x1, y1).
100 100 moveto
200 100 300 100 20 arct    % All on same line, no arc
Radius Too Large - Very large radii relative to the angle may produce unexpected results or hit numerical limits.
Perfect for UI Corners - arct is ideal for creating rounded corners in user interfaces and technical drawings where corners are defined by intersecting lines.

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

  • Arc is circular in user space

  • Non-uniform scaling produces elliptical results

  • Internally converted to Bézier curves

  • The connecting line from current point is automatic

  • Tangent points are calculated but not returned (use arcto for that)

1.10. Performance Considerations

  • Slightly more complex than arc due to tangent calculations

  • Very efficient for creating rounded corners

  • Single operation replaces manual tangent point calculation

1.11. See Also

  • arcto - Like arct but returns tangent points

  • arc - Counterclockwise circular arc

  • arcn - Clockwise circular arc

  • curveto - Bézier cubic curve

  • lineto - Straight line segment


Back to top

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