class HexaPDF:: Content:: GraphicObject:: EndpointArc
Parent | Object |
---|---|
Included Modules |
HexaPDF::Utils HexaPDF::Utils::MathHelpers |
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 Canvas#line_to
. Behind the scenes the endpoint parameterization is turned into a center parameterization and drawn with Arc
.
Note that only the path of the arc 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 :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: Arc
, ARC - www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes (in the version of about 2016, see web.archive.org/web/20160310153722/https://www.w3.org/TR/SVG/implnote.html).
Attributes
Direction of arc - if true
in clockwise direction, else in counterclockwise direction (the default).
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("hp-blue").move_to(0, 0).draw(arc, clockwise: true).stroke
Large arc choice - if true
(the default) 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("hp-blue").
move_to(0, 0).draw(arc, large_arc: false, clockwise: true).stroke
The maximal number of curves used for approximating a complete ellipse.
See Arc#max_curves
for details.
Examples:
arc = canvas.graphic_object(:endpoint_arc, x: 50, y: 20, a: 30, b: 20)
canvas.move_to(0, 0).draw(arc, max_curves: 1).stroke
canvas.stroke_color("hp-blue").
move_to(0, 0).draw(arc, max_curves: 2).stroke
Public Class Methods
Creates and configures a new endpoint arc object.
See configure
for the allowed keyword arguments.
Public Instance Methods
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, -
the given clockwise flag and.
-
the given maximum number of approximation curves.
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.
Examples:
arc = canvas.graphic_object(:endpoint_arc)
arc.configure(x: 50, y: 20, a: 30, b: 10)
canvas.move_to(0, 0).draw(arc).stroke
Draws the arc on the given Canvas
.
Since this method doesn’t have any other arguments than canvas
, it is usually better and easier to use Canvas#draw
.
Examples:
arc = canvas.graphic_object(:endpoint_arc, x: 50, y: 20, a: 30, b: 10)
canvas.move_to(-20, -20)
arc.draw(canvas)
canvas.stroke