diff options
Diffstat (limited to 'scene/animation/easing_equations.h')
-rw-r--r-- | scene/animation/easing_equations.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scene/animation/easing_equations.h b/scene/animation/easing_equations.h index 1b9c378b4f..9150191744 100644 --- a/scene/animation/easing_equations.h +++ b/scene/animation/easing_equations.h @@ -413,4 +413,33 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) { } }; // namespace back +namespace spring { +static real_t out(real_t t, real_t b, real_t c, real_t d) { + t /= d; + real_t s = 1.0 - t; + t = (sin(t * Math_PI * (0.2 + 2.5 * t * t * t)) * pow(s, 2.2) + t) * (1.0 + (1.2 * s)); + return c * t + b; +} + +static real_t in(real_t t, real_t b, real_t c, real_t d) { + return c - out(d - t, 0, c, d) + b; +} + +static real_t in_out(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return in(t * 2, b, c / 2, d); + } + real_t h = c / 2; + return out(t * 2 - d, b + h, h, d); +} + +static real_t out_in(real_t t, real_t b, real_t c, real_t d) { + if (t < d / 2) { + return out(t * 2, b, c / 2, d); + } + real_t h = c / 2; + return in(t * 2 - d, b + h, h, d); +} +}; // namespace spring + #endif // EASING_EQUATIONS_H |