Class: Yuki::Animation::EqAnimation

Inherits:
TimedAnimation show all
Includes:
Math
Defined in:
docs/4_Systems_005_Animation.rb

Overview

Class applying equation to sprite property using defined equation.

Equations are named and all their parameter is given by a hash. You can apply equations on several properties of the sprite.

Here's the name of the equations and their parameters:

  • :linear => a * t + b
  • :quadratic => a * t² + b * t + c
  • :cosine => a * cos(2pi * f * t + phi) + b
  • :variable_cosine => (a * cos(2pi * f2 * t + phi2) + b) * cos(2pi * f * t + phi) + c

Note: t ∈ [0, 1]

Equations may be expressed this way: `[[:property1, :equation_name, { **params }], [:property2, :equation_name, { **params }]]``

Direct Known Subclasses

EqOffsetAnimation

Defined Under Namespace

Modules: Offset

Constant Summary collapse

SPRITE_PROPERTY_TO_SETTER =

Constant mapping properties to their setter method

Returns:

  • (Hash{Symbol => Symbol})
{x: :x=, y: :y=, z: :z=, ox: :ox=, oy: :oy=, angle: :angle=, opacity: :opacity=}
TWO_PI =

Constant representing 2π

Returns:

  • (Float)
2 * PI

Instance Attribute Summary

Attributes inherited from TimedAnimation

#begin_time, #end_time, #time_source

Attributes included from Yuki::AnimationMixin

#player, #resolver

Instance Method Summary collapse

Methods inherited from TimedAnimation

#done?, #duration, #parallel_add, #play_before, #update

Methods included from Yuki::AnimationMixin

#begin_offset_for_next_animation, #done?, #duration, #update

Constructor Details

#initialize(time_to_process, on, equations, distortion: :UNICITY_DISTORTION, time_source: :SCENE_TIME_SOURCE) ⇒ EqAnimation

Create a new EqAnimation animation convert it to another number (between 0 & 1) in order to distord time

Parameters:

  • time_to_process (Float) —

    number of seconds (with generic time) to process the animation

  • on (Object) —

    object that will receive the property

  • equations (Array<Array[property, eq, params]>) —

    list of equations to apply

  • distortion (#call, Symbol) (defaults to: :UNICITY_DISTORTION) —

    callable taking one paramater (between 0 & 1) and

  • time_source (#call, Symbol) (defaults to: :SCENE_TIME_SOURCE) —

    callable taking no parameter and giving the current time



1132
1133
# File 'docs/4_Systems_005_Animation.rb', line 1132

def initialize(time_to_process, on, equations, distortion: :UNICITY_DISTORTION, time_source: :SCENE_TIME_SOURCE)
end

Instance Method Details

#start(begin_offset = 0) ⇒ self

Start the animation (initialize it)

Parameters:

  • begin_offset (Float) (defaults to: 0) —

    offset that prevents the animation from starting before now + begin_offset seconds

Returns:

  • (self)


1137
1138
# File 'docs/4_Systems_005_Animation.rb', line 1137

def start(begin_offset = 0)
end