Sha256: 26fbd9f936ed5fdea08e24bf79a37ede6e7a827941a80e0c979f3874493ef928

Contents?: true

Size: 753 Bytes

Versions: 21

Compression:

Stored size: 753 Bytes

Contents

require File.dirname(__FILE__) + '/scaler'

# This middleware reformats (scales) the track setup to a specific pixel resolution. Very useful for
# applying proxy tracks to full-res images
class Tracksperanto::Middleware::Reformat < Tracksperanto::Middleware::Base
  
  # To which format we have to scale
  attr_accessor :width, :height
  cast_to_int :width, :height
  
  # Called on export start
  def start_export( img_width, img_height)
    @width ||= img_width # If they be nil
    @height ||= img_height
    
    x_factor, y_factor = (@width / img_width.to_f), (@height / img_height.to_f)  
    
    @stash = @exporter
    @exporter = Tracksperanto::Middleware::Scaler.new(@exporter, :x_factor => x_factor, :y_factor => y_factor)
    super
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
tracksperanto-2.1.1 lib/middleware/reformat.rb