Class: DYI::Animation::TransformAnimation
- Defined in:
- lib/dyi/animation.rb
Overview
Class representing an animation of transform
Constant Summary collapse
- IMPLEMENT_ATTRIBUTES =
[:type]
- VALID_VALUES =
{ :type => [:translate, :scale, :rotate, :skewX, :skewY] }
Instance Attribute Summary collapse
-
#from ⇒ Numeric|Array
a starting value of the animation.
- #relays ⇒ Array
-
#to ⇒ Numeric|Array
a ending value of the animation.
-
#type ⇒ Symbol
a type of transform, either ‘translate’, ‘scale’, ‘rotate’, ‘skewX’ or ‘skewY’.
Attributes inherited from Base
#additive, #calc_mode, #fill, #key_splines, #repeat_count, #restart
Class Method Summary collapse
- .rotate(shape, options) ⇒ Object
- .scale(shape, options) ⇒ Object
- .skew_x(shape, options) ⇒ Object
- .skew_y(shape, options) ⇒ Object
- .translate(shape, options) ⇒ Object
Instance Method Summary collapse
-
#initialize(shape, type, options) ⇒ TransformAnimation
constructor
A new instance of TransformAnimation.
- #write_as(formatter, shape, io = $>) ⇒ Object
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.
418 419 420 421 |
# File 'lib/dyi/animation.rb', line 418 def initialize(shape, type, ) @type = type super(shape, ) end |
Instance Attribute Details
#from ⇒ Numeric|Array
a starting value of the animation
250 251 252 |
# File 'lib/dyi/animation.rb', line 250 def from @from end |
#relays ⇒ Array
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 |
#to ⇒ Numeric|Array
a ending value of the animation
250 251 252 |
# File 'lib/dyi/animation.rb', line 250 def to @to end |
#type ⇒ Symbol
a type of transform, either ‘translate’, ‘scale’, ‘rotate’, ‘skewX’ or ‘skewY’
250 251 252 |
# File 'lib/dyi/animation.rb', line 250 def type @type end |
Class Method Details
.rotate(shape, options) ⇒ Object
437 438 439 |
# File 'lib/dyi/animation.rb', line 437 def rotate(shape, ) new(shape, :rotate, ) end |
.scale(shape, options) ⇒ Object
433 434 435 |
# File 'lib/dyi/animation.rb', line 433 def scale(shape, ) new(shape, :scale, ) end |
.skew_x(shape, options) ⇒ Object
441 442 443 |
# File 'lib/dyi/animation.rb', line 441 def skew_x(shape, ) new(shape, :skewX, ) end |
.skew_y(shape, options) ⇒ Object
445 446 447 |
# File 'lib/dyi/animation.rb', line 445 def skew_y(shape, ) new(shape, :skewY, ) end |
.translate(shape, options) ⇒ Object
429 430 431 |
# File 'lib/dyi/animation.rb', line 429 def translate(shape, ) new(shape, :translate, ) end |
Instance Method Details
#write_as(formatter, shape, io = $>) ⇒ Object
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 |