class HexaPDF::Content::GraphicObject::EndpointArc

Parent
Included Modules

This class describes an elliptical arc in endpoint parameterization. It allows one to generate an arc from the current point to a given point, similar to Content::Canvas#line_to.

This graphic object is registered under the :endpoint_arc key for use with the HexaPDF::Content::Canvas class.

Examples:

arc = canvas.graphic_object(:endpoint_arc, x: 50, y: 20, a: 30, b: 10)
canvas.move_to(0, 0).draw(arc).stroke

See: GraphicObject::Arc, ARC - www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes

Constants

EPSILON

Attributes

a[R]

Length of semi-major axis

Examples:

arc = canvas.graphic_object(:endpoint_arc, x: 50, y: 20, a: 30, b: 20)
canvas.move_to(0, 0).draw(arc).stroke
canvas.stroke_color("red").move_to(0, 0).draw(arc, a: 40).stroke

b[R]

Length of semi-minor axis

Examples:

arc = canvas.graphic_object(:endpoint_arc, x: 50, y: 20, a: 30, b: 20)
canvas.move_to(0, 0).draw(arc).stroke
canvas.stroke_color("red").move_to(0, 0).draw(arc, b: 50).stroke

clockwise[R]

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

This is needed, for example, when filling paths using the nonzero winding number rule to achieve different effects.

Examples:

arc = canvas.graphic_object(:endpoint_arc, x: 50, y: 20, a: 30, b: 20)
canvas.move_to(0, 0).draw(arc).stroke
canvas.stroke_color("red").move_to(0, 0).draw(arc, clockwise: true).stroke

inclination[R]

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

Examples:

arc = canvas.graphic_object(:endpoint_arc, x: 50, y: 20, a: 30, b: 20)
canvas.move_to(0, 0).draw(arc).stroke
canvas.stroke_color("red").move_to(0, 0).draw(arc, inclination: 45).stroke

large_arc[R]

Large arc choice - if true use the large arc (i.e. the one spanning more than 180 degrees), else the small arc

Examples:

arc = canvas.graphic_object(:endpoint_arc, x: 50, y: 20, a: 30, b: 20)
canvas.move_to(0, 0).draw(arc).stroke
canvas.stroke_color("red").move_to(0, 0).draw(arc, large_arc: false, clockwise: true).stroke

x[R]

x-coordinate of endpoint

Examples:

arc = canvas.graphic_object(:endpoint_arc, x: 50, y: 20, a: 30, b: 20)
canvas.move_to(0, 0).draw(arc).stroke
canvas.stroke_color("red").move_to(0, 0).draw(arc, x: -50).stroke

y[R]

y-coordinate of endpoint

Examples:

arc = canvas.graphic_object(:endpoint_arc, x: 50, y: 20, a: 30, b: 20)
canvas.move_to(0, 0).draw(arc).stroke
canvas.stroke_color("red").move_to(0, 0).draw(arc, y: -20).stroke

Public Class Methods

configure(**kwargs)

Creates and configures a new endpoint arc object.

See configure for the allowed keyword arguments.

new()

Creates an endpoint arc with default values x=0, y=0, a=0, b=0, inclination=0, large_arc=true, clockwise=false (a line to the origin).

Examples:

canvas.move_to(30, 30).draw(:endpoint_arc).stroke

Public Instance Methods

configure(x: nil, y: nil, a: nil, b: nil, inclination: nil, large_arc: nil, clockwise: nil)

Configures the endpoint arc with

  • endpoint (x, y),

  • semi-major axis a,

  • semi-minor axis b,

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

  • the given large_arc flag and

  • the given clockwise flag.

The large_arc option determines whether the large arc, i.e. the one spanning more than 180 degrees, is used (true) or the small arc (false).

The clockwise option 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.

draw(canvas)

Draws the arc on the given Canvas.