Class: Savage::Directions::ArcTo

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

Instance Attribute Summary collapse

Attributes inherited from PointTarget

#target

Attributes inherited from Savage::Direction

#absolute

Instance Method Summary collapse

Methods inherited from Savage::Direction

#absolute?, #relative?, #to_command

Methods included from Transformable

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

Methods included from Utils

#bool_to_int

Constructor Details

#initialize(radius_x, radius_y, rotation, large_arc, sweep, target_x, target_y, absolute = true) ⇒ ArcTo

Returns a new instance of ArcTo.



6
7
8
9
10
11
12
# File 'lib/ext/savage/lib/savage/directions/arc_to.rb', line 6

def initialize(radius_x, radius_y, rotation, large_arc, sweep, target_x, target_y, absolute=true)
  super(target_x, target_y, absolute)
  @radius = Point.new(radius_x, radius_y)
  @rotation = rotation
  @large_arc = large_arc.is_a?(Numeric) ? large_arc > 0 : large_arc
  @sweep = sweep.is_a?(Numeric) ? sweep > 0 : sweep
end

Instance Attribute Details

#large_arcObject

Returns the value of attribute large_arc.



4
5
6
# File 'lib/ext/savage/lib/savage/directions/arc_to.rb', line 4

def large_arc
  @large_arc
end

#radiusObject

Returns the value of attribute radius.



4
5
6
# File 'lib/ext/savage/lib/savage/directions/arc_to.rb', line 4

def radius
  @radius
end

#rotationObject

Returns the value of attribute rotation.



4
5
6
# File 'lib/ext/savage/lib/savage/directions/arc_to.rb', line 4

def rotation
  @rotation
end

#sweepObject

Returns the value of attribute sweep.



4
5
6
# File 'lib/ext/savage/lib/savage/directions/arc_to.rb', line 4

def sweep
  @sweep
end

Instance Method Details

#command_codeObject



18
19
20
# File 'lib/ext/savage/lib/savage/directions/arc_to.rb', line 18

def command_code
  (absolute?) ? 'A' : 'a'
end

#to_aObject



14
15
16
# File 'lib/ext/savage/lib/savage/directions/arc_to.rb', line 14

def to_a
  [command_code, @radius.x, @radius.y, @rotation, bool_to_int(@large_arc), bool_to_int(@sweep), target.x, target.y]
end

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



22
23
24
25
26
# File 'lib/ext/savage/lib/savage/directions/arc_to.rb', line 22

def transform(scale_x, skew_x, skew_y, scale_y, tx, ty)
  # relative arc_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)
end