![]() |
Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
|
Predefined easing functions. More...
#include <gf/Easings.h>
Public Member Functions | |
Ease ()=delete | |
Deleted constructor. More... | |
Static Public Member Functions | |
static float | linear (float t) |
Linear easing. More... | |
static float | smooth (float t) |
Smooth easing. More... | |
static float | smoother (float t) |
Smoother easing. More... | |
static float | quadIn (float t) |
Ease-In flavor of quad easing. More... | |
static float | quadOut (float t) |
Ease-Out flavor of quad easing. More... | |
static float | quadInOut (float t) |
Ease-In-Out flavor of quad easing. More... | |
static float | quadOutIn (float t) |
Ease-Out-In flavor of quad easing. More... | |
static float | cubicIn (float t) |
Ease-In flavor of cubic easing. More... | |
static float | cubicOut (float t) |
Ease-Out flavor of cubic easing. More... | |
static float | cubicInOut (float t) |
Ease-In-Out flavor of cubic easing. More... | |
static float | cubicOutIn (float t) |
Ease-Out-In flavor of cubic easing. More... | |
static float | quartIn (float t) |
Ease-In flavor of quart easing. More... | |
static float | quartOut (float t) |
Ease-Out flavor of quart easing. More... | |
static float | quartInOut (float t) |
Ease-In-Out flavor of quart easing. More... | |
static float | quartOutIn (float t) |
Ease-Out-In flavor of quart easing. More... | |
static float | quintIn (float t) |
Ease-In flavor of quint easing. More... | |
static float | quintOut (float t) |
Ease-Out flavor of quint easing. More... | |
static float | quintInOut (float t) |
Ease-In-Out flavor of quint easing. More... | |
static float | quintOutIn (float t) |
Ease-Out-In flavor of quint easing. More... | |
static float | circIn (float t) |
Ease-In flavor of circ easing. More... | |
static float | circOut (float t) |
Ease-Out flavor of circ easing. More... | |
static float | circInOut (float t) |
Ease-In-Out flavor of circ easing. More... | |
static float | circOutIn (float t) |
Ease-Out-In flavor of circ easing. More... | |
static float | sineIn (float t) |
Ease-In flavor of sine easing. More... | |
static float | sineOut (float t) |
Ease-Out flavor of sine easing. More... | |
static float | sineInOut (float t) |
Ease-In-Out flavor of sine easing. More... | |
static float | sineOutIn (float t) |
Ease-Out-In flavor of sine easing. More... | |
static float | backIn (float t) |
Ease-In flavor of back easing. More... | |
static float | backOut (float t) |
Ease-Out flavor of back easing. More... | |
static float | backInOut (float t) |
Ease-In-Out flavor of back easing. More... | |
static float | backOutIn (float t) |
Ease-Out-In flavor of back easing. More... | |
static float | bounceIn (float t) |
Ease-In flavor of bounce easing. More... | |
static float | bounceOut (float t) |
Ease-Out flavor of bounce easing. More... | |
static float | bounceInOut (float t) |
Ease-Out-In flavor of bounce easing. More... | |
static float | bounceOutIn (float t) |
Ease-In-Out flavor of bounce easing. More... | |
static float | elasticIn (float t) |
Ease-In flavor of elastic easing. More... | |
static float | elasticOut (float t) |
Ease-Out flavor of elastic easing. More... | |
static float | elasticInOut (float t) |
Ease-In-Out flavor of elastic easing. More... | |
static float | elasticOutIn (float t) |
Ease-Out-In flavor of elastic easing. More... | |
static float | expoIn (float t) |
Ease-In flavor of expo easing. More... | |
static float | expoOut (float t) |
Ease-Out flavor of expo easing. More... | |
static float | expoInOut (float t) |
Ease-In-Out flavor of expo easing. More... | |
static float | expoOutIn (float t) |
Ease-Out-In flavor of expo easing. More... | |
Predefined easing functions.
This class defines usual easing functions.
The first set of functions are common interpolation functions.
\[ f(t) = t \]
\[ f(t) = -2 * t^3 + 3 * t^2 \]
\[ f(t) = 6 * t^5 - 15 * t^4 + 10 * t^3 \]
Here are the plots of these functions:
Functions | Plot |
---|---|
linear | ![]() |
smooth | ![]() |
smoother | ![]() |
The second set are the easing functions defined by Robert Penner. From a base function \( f(t) \), four flavors are defined:
\[ \mathtt{easeIn}(t) = f(t) \]
\[ \mathtt{easeOut}(t) = 1 - \mathtt{easeIn}(1 - t) \]
\[ \mathtt{easeInOut}(t) = \begin{cases} \mathtt{easeIn}(2 \times t) \div 2 & \text{if } t < 0.5 \\ \mathtt{easeOut}(2 \times t + 1) \div 2 + 0.5 & \text{if } t \geq 0.5 \end{cases} \]
\[ \mathtt{easeOutIn}(t) = \begin{cases} \mathtt{easeOut}(2 \times t) \div 2 & \text{if } t < 0.5 \\ \mathtt{easeIn}(2 \times t + 1) \div 2 + 0.5 & \text{if } t \geq 0.5 \end{cases} \]
Here are the base functions:
\[ f(t) = t^2 \]
\[ f(t) = t^3 \]
\[ f(t) = t^4 \]
\[ f(t) = t^5 \]
\[ f(t) = 1 - \cos\left(t \times \frac{\pi}{2}\right)\]
\[ f(t) = \begin{cases} 0 & \text{if } t = 0 \\ 2^{10 \times (t - 1)} & \text{if } t > 0 \end{cases} \]
\[ f(t) = 1 - \sqrt{1 - t^2} \]
\[ f(t) = t^2 \times (2.70158 \times t - 1.70158) \]
\[ f(t) = \begin{cases} 1 - 7.5625 \times (1 - t)^2 & \text{if } 1 - t < 1 / 2.75 \\ 1 - (7.5625 \times (1 - t - 1.5 / 2.75)^2 + 0.75) & \text{if } 1 - t < 2 / 2.75 \\ 1 - (7.5625 \times (1 - t - 2.25 / 2.75)^2 + 0.9375) & \text{if } 1 - t < 2.5 / 2.75 \\ 1 - (7.5625 \times (1 - t - 2.625 / 2.75)^2 + 0.984375) & \text{otherwise} \end{cases} \]
\[ f(t) = -2^{10 \times (t - 1)} \times \sin\left(\left((t - 1) - \frac{0.3}{4}\right) \times \frac{2 \times \pi}{0.3}\right) \]
Here are the plots for all the defined easing functions:
Function | Ease-In | Ease-Out | Ease-In-Out | Ease-Out-In |
---|---|---|---|---|
quad | ![]() | ![]() | ![]() | ![]() |
cubic | ![]() | ![]() | ![]() | ![]() |
quart | ![]() | ![]() | ![]() | ![]() |
quint | ![]() | ![]() | ![]() | ![]() |
sine | ![]() | ![]() | ![]() | ![]() |
expo | ![]() | ![]() | ![]() | ![]() |
circ | ![]() | ![]() | ![]() | ![]() |
back | ![]() | ![]() | ![]() | ![]() |
bounce | ![]() | ![]() | ![]() | ![]() |
elastic | ![]() | ![]() | ![]() | ![]() |
|
delete |
Deleted constructor.
|
static |
Ease-In flavor of back easing.
|
static |
Ease-In-Out flavor of back easing.
|
static |
Ease-Out flavor of back easing.
|
static |
Ease-Out-In flavor of back easing.
|
static |
Ease-In flavor of bounce easing.
|
static |
Ease-Out-In flavor of bounce easing.
|
static |
Ease-Out flavor of bounce easing.
|
static |
Ease-In-Out flavor of bounce easing.
|
static |
Ease-In flavor of circ easing.
|
static |
Ease-In-Out flavor of circ easing.
|
static |
Ease-Out flavor of circ easing.
|
static |
Ease-Out-In flavor of circ easing.
|
static |
Ease-In flavor of cubic easing.
|
static |
Ease-In-Out flavor of cubic easing.
|
static |
Ease-Out flavor of cubic easing.
|
static |
Ease-Out-In flavor of cubic easing.
|
static |
Ease-In flavor of elastic easing.
|
static |
Ease-In-Out flavor of elastic easing.
|
static |
Ease-Out flavor of elastic easing.
|
static |
Ease-Out-In flavor of elastic easing.
|
static |
Ease-In flavor of expo easing.
|
static |
Ease-In-Out flavor of expo easing.
|
static |
Ease-Out flavor of expo easing.
|
static |
Ease-Out-In flavor of expo easing.
|
static |
Linear easing.
This is the default easing function
|
static |
Ease-In flavor of quad easing.
|
static |
Ease-In-Out flavor of quad easing.
|
static |
Ease-Out flavor of quad easing.
|
static |
Ease-Out-In flavor of quad easing.
|
static |
Ease-In flavor of quart easing.
|
static |
Ease-In-Out flavor of quart easing.
|
static |
Ease-Out flavor of quart easing.
|
static |
Ease-Out-In flavor of quart easing.
|
static |
Ease-In flavor of quint easing.
|
static |
Ease-In-Out flavor of quint easing.
|
static |
Ease-Out flavor of quint easing.
|
static |
Ease-Out-In flavor of quint easing.
|
static |
Ease-In flavor of sine easing.
|
static |
Ease-In-Out flavor of sine easing.
|
static |
Ease-Out flavor of sine easing.
|
static |
Ease-Out-In flavor of sine easing.
|
static |
Smooth easing.
|
static |
Smoother easing.