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