module MovieMasher::FilterHelpers
helpers used by filter objects
Constants
- RGB_FORMAT
Public Class Methods
mm_cmp(param_string, _mash, _scope)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 9 def mm_cmp(param_string, _mash, _scope) params = __params_from_str(param_string) param0 = Evaluate.equation(params[0], true) param1 = Evaluate.equation(params[0], true) (param0 > param1 ? params[2] : params[3]) end
mm_dir_horz(param_string, _mash, _scope)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 16 def mm_dir_horz(param_string, _mash, _scope) if param_string.empty? raise(Error::JobInput, "mm_dir_horz no parameters #{param_string}") end params = __params_from_str(param_string) # puts "mm_dir_horz #{param_string}} #{params.join ','}" case params[0].to_i # direction value when 0, 2 # center with no change '((in_w-out_w)/2)' when 1, 4, 5 "((#{params[2]}-#{params[1]})*#{params[3]})" when 3, 6, 7 "((#{params[1]}-#{params[2]})*#{params[3]})" else raise(Error::JobInput, "unknown direction #{params[0]}") end end
mm_dir_vert(param_string, _mash, _scope)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 35 def mm_dir_vert(param_string, _mash, _scope) if param_string.empty? raise(Error::JobInput, "mm_dir_vert no parameters #{param_string}") end params = __params_from_str(param_string) # puts "mm_dir_vert #{param_string} #{params.join ','}" case params[0].to_i # direction value when 1, 3 # center with no change '((in_h-out_h)/2)' when 0, 4, 7 "((#{params[1]}-#{params[2]})*#{params[3]})" when 2, 5, 6 "((#{params[2]}-#{params[1]})*#{params[3]})" else raise(Error::JobInput, "unknown direction #{params[0]}") end end
mm_fontfamily(param_string, mash, _scope)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 65 def mm_fontfamily(param_string, mash, _scope) params = __params_from_str(param_string) font_id = params.join(',') font = __find_font(font_id, mash) raise(Error::JobInput, 'font has no family') unless font[:family] font[:family] end
mm_fontfile(param_string, mash, _scope)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 54 def mm_fontfile(param_string, mash, _scope) params = __params_from_str(param_string) font_id = params.join ',' font = __find_font(font_id, mash) unless font[:cached_file] raise(Error::JobInput, "font has not been cached #{font}") end font[:cached_file] end
mm_horz(param_string, mash = nil, scope = nil)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 74 def mm_horz(param_string, mash = nil, scope = nil) __horz_vert(:mm_width, param_string, mash, scope) end
mm_max(param_string, mash, scope)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 78 def mm_max(param_string, mash, scope) __max_min(:max, param_string, mash, scope) end
mm_min(param_string, mash, scope)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 82 def mm_min(param_string, mash, scope) __max_min(:min, param_string, mash, scope) end
mm_paren(param_string, _mash, _scope)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 86 def mm_paren(param_string, _mash, _scope) params = __params_from_str(param_string) "(#{params.join ','})" end
mm_textfile(param_string, _mash, scope)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 91 def mm_textfile(param_string, _mash, scope) job = scope[:mm_job] output = scope[:mm_output] path = Path.concat(job.output_path(output), "#{SecureRandom.uuid}.txt") params = __params_from_str(param_string) output[:commands] << { content: params.join(','), file: path } path end
mm_vert(param_string, mash = nil, scope = nil)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 100 def mm_vert(param_string, mash = nil, scope = nil) __horz_vert(:mm_height, param_string, mash, scope) end
rgb(param_string, _mash = nil, _scope = nil)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 104 def rgb(param_string, _mash = nil, _scope = nil) params = __params_from_str(param_string) format(RGB_FORMAT, *params) end
rgba(param_string, _mash = nil, _scope = nil)
click to toggle source
# File lib/graphs/filter_helpers.rb, line 109 def rgba(param_string, _mash = nil, _scope = nil) params = __params_from_str(param_string) alpha = params.pop.to_f result = format(RGB_FORMAT, *params) "#{result}@#{alpha}" end