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
Constant Summary
Constants inherited from Scaler
Instance Attribute Summary collapse
-
#height ⇒ Object
To which format we have to scale.
-
#width ⇒ Object
To which format we have to scale.
Attributes inherited from Scaler
Instance Method Summary collapse
-
#start_export(img_width, img_height) ⇒ Object
Called on export start.
Methods inherited from Scaler
Methods inherited from Base
#end_export, #end_tracker_segment, #export_point, #initialize, #start_tracker_segment
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
#start_export(img_width, img_height) ⇒ Object
Called on export start
14 15 16 17 18 19 20 21 22 |
# File 'lib/middleware/reformat.rb', line 14 def start_export( img_width, img_height) @width ||= img_width @height ||= img_height self.x_factor, self.y_factor = (@width / img_width.to_f), (@height / img_height.to_f) set_residual_factor # Do not call super since it scales by itself :-) @exporter.start_export(@width, @height) end |