Class: Savage::Directions::CubicCurveTo
- Inherits:
-
QuadraticCurveTo
- Object
- Savage::Direction
- PointTarget
- QuadraticCurveTo
- Savage::Directions::CubicCurveTo
- Defined in:
- lib/savage/directions/cubic_curve_to.rb
Instance Attribute Summary collapse
-
#control_1 ⇒ Object
Returns the value of attribute control_1.
Attributes inherited from QuadraticCurveTo
Attributes inherited from PointTarget
Instance Method Summary collapse
- #command_code ⇒ Object
- #control_2 ⇒ Object
- #control_2=(value) ⇒ Object
-
#initialize(*args) ⇒ CubicCurveTo
constructor
A new instance of CubicCurveTo.
- #to_a ⇒ Object
Methods inherited from Savage::Direction
Methods included from Utils
Constructor Details
#initialize(*args) ⇒ CubicCurveTo
Returns a new instance of CubicCurveTo.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/savage/directions/cubic_curve_to.rb', line 6 def initialize(*args) raise ArgumentError if args.length < 4 case args.length when 4 super(args[0],args[1],args[2],args[3],true) when 5 raise ArgumentError if args[4].kind_of?(Numeric) super(args[0],args[1],args[2],args[3],args[4]) when 6 @control_1 = Point.new(args[0],args[1]) super(args[2],args[3],args[4],args[5],true) when 7 @control_1 = Point.new(args[0],args[1]) super(args[2],args[3],args[4],args[5],args[6]) end end |
Instance Attribute Details
#control_1 ⇒ Object
Returns the value of attribute control_1.
4 5 6 |
# File 'lib/savage/directions/cubic_curve_to.rb', line 4 def control_1 @control_1 end |
Instance Method Details
#command_code ⇒ Object
34 35 36 37 |
# File 'lib/savage/directions/cubic_curve_to.rb', line 34 def command_code return (absolute?) ? 'C' : 'c' if @control_1 (absolute?) ? 'S' : 's' end |
#control_2 ⇒ Object
31 |
# File 'lib/savage/directions/cubic_curve_to.rb', line 31 def control_2; @control; end |
#control_2=(value) ⇒ Object
32 |
# File 'lib/savage/directions/cubic_curve_to.rb', line 32 def control_2=(value); @control = value; end |
#to_a ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/savage/directions/cubic_curve_to.rb', line 23 def to_a if @control_1 [command_code, @control_1.x, @control_1.y, @control.x, @control.y, @target.x, @target.y] else [command_code, @control.x, @control.y, @target.x, @target.y] end end |