Sha256: 644c1e9ce7fd7ea62b40fb22b779539408f4442aefa83a5a37dbfa8ca1ba6316

Contents?: true

Size: 1.26 KB

Versions: 10

Compression:

Stored size: 1.26 KB

Contents

# -*- encoding : utf-8 -*-
# Exports trackers as an AfterEffects script creating nulls
class Tracksperanto::Export::AE < Tracksperanto::Export::Base

  PREAMBLE = '// Run this script from the Script Editor
function convertFrameToSeconds(layerWithFootage, frameValue)
  {
  		var comp = layerWithFootage.containingComp;
  		var rate = 1.0 / comp.frameDuration;
  		// Frames in AE are 0-based by default
  		return (frameValue) / rate;
  }'

  def self.desc_and_extension
    "createNulls.jsx"
  end
  
  def self.human_name
    "AfterEffects .jsx script generating null layers"
  end
  
  def start_export(w, h)
    @io.puts(PREAMBLE)
    @io.puts("")
    @count = 0
    @height = h
  end
  
  def start_tracker_segment(tracker_name)
    @io.puts("")
    @io.puts('var layer%d = app.project.activeItem.layers.addNull();' % @count)
    @io.puts( 'layer%d.name = %s;' % [@count, tracker_name.inspect])
    @io.puts("")
    @io.puts('var pos = layer%d.property("Transform").property("Position");' % @count)
  end
  
  def export_point(frame, abs_float_x, abs_float_y, float_residual)
    @io.puts('pos.setValueAtTime(convertFrameToSeconds(layer%d, %d), [%0.5f,%0.5f]);' % [@count, frame, abs_float_x, @height - abs_float_y])
  end
  
  def end_tracker_segment
    @count += 1
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tracksperanto-2.11.2 lib/export/cosa.rb
tracksperanto-2.11.1 lib/export/cosa.rb
tracksperanto-2.11.0 lib/export/cosa.rb
tracksperanto-2.10.0 lib/export/cosa.rb
tracksperanto-2.9.9 lib/export/cosa.rb
tracksperanto-2.9.8 lib/export/cosa.rb
tracksperanto-2.9.7 lib/export/cosa.rb
tracksperanto-2.9.6 lib/export/cosa.rb
tracksperanto-2.9.5 lib/export/cosa.rb
tracksperanto-2.9.4 lib/export/cosa.rb