Class: Savage::Directions::QuadraticCurveTo

Inherits:
PointTarget show all
Defined in:
lib/savage/directions/quadratic_curve_to.rb

Direct Known Subclasses

CubicCurveTo

Instance Attribute Summary collapse

Attributes inherited from PointTarget

#target

Instance Method Summary collapse

Methods inherited from Savage::Direction

#absolute?, #to_command

Methods included from Utils

#bool_to_int

Constructor Details

#initialize(*args) ⇒ QuadraticCurveTo

Returns a new instance of QuadraticCurveTo.

Raises:

  • (ArgumentError)


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

#controlObject

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_codeObject



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_aObject



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