Concepts
Functions
The Function interface represents a mathematical function.
Its purpose is to associate a floating value to any input floating value between 0f
and 1f
.
This function specifies the rate of change of a parameter over time (for example the position of an object).
The library provides a set of functions among the most common ones. Each one contains a convenient instance. For example the singleton for the linear function.
Simple functions
The constant function represents a constant motion whose value is always the stop value.
The linear function represents a uniform linear motion: the velocity is constant (no acceleration or deceleration).
Easing functions
The easing functions come in 3 forms:
Ease-in: the function is eased at the beginning.
Ease-out: the function is eased at the end.
Ease-in-out: the function is eased at the beginning and the end.
Here are the easing functions available in the library:
Circ ease-in | Circ ease-out | Circ ease-in-out |
Cubic ease-in | Cubic ease-out | Cubic ease-in-out |
Expo ease-in | Expo ease-out | Expo ease-in-out |
Quad ease-in | Quad ease-out | Quad ease-in-out |
Quart ease-in | Quart ease-out | Quart ease-in-out |
Quint ease-in | Quint ease-out | Quint ease-in-out |
Sine ease-in | Sine ease-out | Sine ease-in-out |
Back ease-in | Back ease-out | Back ease-in-out |
Bounce ease-in | Bounce ease-out | Bounce ease-in-out |
Elastic ease-in | Elastic ease-out | Elastic ease-in-out |
Custom Function
It is possible to create custom functions by creating a class implementing the Function interface.
The computeValue(float) method should return a value between 0f
and 1f
.
Motion
The Motion class is used to describe the movement of an element. It is made of a function, a start value, a stop value and a duration.
It proposes a convenient method Motion.getValue(long) to retrieve the position of the element at the specified elapsed time.