Class: Tracksperanto::Middleware::Reformat
- 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
-
#height ⇒ Object
To which format we have to scale.
-
#width ⇒ Object
To which format we have to scale.
Instance Method Summary collapse
- #end_export ⇒ Object
-
#start_export(img_width, img_height) ⇒ Object
Called on export start.
Methods inherited from Base
#end_tracker_segment, #export_point, inherited, #initialize, #start_tracker_segment
Methods included from SimpleExport
Methods included from ConstName
Methods included from BlockInit
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
#height ⇒ Object
To which format we have to scale
8 9 10 |
# File 'lib/middleware/reformat.rb', line 8 def height @height end |
#width ⇒ Object
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_export ⇒ Object
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 |