1. arc

Appends a counterclockwise circular arc to the current path.

1.1. Syntax

x y r ang1 ang2 arc → -

1.2. Stack Effects

Table 1. Before
Level Object

4

ang2 (number - ending angle in degrees)

3

ang1 (number - starting angle in degrees)

2

r (number - radius)

1

y (number - center y-coordinate)

0

x (number - center x-coordinate)

Table 2. After
Level Object

(empty)

Stack cleared of operands

1.3. Description

arc appends a counterclockwise arc of a circle to the current path. The arc has (x, y) as center, r as radius, ang1 as the angle from (x, y) to the first endpoint, and ang2 as the angle from (x, y) to the second endpoint.

Angles are measured in degrees counterclockwise from the positive x-axis of the current user coordinate system.

If there is a current point, arc includes a straight line segment from the current point to the first endpoint of the arc, then adds the arc into the current path. If the current path is empty, arc does not produce the initial straight line segment. In any event, the second endpoint of the arc becomes the new current point.

The curve produced is circular in user space. If user space is scaled non-uniformly (differently in x and y), arc will produce elliptical curves in device space.

1.4. PostScript Level

Level 1 and later

1.5. Examples

Drawing a circle
newpath
200 200 50 0 360 arc
closepath
fill
Drawing a semicircle
newpath
200 200 75 0 180 arc
closepath
stroke
Creating a pie slice
newpath
200 200 moveto           % Move to center
200 200 100 0 45 arc     % Draw arc from 0° to 45°
closepath                % Line back to center
fill
Drawing partial circles
newpath
150 150 50 45 135 arc    % Upper-right quadrant
stroke

newpath
150 150 50 225 315 arc   % Lower-left quadrant
stroke

1.6. Common Use Cases

1.6.1. Drawing Circular Shapes

/drawCircle {
  % x y radius
  /r exch def
  /y exch def
  /x exch def
  newpath
  x y r 0 360 arc
  closepath
} def

200 200 50 drawCircle
fill

1.6.2. Creating Rounded Corners

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

  newpath
  x r add y moveto
  x w add r sub y r 0 90 arc       % Bottom-right
  x w add y h add r sub r 90 180 arc   % Top-right
  x r add y h add r 180 270 arc        % Top-left
  x y r add r 270 360 arc              % Bottom-left
  closepath
} def

100 100 200 150 20 roundedRect
stroke

1.6.3. Drawing Gauges and Dials

/drawGauge {
  % cx cy radius startAngle endAngle value
  /val exch def
  /endAng exch def
  /startAng exch def
  /r exch def
  /cy exch def
  /cx exch def

  % Draw arc background
  newpath
  cx cy r startAng endAng arc
  0.7 setgray
  5 setlinewidth
  stroke

  % Draw value indicator
  newpath
  cx cy r startAng
  startAng endAng startAng sub val mul add arc
  1 0 0 setrgbcolor
  stroke
} def

200 200 80 135 45 0.75 drawGauge

1.7. Common Pitfalls

Angle Units - Angles are in degrees, not radians. A full circle is 360°, not 2π.
200 200 50 0 6.28 arc   % Wrong! Only draws ~6° of arc
200 200 50 0 360 arc    % Correct: full circle
Counterclockwise Direction - arc always draws counterclockwise. For clockwise arcs, use arcn.
% For clockwise 90° arc from 0° to -90°:
200 200 50 0 -90 arc    % Wrong! Draws 270° counterclockwise
200 200 50 0 -90 arcn   % Correct: 90° clockwise
Non-uniform Scaling - If the CTM has non-uniform scaling, arcs become elliptical.
2 1 scale               % Scale x by 2, y by 1
100 100 50 0 360 arc    % Produces an ellipse, not a circle
Connecting Line - If a current point exists, arc adds a connecting line to the arc’s start. Use moveto to the start point to avoid this.

1.8. Implementation Notes

  • Arcs are internally represented as one or more Bézier cubic curves

  • The conversion is accurate enough for faithful arc rendering

  • Programs using pathforall will see curveto segments

  • Angles wrap around: 370° is equivalent to 10°

  • Negative angles are valid: -90° equals 270°

  • Zero radius creates a point (degenerate arc)

1.9. Error Conditions

Error Condition

[limitcheck]

Path becomes too complex for implementation

[stackunderflow]

Fewer than 5 operands on stack

[typecheck]

Any operand is not a number

1.10. Performance Considerations

  • Arcs are efficient primitives

  • Large arcs (many degrees) may use multiple curve segments

  • Multiple small arcs may be slower than one large arc

  • Circular arcs in user space may be expensive if transformed to complex ellipses

1.11. See Also

  • arcn - Clockwise arc

  • arct - Arc defined by tangent lines

  • arcto - Like arct but returns tangent points

  • curveto - Bézier cubic curve

  • moveto - Set current point

  • closepath - Close current subpath


Back to top

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