class MovieMasher::GraphMash

a mash represented as a graph

Public Class Methods

new(job, mash_input, render_range = nil, label_name = 'layer') click to toggle source
Calls superclass method MovieMasher::Graph.new
# File lib/graph.rb, line 228
def initialize(job, mash_input, render_range = nil, label_name = 'layer')
  @label_name = label_name
  super(job, mash_input, render_range)
  @layers = []
  @layers << LayerColor.new(duration, mash_input[:mash][:backcolor])
end

Public Instance Methods

add_new_layer(input) click to toggle source
# File lib/graph.rb, line 197
def add_new_layer(input)
  layer = create_layer(input)
  @layers << layer
  layer
end
graph_command(*) click to toggle source
Calls superclass method MovieMasher::Graph#graph_command
# File lib/graph.rb, line 202
def graph_command(*)
  super
  graph_cmds = []
  layer_length = @layers.length
  layer_length.times do |i|
    layer = @layers[i]
    cmd = layer.layer_command(graph_scope)
    cmd += layer.trim_command(@render_range)
    cmd += "[#{@label_name}#{i}]" if 1 < layer_length
    graph_cmds << cmd
  end
  if 1 < layer_length
    (1..layer_length - 1).each do |i|
      layer = @layers[i]
      cmd = (1 == i ? "[#{@label_name}0]" : "[#{@label_name}ed#{i - 1}]")
      cmd += "[#{@label_name}#{i}]"
      merge_cmd = layer.merger_command(graph_scope)
      __raise_if_empty(merge_cmd, "merger produced nothing #{layer}")
      cmd += merge_cmd
      cmd += "[#{@label_name}ed#{i}]" if i + 1 < layer_length
      graph_cmds << cmd
    end
  end
  cmd = graph_cmds.join ';'
  cmd
end