class Castaway::Scene
Attributes
Public Class Methods
# File lib/castaway/scene.rb, line 19 def initialize(title, production) @title = title @production = production end
Public Instance Methods
# File lib/castaway/scene.rb, line 129 def _still(filename, full) Element::Still.new(production, self, filename, full: full). tap do |element| _timeline.add(element) end end
# File lib/castaway/scene.rb, line 136 def _strip(text) if text =~ /^(\s+)\S/ indent = Regexp.last_match(1) text.gsub(/^#{indent}/, '') else text end end
# File lib/castaway/scene.rb, line 24 def configure(&block) instance_eval(&block) self end
# File lib/castaway/scene.rb, line 73 def construct(timeline) @_timeline = timeline instance_eval(&@plan) if @plan ensure remove_instance_variable :@_timeline end
Returns a new Castaway::Element::Matte
element with the given color, and adds it to the timeline.
# File lib/castaway/scene.rb, line 82 def matte(color) Element::Matte.new(production, self, color).tap do |element| _timeline.add(element) end end
Returns a new Castaway::Element::Pointer
element and adds it to the timeline. If an `id` is given, the pointer declared with that `id` is used.
# File lib/castaway/scene.rb, line 103 def pointer(id = :default) Element::Pointer.new(production, self, id).tap do |pointer| _timeline.add(pointer) end end
Returns a Castaway::Point
with the given coordinates multiplied by the resolution. This let's you declare coordinates as fractions of the frame size, so that they work regardless of the final rendered resolution.
# File lib/castaway/scene.rb, line 120 def relative_position(x, y) Castaway::Point.new(x, y) * production.resolution end
Returns a new Castaway::RelativeTo
instance for the resource with the given file name. This is useful for positioning pointers in a resolution-independent way.
# File lib/castaway/scene.rb, line 45 def relative_to_image(name) RelativeTo.new(name, production) end
Sets (or returns) the script corresponding to the current scene. This is not used, except informationally.
# File lib/castaway/scene.rb, line 51 def script(*args) if args.empty? @script elsif args.length == 1 @script = _strip(args.first) else raise ArgumentError, 'script expects 0 or 1 argument' end end
Returns a new Castaway::Element::Still
element for the given filename, and adds it to the timeline. It's native dimensions will be preserved.
# File lib/castaway/scene.rb, line 96 def sprite(filename) _still(filename, false) end
Declares (or returns) the time value (in seconds) for the start of this scene. Any value parsable by Castaway::Times
will be accepted.
# File lib/castaway/scene.rb, line 31 def start(value = nil) return @start unless value @start = _parse_time(value) end
Returns a new Castaway::Element::Still
element for the given filename, and adds it to the timeline. It will be forced to fill the entire frame.
# File lib/castaway/scene.rb, line 90 def still(filename) _still(filename, true) end
Returns a new Castaway::Element::Text
element with the given text, and adds it to the timeline.
# File lib/castaway/scene.rb, line 111 def text(string) Element::Text.new(production, self, string).tap do |text| _timeline.add(text) end end
Parses and returns the seconds corresponding to the given value. See Castaway::Times
.
# File lib/castaway/scene.rb, line 38 def time(value) _parse_time(value) end
# File lib/castaway/scene.rb, line 124 def update_from_next(neighbor) @finish = neighbor.nil? ? @start : neighbor.start @duration = @finish - @start end