Class: DYI::Animation::PaintingAnimation

Inherits:
Base
  • Object
show all
Defined in:
lib/dyi/animation.rb

Overview

Class representing an animation of a painting

Since:

  • 1.0.0

Constant Summary

Constants inherited from Base

Base::IMPLEMENT_ATTRIBUTES, Base::VALID_VALUES

Instance Attribute Summary collapse

Attributes inherited from Base

#additive, #calc_mode, #fill, #key_splines, #repeat_count, #restart

Instance Method Summary collapse

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

#fromPainting

Returns a starting value of the animation.

Returns:

  • (Painting)

    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

#relaysArray<Painting>

Returns:

Since:

  • 1.3.0



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_attributesObject

Since:

  • 1.0.0



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

Since:

  • 1.0.0



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

Since:

  • 1.0.0



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