Class: DYI::Animation::TransformAnimation

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

Overview

Class representing an animation of transform

Since:

  • 1.0.0

Constant Summary collapse

IMPLEMENT_ATTRIBUTES =

Since:

  • 1.0.0

[:type]
VALID_VALUES =

Since:

  • 1.0.0

{
  :type => [:translate, :scale, :rotate, :skewX, :skewY]
}

Instance Attribute Summary collapse

Attributes inherited from Base

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#accumulate=, #accumulate?, #begin_event=, #begin_offset=, #duration=, #end_event=, #end_offset=, #relay_times=

Constructor Details

#initialize(shape, type, options) ⇒ TransformAnimation

Returns a new instance of TransformAnimation.

Since:

  • 1.0.0



418
419
420
421
# File 'lib/dyi/animation.rb', line 418

def initialize(shape, type, options)
  @type = type
  super(shape, options)
end

Instance Attribute Details

#fromNumeric|Array

a starting value of the animation

Returns:

  • (Numeric|Array)

    the current value of from



250
251
252
# File 'lib/dyi/animation.rb', line 250

def from
  @from
end

#relaysArray

Returns:

  • (Array)

Since:

  • 1.3.0



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/dyi/animation.rb', line 368

def relays=(values)
  @relays =
      case type
      when :translate
        values.map do |value|
          case value
          when Array
            case value.size
              when 2 then value.map{|v| v.to_f}
              else raise ArgumentError, "illegal size of Array: #{value.size}"
            end
          when Numeric, Length
            [value.to_f, 0]
          else
            raise TypeError, "illegal argument: #{value}"
          end
        end
      when :scale
        values.map do |value|
          case value
          when Array
            case value.size
              when 2 then value.map{|v| v.to_f}
              else raise ArgumentError, "illegal size of Array: #{value.size}"
            end
          when Numeric
            [value.to_f, value.to_f]
          else
            raise TypeError, "illegal argument: #{value}"
          end
        end
      when :rotate
        values.map do |value|
          case value
          when Array
            case value.size
              when 3 then value.map{|v| v.to_f}
              else raise ArgumentError, "illegal size of Array: #{value.size}"
            end
          when Numeric
            value.to_f
          else
            raise TypeError, "illegal argument: #{value}"
          end
        end
      when :skewX, :skewY
        values.map{|value| value.to_f}
      end
end

#toNumeric|Array

a ending value of the animation

Returns:

  • (Numeric|Array)

    the current value of to



250
251
252
# File 'lib/dyi/animation.rb', line 250

def to
  @to
end

#typeSymbol

a type of transform, either ‘translate’, ‘scale’, ‘rotate’, ‘skewX’ or ‘skewY’

Returns:

  • (Symbol)

    the current value of type



250
251
252
# File 'lib/dyi/animation.rb', line 250

def type
  @type
end

Class Method Details

.rotate(shape, options) ⇒ Object

Since:

  • 1.0.0



437
438
439
# File 'lib/dyi/animation.rb', line 437

def rotate(shape, options)
  new(shape, :rotate, options)
end

.scale(shape, options) ⇒ Object

Since:

  • 1.0.0



433
434
435
# File 'lib/dyi/animation.rb', line 433

def scale(shape, options)
  new(shape, :scale, options)
end

.skew_x(shape, options) ⇒ Object

Since:

  • 1.0.0



441
442
443
# File 'lib/dyi/animation.rb', line 441

def skew_x(shape, options)
  new(shape, :skewX, options)
end

.skew_y(shape, options) ⇒ Object

Since:

  • 1.0.0



445
446
447
# File 'lib/dyi/animation.rb', line 445

def skew_y(shape, options)
  new(shape, :skewY, options)
end

.translate(shape, options) ⇒ Object

Since:

  • 1.0.0



429
430
431
# File 'lib/dyi/animation.rb', line 429

def translate(shape, options)
  new(shape, :translate, options)
end

Instance Method Details

#write_as(formatter, shape, io = $>) ⇒ Object

Since:

  • 1.0.0



423
424
425
426
# File 'lib/dyi/animation.rb', line 423

def write_as(formatter, shape, io=$>)
  formatter.write_transform_animation(self, shape, io,
                                      &(block_given? ? Proc.new : nil))
end