Class: Tracksperanto::Tool::Scaler

Inherits:
Base
  • Object
show all
Defined in:
lib/tools/scaler.rb

Overview

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

Constant Summary collapse

DEFAULT_FACTOR =
1

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize

Methods included from Parameters

#parameter, #parameters

Methods included from SimpleExport

#just_export

Methods included from ConstName

#const_name

Methods included from BlockInit

#initialize

Methods included from Casts

#cast_to_bool, #cast_to_float, #cast_to_int, #cast_to_string

Constructor Details

This class inherits a constructor from Tracksperanto::Tool::Base

Class Method Details

.action_descriptionObject



8
9
10
# File 'lib/tools/scaler.rb', line 8

def self.action_description
  "Scale the comp by a specified factor"
end

Instance Method Details

#export_point(frame, float_x, float_y, float_residual) ⇒ Object



27
28
29
30
31
32
33
34
35
# 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) ⇒ Object

Called on export start



13
14
15
16
17
# 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_factorObject



23
24
25
# File 'lib/tools/scaler.rb', line 23

def x_factor
  @x_factor || DEFAULT_FACTOR
end

#y_factorObject



19
20
21
# File 'lib/tools/scaler.rb', line 19

def y_factor
  @y_factor || DEFAULT_FACTOR
end