Class: Metro::Easing
- Inherits:
-
Object
- Object
- Metro::Easing
- Defined in:
- lib/metro/animation/easing/easing.rb,
lib/metro/animation/easing/linear.rb,
lib/metro/animation/easing/ease_in.rb
Overview
An easing is a means to calculate the steps between the start and the final over an interval.
Direct Known Subclasses
Defined Under Namespace
Class Method Summary collapse
-
.calculate(start, final, interval) ⇒ Object
The calculate method is called within the ImplicitAnimation and will create an array of all the states between the start and the final value.
-
.calculation(moment, start, change, interval) ⇒ Object
The calculation method is to be overriden in the Easing subclasses.
-
.easing_for(easing) ⇒ Object
The easing class based on the specified easing name.
-
.easings ⇒ Object
A hash of all the supported easings within metro or game.
-
.register(name, easing_class) ⇒ Object
Register an easing within the game system.
Class Method Details
.calculate(start, final, interval) ⇒ Object
The calculate method is called within the ImplicitAnimation and will create an array of all the states between the start and the final value.
13 14 15 16 |
# File 'lib/metro/animation/easing/easing.rb', line 13 def self.calculate(start,final,interval) change = final - start (1..interval).map { |time| calculation(time.to_f,start,change,interval) } end |
.calculation(moment, start, change, interval) ⇒ Object
The calculation method is to be overriden in the Easing subclasses. This calculation figures out the value at the current moemnt.
22 |
# File 'lib/metro/animation/easing/easing.rb', line 22 def self.calculation(moment,start,change,interval) ; 0 ; end |
.easing_for(easing) ⇒ Object
Returns the easing class based on the specified easing name.
34 35 36 37 |
# File 'lib/metro/animation/easing/easing.rb', line 34 def self.easing_for(easing) easing_classname = easings[easing] easing_classname.constantize end |
.easings ⇒ Object
A hash of all the supported easings within metro or game.
42 43 44 |
# File 'lib/metro/animation/easing/easing.rb', line 42 def self.easings @easings_hash ||= HashWithIndifferentAccess.new("Metro::Easing::Linear") end |
.register(name, easing_class) ⇒ Object
Register an easing within the game system.
27 28 29 |
# File 'lib/metro/animation/easing/easing.rb', line 27 def self.register(name,easing_class) easings[name] = easing_class.to_s end |