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 PointTarget

#movement

Methods inherited from Savage::Direction

#absolute?, #fully_transformable?, #relative?, #to_command

Methods included from Transformable

#rotate, #scale, #skew_x, #skew_y, #translate

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

#transform(scale_x, skew_x, skew_y, scale_y, tx, ty) ⇒ Object



36
37
38
39
40
41
# File 'lib/savage/directions/quadratic_curve_to.rb', line 36

def transform(scale_x, skew_x, skew_y, scale_y, tx, ty)
  # relative line_to dont't need to be tranlated
  tx = ty = 0 if relative?
  transform_dot( target,  scale_x, skew_x, skew_y, scale_y, tx, ty)
  transform_dot( control, scale_x, skew_x, skew_y, scale_y, tx, ty) if control
end