Class: Pdfrb::Content::GraphicObject::Curve
- Inherits:
-
Object
- Object
- Pdfrb::Content::GraphicObject::Curve
- Defined in:
- lib/pdfrb/content/graphic_object/curve.rb
Overview
Cubic Bezier curve through one start point, two control
points, and one end point. Convenience wrapper around
canvas.curve_to for users that prefer object form.
Instance Attribute Summary collapse
-
#c1 ⇒ Object
readonly
Returns the value of attribute c1.
-
#c2 ⇒ Object
readonly
Returns the value of attribute c2.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
- #draw(canvas) ⇒ Object
-
#initialize(start:, c1:, c2:, endpoint:) ⇒ Curve
constructor
A new instance of Curve.
Constructor Details
#initialize(start:, c1:, c2:, endpoint:) ⇒ Curve
Returns a new instance of Curve.
12 13 14 15 16 17 |
# File 'lib/pdfrb/content/graphic_object/curve.rb', line 12 def initialize(start:, c1:, c2:, endpoint:) @start = [start[0].to_f, start[1].to_f] @c1 = [c1[0].to_f, c1[1].to_f] @c2 = [c2[0].to_f, c2[1].to_f] @endpoint = [endpoint[0].to_f, endpoint[1].to_f] end |
Instance Attribute Details
#c1 ⇒ Object (readonly)
Returns the value of attribute c1.
10 11 12 |
# File 'lib/pdfrb/content/graphic_object/curve.rb', line 10 def c1 @c1 end |
#c2 ⇒ Object (readonly)
Returns the value of attribute c2.
10 11 12 |
# File 'lib/pdfrb/content/graphic_object/curve.rb', line 10 def c2 @c2 end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
10 11 12 |
# File 'lib/pdfrb/content/graphic_object/curve.rb', line 10 def endpoint @endpoint end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
10 11 12 |
# File 'lib/pdfrb/content/graphic_object/curve.rb', line 10 def start @start end |
Instance Method Details
#draw(canvas) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/pdfrb/content/graphic_object/curve.rb', line 19 def draw(canvas) canvas.move_to(@start[0], @start[1]) canvas.curve_to(@c1[0], @c1[1], @c2[0], @c2[1], @endpoint[0], @endpoint[1]) canvas end |