Sha256: ff93fb7b826f1575601ca6c6bb2660b9c965fccfb1d04f21c9d39ea3e248a269

Contents?: true

Size: 863 Bytes

Versions: 48

Compression:

Stored size: 863 Bytes

Contents

# Scales the comp being exported by a specific factor, together with the tracker keyframes
class Tracksperanto::Middleware::Scaler < Tracksperanto::Middleware::Base
  DEFAULT_FACTOR = 1
  
  attr_accessor :x_factor, :y_factor
  cast_to_float :x_factor, :y_factor
  
  # Called on export start
  def start_export( img_width, img_height)
    set_residual_factor
    super( (img_width * x_factor).to_i, (img_height * y_factor).to_i)
  end
  
  def y_factor
    @y_factor || DEFAULT_FACTOR
  end
  
  def x_factor
    @x_factor || DEFAULT_FACTOR
  end
  
  def export_point(frame, float_x, float_y, float_residual)
    super(frame, 
      (float_x * x_factor), 
      (float_y * y_factor), 
      (float_residual * @residual_factor)
    )
  end
  
  private
    def set_residual_factor
      @residual_factor = Math.sqrt((x_factor ** 2) + (y_factor ** 2))
    end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
tracksperanto-2.0.1 lib/middleware/scaler.rb
tracksperanto-2.0.0 lib/middleware/scaler.rb
tracksperanto-1.9.9 lib/middleware/scaler.rb
tracksperanto-1.9.8 lib/middleware/scaler.rb
tracksperanto-1.9.6 lib/middleware/scaler.rb
tracksperanto-1.9.5 lib/middleware/scaler.rb
tracksperanto-1.9.4 lib/middleware/scaler.rb
tracksperanto-1.9.3 lib/middleware/scaler.rb
tracksperanto-1.9.2 lib/middleware/scaler.rb
tracksperanto-1.9.1 lib/middleware/scaler.rb
tracksperanto-1.9.0 lib/middleware/scaler.rb
tracksperanto-1.8.4 lib/middleware/scaler.rb
tracksperanto-1.8.2 lib/middleware/scaler.rb
tracksperanto-1.8.1 lib/middleware/scaler.rb
tracksperanto-1.8.0 lib/middleware/scaler.rb
tracksperanto-1.7.5 lib/middleware/scaler.rb
tracksperanto-1.7.4 lib/middleware/scaler.rb
tracksperanto-1.7.3 lib/middleware/scaler.rb
tracksperanto-1.7.2 lib/middleware/scaler.rb
tracksperanto-1.7.1 lib/middleware/scaler.rb