Class: Pdfrb::Content::GraphicObject::Arc
- Inherits:
-
Object
- Object
- Pdfrb::Content::GraphicObject::Arc
- Defined in:
- lib/pdfrb/content/graphic_object/arc.rb
Overview
Circular or elliptical arc, approximated with cubic Beziers (s8.3.8.3 in PDF reference). One segment per 90 degrees.
Instance Attribute Summary collapse
-
#cx ⇒ Object
readonly
Returns the value of attribute cx.
-
#cy ⇒ Object
readonly
Returns the value of attribute cy.
-
#end_angle ⇒ Object
readonly
Returns the value of attribute end_angle.
-
#radius_x ⇒ Object
readonly
Returns the value of attribute radius_x.
-
#radius_y ⇒ Object
readonly
Returns the value of attribute radius_y.
-
#start_angle ⇒ Object
readonly
Returns the value of attribute start_angle.
Instance Method Summary collapse
-
#draw(canvas) ⇒ Object
Emit the path operators onto
canvasstarting with a moveto. -
#initialize(cx:, cy:, radius:, radius_y: nil, start_angle: 0, end_angle: 360) ⇒ Arc
constructor
A new instance of Arc.
Constructor Details
#initialize(cx:, cy:, radius:, radius_y: nil, start_angle: 0, end_angle: 360) ⇒ Arc
Returns a new instance of Arc.
15 16 17 18 19 20 21 22 23 |
# File 'lib/pdfrb/content/graphic_object/arc.rb', line 15 def initialize(cx:, cy:, radius:, radius_y: nil, start_angle: 0, end_angle: 360) @cx = cx.to_f @cy = cy.to_f @radius_x = radius.to_f @radius_y = (radius_y || radius).to_f @start_angle = start_angle.to_f @end_angle = end_angle.to_f end |
Instance Attribute Details
#cx ⇒ Object (readonly)
Returns the value of attribute cx.
12 13 14 |
# File 'lib/pdfrb/content/graphic_object/arc.rb', line 12 def cx @cx end |
#cy ⇒ Object (readonly)
Returns the value of attribute cy.
12 13 14 |
# File 'lib/pdfrb/content/graphic_object/arc.rb', line 12 def cy @cy end |
#end_angle ⇒ Object (readonly)
Returns the value of attribute end_angle.
12 13 14 |
# File 'lib/pdfrb/content/graphic_object/arc.rb', line 12 def end_angle @end_angle end |
#radius_x ⇒ Object (readonly)
Returns the value of attribute radius_x.
12 13 14 |
# File 'lib/pdfrb/content/graphic_object/arc.rb', line 12 def radius_x @radius_x end |
#radius_y ⇒ Object (readonly)
Returns the value of attribute radius_y.
12 13 14 |
# File 'lib/pdfrb/content/graphic_object/arc.rb', line 12 def radius_y @radius_y end |
#start_angle ⇒ Object (readonly)
Returns the value of attribute start_angle.
12 13 14 |
# File 'lib/pdfrb/content/graphic_object/arc.rb', line 12 def start_angle @start_angle end |
Instance Method Details
#draw(canvas) ⇒ Object
Emit the path operators onto canvas starting with a moveto.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pdfrb/content/graphic_object/arc.rb', line 26 def draw(canvas) steps = tessellate return if steps.empty? first = steps.first canvas.move_to(first[:p0][0], first[:p0][1]) steps.each do |seg| canvas.curve_to(seg[:c1][0], seg[:c1][1], seg[:c2][0], seg[:c2][1], seg[:p3][0], seg[:p3][1]) end canvas end |