Class: DYI::Animation::PaintingAnimation
- Defined in:
- lib/dyi/animation.rb
Overview
Class representing an animation of a painting
Constant Summary
Constants inherited from Base
Base::IMPLEMENT_ATTRIBUTES, Base::VALID_VALUES
Instance Attribute Summary collapse
-
#from ⇒ Painting
Returns a starting value of the animation.
- #relays ⇒ Array<Painting>
Attributes inherited from Base
#additive, #calc_mode, #fill, #key_splines, #repeat_count, #restart
Instance Method Summary collapse
- #animation_attributes ⇒ Object
- #to=(painting) ⇒ Object
- #write_as(formatter, shape, io = $>) ⇒ Object
Methods inherited from Base
#accumulate=, #accumulate?, #begin_event=, #begin_offset=, #duration=, #end_event=, #end_offset=, #initialize, #relay_times=
Constructor Details
This class inherits a constructor from DYI::Animation::Base
Instance Attribute Details
#from ⇒ Painting
Returns a starting value of the animation.
213 214 215 |
# File 'lib/dyi/animation.rb', line 213 def from=(painting) @from = painting && DYI::Painting.new(painting) end |
#relays ⇒ Array<Painting>
224 225 226 |
# File 'lib/dyi/animation.rb', line 224 def relays=(paintings) @relays = paintings.map{|painting| DYI::Painting.new(painting)} end |
Instance Method Details
#animation_attributes ⇒ Object
228 229 230 231 232 233 234 235 236 237 |
# File 'lib/dyi/animation.rb', line 228 def animation_attributes DYI::Painting::IMPLEMENT_ATTRIBUTES.inject({}) do |result, attr| from_attr, to_attr = @from && @from.__send__(attr), @to.__send__(attr) relay_attrs = @relays.map{|relay| relay.__send__(attr)} if to_attr && (from_attr != to_attr || relay_attrs.any?{|relay_attr| from_attr != relay_attrs || relay_attr != to_attr}) result[attr] = [from_attr].push(*relay_attrs).push(to_attr) end result end end |
#to=(painting) ⇒ Object
217 218 219 |
# File 'lib/dyi/animation.rb', line 217 def to=(painting) @to = DYI::Painting.new(painting) end |
#write_as(formatter, shape, io = $>) ⇒ Object
239 240 241 242 |
# File 'lib/dyi/animation.rb', line 239 def write_as(formatter, shape, io=$>) formatter.write_painting_animation(self, shape, io, &(block_given? ? Proc.new : nil)) end |