class HexaPDF::Content::GraphicObject::SolidArc

Parent

This graphic object represents a solid elliptical arc, i.e. an arc that has an inner and an outer set of a/b values.

Note that only the path itself is added to the canvas. So depending on the use-case the path itself still has to be, for example, stroked.

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

It can be used to create

  • an (elliptical) disk (when the inner a/b are zero and the difference between start and end angles is greater than or equal to 360),

    canvas.fill_color("hp-blue").
      draw(:solid_arc, outer_a: 80, outer_b: 50).
      fill_stroke

  • an (elliptical) sector (when the inner a/b are zero and the difference between start and end angles is less than 360),

    canvas.fill_color("hp-blue").
      draw(:solid_arc, outer_a: 80, outer_b: 50, start_angle: 20, end_angle: 230).
      fill_stroke

  • an (elliptical) annulus (when the inner a/b are nonzero and the difference between start and end angles is greater than or equal to 360),

    canvas.fill_color("hp-blue").
      draw(:solid_arc, outer_a: 80, outer_b: 50, inner_a: 70, inner_b: 30).
      fill_stroke

  • and an (elliptical) *annular sector* (when the inner a/b are nonzero and the difference between start and end angles is less than 360)

    canvas.fill_color("hp-blue").
      draw(:solid_arc, outer_a: 80, outer_b: 50, inner_a: 70, inner_b: 30,
           start_angle: 20, end_angle: 230).
      fill_stroke

See: Arc

Attributes

cx[R]

x-coordinate of center point, defaults to 0.

Examples:

solid_arc = canvas.graphic_object(:solid_arc, outer_a: 30, outer_b: 20,
                                  inner_a: 20, inner_b: 10)
canvas.draw(solid_arc).stroke
canvas.stroke_color("hp-blue").draw(solid_arc, cx: 50).stroke

cy[R]

y-coordinate of center point, defaults to 0.

Examples:

solid_arc = canvas.graphic_object(:solid_arc, outer_a: 30, outer_b: 20,
                                  inner_a: 20, inner_b: 10)
canvas.draw(solid_arc).stroke
canvas.stroke_color("hp-blue").draw(solid_arc, cy: 50).stroke

end_angle[R]

End angle of the solid arc in degrees, defaults to 0.

Examples:

solid_arc = canvas.graphic_object(:solid_arc, cx: -50, outer_a: 30, outer_b: 20,
                                  inner_a: 20, inner_b: 10)
canvas.draw(solid_arc).stroke
canvas.stroke_color("hp-blue").draw(solid_arc, cx: 50, end_angle: 120).stroke

inclination[R]

Inclination in degrees of semi-major axis in respect to x-axis, defaults to 0.

Examples:

solid_arc = canvas.graphic_object(:solid_arc, cx: -50, outer_a: 30, outer_b: 20,
                                  inner_a: 20, inner_b: 10)
canvas.draw(solid_arc).stroke
canvas.stroke_color("hp-blue").draw(solid_arc, cx: 50, inclination: 40).stroke

inner_a[R]

Length of inner semi-major axis which (without altering the inclination) is parallel to the x-axis, defaults to 0.

Examples:

solid_arc = canvas.graphic_object(:solid_arc, cx: -50, outer_a: 30, outer_b: 20,
                                  inner_a: 20, inner_b: 10)
canvas.draw(solid_arc).stroke
canvas.stroke_color("hp-blue").draw(solid_arc, cx: 50, inner_a: 5).stroke

inner_b[R]

Length of inner semi-minor axis which (without altering the inclination) is parallel to the y-axis, defaults to 0.

Examples:

solid_arc = canvas.graphic_object(:solid_arc, cx: -50, outer_a: 30, outer_b: 20,
                                  inner_a: 20, inner_b: 10)
canvas.draw(solid_arc).stroke
canvas.stroke_color("hp-blue").draw(solid_arc, cx: 50, inner_b: 20).stroke

outer_a[R]

Length of outer semi-major axis which (without altering the inclination) is parallel to the x-axis, defaults to 1.

Examples:

solid_arc = canvas.graphic_object(:solid_arc, cx: -50, outer_a: 30, outer_b: 20,
                                  inner_a: 20, inner_b: 10)
canvas.draw(solid_arc).stroke
canvas.stroke_color("hp-blue").draw(solid_arc, cx: 50, outer_a: 45).stroke

outer_b[R]

Length of outer semi-minor axis which (without altering the inclination) is parallel to the y-axis, defaults to 1.

Examples:

solid_arc = canvas.graphic_object(:solid_arc, cx: -50, outer_a: 30, outer_b: 20,
                                  inner_a: 20, inner_b: 10)
canvas.draw(solid_arc).stroke
canvas.stroke_color("hp-blue").draw(solid_arc, cx: 50, outer_b: 40).stroke

start_angle[R]

Start angle of the solid arc in degrees, defaults to 0.

Examples:

solid_arc = canvas.graphic_object(:solid_arc, cx: -50, outer_a: 30, outer_b: 20,
                                  inner_a: 20, inner_b: 10)
canvas.draw(solid_arc).stroke
canvas.stroke_color("hp-blue").draw(solid_arc, cx: 50, start_angle: 60).stroke

Public Class Methods

configure(**kwargs)

Creates and configures a new solid arc object.

See configure for the allowed keyword arguments.

new()

Creates a solid arc with default values (a unit disk at the origin).

Examples:

canvas.draw(:solid_arc).stroke

Public Instance Methods

configure(cx: nil, cy: nil, inner_a: nil, inner_b: nil, outer_a: nil, outer_b: nil, start_angle: nil, end_angle: nil, inclination: nil)

Configures the solid arc with

  • center point (cx, cy),

  • inner semi-major axis inner_a,

  • inner semi-minor axis inner_b,

  • outer semi-major axis outer_a,

  • outer semi-minor axis outer_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.

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

Returns self.

Examples:

solid_arc = canvas.graphic_object(:solid_arc)
solid_arc.configure(outer_a: 30, outer_b: 20, inner_a: 20, inner_b: 10)
canvas.draw(solid_arc).stroke

draw(canvas)

Draws the solid arc on the given Canvas.

Examples:

solid_arc = canvas.graphic_object(:solid_arc, outer_a: 30, outer_b: 20,
                                  inner_a: 20, inner_b: 10)
solid_arc.draw(canvas)
canvas.stroke