class Tracksperanto::Tool::Scaler

Scales the comp being exported by a specific factor, together with the tracker keyframes

Constants

DEFAULT_FACTOR

Public Class Methods

action_description() click to toggle source
# File lib/tools/scaler.rb, line 8
def self.action_description
  "Scale the comp by a specified factor"
end

Public Instance Methods

export_point(frame, float_x, float_y, float_residual) click to toggle source
Calls superclass method
# File lib/tools/scaler.rb, line 27
def export_point(frame, float_x, float_y, float_residual)
  return super if @y_factor == DEFAULT_FACTOR && @x_factor == DEFAULT_FACTOR
  
  super(frame,
    x_factor < 0 ? (@w + (float_x * x_factor)) : (float_x * x_factor),
    y_factor < 0 ? (@h + (float_y * y_factor)) : (float_y * y_factor),
    (float_residual * @residual_factor)
  )
end
start_export( img_width, img_height) click to toggle source

Called on export start

Calls superclass method
# File lib/tools/scaler.rb, line 13
def start_export( img_width, img_height)
  set_residual_factor
  @w, @h = (img_width * x_factor).to_i.abs, (img_height * y_factor).to_i.abs
  super(@w, @h)
end
x_factor() click to toggle source
# File lib/tools/scaler.rb, line 23
def x_factor
  @x_factor || DEFAULT_FACTOR
end
y_factor() click to toggle source
# File lib/tools/scaler.rb, line 19
def y_factor
  @y_factor || DEFAULT_FACTOR
end

Private Instance Methods

set_residual_factor() click to toggle source
# File lib/tools/scaler.rb, line 38
def set_residual_factor
  @residual_factor = Math.sqrt((x_factor ** 2) + (y_factor ** 2))
end