class HexaPDF::Content::GraphicObject::Arc

Included Modules

This class describes an elliptical in center parameterization arc that is approximated using Bezier curves. It can be used to draw circles, circular arcs, ellipses and elliptical arcs, all either in clockwise or counterclockwise direction and optionally inclined in respect to the x-axis.

See: ELL -



Length of semi-major axis


Length of semi-minor axis


Direction of arc - if true in clockwise direction, else in counterclockwise direction


x-coordinate of center point


y-coordinate of center point


End angle in degrees


Inclination in degrees of semi-major axis in respect to x-axis


The maximal number of curves used for approximating a complete ellipse.

The higher the value the better the approximation will be but it will also take longer to compute. The value should not be lower than 4. Default value is 6 which already provides a good approximation.


Start angle in degrees

Public Class Methods


Creates and configures a new elliptical arc object.

See configure for the allowed keyword arguments.


Creates an elliptical arc with default values (a counterclockwise unit circle at the origin).

Public Instance Methods

configure(cx: nil, cy: nil, a: nil, b: nil, start_angle: nil, end_angle: nil, inclination: nil, clockwise: nil)

Configures the arc with

  • center point (cx, cy),

  • semi-major axis a,

  • semi-minor axis b,

  • start angle of start_angle degrees,

  • end angle of end_angle degrees and

  • an inclination in respect to the x-axis of inclination degrees.

The clockwise argument determines if the arc is drawn in the counterclockwise direction (false) or in the clockwise direction (true).

Any arguments not specified are not modified and retain their old value, see initialize for the inital values.

Returns self.


Returns an array of arrays that contain the points for the Bezier curves which are used for approximating the elliptical arc between start_point and end_point.

One subarray consists of

[end_point_x, end_point_y, p1: control_point_1, p2: control_point_2]

The first start point is the one returned by start_point, the other start points are the end points of the curve before.

The format of the subarray is chosen so that it can be fed to the Canvas#curve_to method by using array splatting.

See: ELL s3.4.1 (especially the last box on page 18)

draw(canvas, move_to_start: true)

Draws the arc on the given Canvas.

If the argument move_to_start is true, a Canvas#move_to operation is executed to move the current point to the start point of the arc. Otherwise it is assumed that the current point already coincides with the start point

The max_curves value is set to the value of the configuration option 'graphic_object.arc.max_curves' before drawing.


Returns the end point of the elliptical arc.


Returns the point at angle degrees on the ellipse.

Note that the point may not lie on the arc itself!


Returns the start point of the elliptical arc.