Sha256: 494fdf0d2ae0ea689b8d861315a0514c783b50a2eee51b0ab93e9808583d888e

Contents?: true

Size: 1.65 KB

Versions: 38

Compression:

Stored size: 1.65 KB

Contents

# The base middleware class works just like a Tracksperanto::Export::Base, but it only wraps another exporting object and does not get registered on it's own
# as an export format. Middleware can be used to massage the tracks being exported in various interesting ways - like moving the coordinates, clipping the keyframes,
# scaling the whole export or even reversing the trackers to go backwards
class Tracksperanto::Middleware::Base
  include Tracksperanto::Casts
  include Tracksperanto::BlockInit
  include Tracksperanto::ConstName
  include Tracksperanto::SimpleExport
  
  # Used to automatically register your middleware in Tracksperanto.middlewares
  # Normally you wouldn't need to override this
  def self.inherited(by)
    Tracksperanto.middlewares << by
    super
  end
  
  # Constructor accepts the exporter that will be wrapped
  def initialize(exporter, *args_for_block_init)
    @exporter = exporter
    super(*args_for_block_init)
  end
  
  # Called on export start
  def start_export( img_width, img_height)
    @exporter.start_export(img_width, img_height)
  end
  
  # Called on export end
  def end_export
    @exporter.end_export
  end
  
  # Called on tracker start, one for each tracker. Start of the next tracker
  # signifies that the previous tracker has passed by
  def start_tracker_segment(tracker_name)
    @exporter.start_tracker_segment(tracker_name)
  end
  
  # Called on tracker end
  def end_tracker_segment
    @exporter.end_tracker_segment
  end
  
  # Called for each tracker keyframe
  def export_point(at_frame_i, abs_float_x, abs_float_y, float_residual)
    @exporter.export_point(at_frame_i, abs_float_x, abs_float_y, float_residual)
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
tracksperanto-1.7.0 lib/middleware/base.rb
tracksperanto-1.6.9 lib/middleware/base.rb
tracksperanto-1.6.8 lib/middleware/base.rb
tracksperanto-1.6.7 lib/middleware/base.rb
tracksperanto-1.6.6 lib/middleware/base.rb
tracksperanto-1.6.5 lib/middleware/base.rb
tracksperanto-1.6.4 lib/middleware/base.rb
tracksperanto-1.6.3 lib/middleware/base.rb
tracksperanto-1.6.2 lib/middleware/base.rb
tracksperanto-1.6.1 lib/middleware/base.rb
tracksperanto-1.6.0 lib/middleware/base.rb
tracksperanto-1.5.7 lib/middleware/base.rb
tracksperanto-1.5.6 lib/middleware/base.rb
tracksperanto-1.5.5 lib/middleware/base.rb
tracksperanto-1.5.4 lib/middleware/base.rb
tracksperanto-1.5.3 lib/middleware/base.rb
tracksperanto-1.5.2 lib/middleware/base.rb
tracksperanto-1.5.1 lib/middleware/base.rb