Class: Tracksperanto::Middleware::Reformat

Inherits:
Base
  • Object
show all
Defined in:
lib/middleware/reformat.rb

Overview

This middleware reformats (scales) the track setup to a specific pixel resolution. Very useful for applying proxy tracks to full-res images

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#end_tracker_segment, #export_point, inherited, #initialize, #start_tracker_segment

Methods included from SimpleExport

#just_export

Methods included from ConstName

#const_name, included

Methods included from BlockInit

#initialize

Methods included from Casts

#cast_to_float, #cast_to_int, #cast_to_string, included

Constructor Details

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

Instance Attribute Details

#heightObject

To which format we have to scale



8
9
10
# File 'lib/middleware/reformat.rb', line 8

def height
  @height
end

#widthObject

To which format we have to scale



8
9
10
# File 'lib/middleware/reformat.rb', line 8

def width
  @width
end

Instance Method Details

#end_exportObject



23
24
25
26
# File 'lib/middleware/reformat.rb', line 23

def end_export
  @exporter = @stash
  @exporter.end_export
end

#start_export(img_width, img_height) ⇒ Object

Called on export start



12
13
14
15
16
17
18
19
20
21
# File 'lib/middleware/reformat.rb', line 12

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