#
namespace
#include <Magnum/Animation/Easing.h>

Easing Easing functions.

### Contents

- Equations
- References
- Reference

A collection of predefined easing / tweening functions for adding life to animation interpolation.

This library is built as part of Magnum by default. To use this library with CMake, find the `Magnum`

package and link to the `Magnum::Magnum`

target:

find_package(Magnum REQUIRED) # ... target_link_libraries(your-app PRIVATE Magnum::Magnum)

See Downloading and building, Usage with CMake and Keyframe-based animation for more information.

The easing function is meant to be used to modify the interpolation factor, such as:

Vector3 result = Math::lerp(a, b, Animation::Easing::quadraticInOut(t));

The Animation library also provides the ease() utility that combines the interpolator together with the easing function:

auto lerpQuadraticInOut = Animation::ease<Vector3, Math::lerp, Animation::Easing::quadraticInOut>(); Vector3 result = lerpQuadraticInOut(a, b, t);

## Equations

Every function documentation shows a plot of its behavior, together with a direction in which it extrapolates. Green color means the extrapolation goes in a reasonable monotonic direction outside of the range (also denoted by **E** in the above list), red color means the extrapolation is defined, but behaves in a probably unwanted or non-monotonic way (denoted by **E** in the above list). If neither is present, it means the function is not defined outside of the range and produces a NaN. You may want to ensure the factor stays in bounds, using either Math::

auto lerpCircularOutClamped = Animation::easeClamped< Vector3, Math::lerp, Animation::Easing::quadraticInOut>(); Vector3 result1 = Math::lerp(a, b, Math::clamp(0.0f, 1.0f, Animation::Easing::circularOut(t))); Vector3 result2 = lerpCircularOutClamped(a, b, t);

Out-function for a corresponding in-function is defined as the following, the equations in the docs usually just show the final derived form. Similarly goes for combined in-/out-function :

Easing functions defined by simple polynomials can have an *exact* (denoted by **B** in the above list) or approximate (denoted by **B** in the above list) cubic Math::

Matrix3 transformation; CubicBezier2D easing; CubicBezier2D transformed{ transformation.transformPoint(easing[0]), transformation.transformPoint(easing[1]), transformation.transformPoint(easing[2]), transformation.transformPoint(easing[3])};

## References

Functions follow the common naming from Robert Penner's Easing functions, http:/

## Functions

- auto linear(Float t) -> Float
- Linear.
- auto step(Float t) -> Float
- Step.
- auto smoothstep(Float t) -> Float
- Smoothstep.
- auto smootherstep(Float t) -> Float
- Smootherstep.
- auto quadraticIn(Float t) -> Float
- Quadratic in.
- auto quadraticOut(Float t) -> Float
- Quadratic out.
- auto quadraticInOut(Float t) -> Float
- Quadratic in and out.
- auto cubicIn(Float t) -> Float
- Cubic in.
- auto cubicOut(Float t) -> Float
- Cubic out.
- auto cubicInOut(Float t) -> Float
- Cubic in and out.
- auto quarticIn(Float t) -> Float
- Quartic in.
- auto quarticOut(Float t) -> Float
- Quartic out.
- auto quarticInOut(Float t) -> Float
- Quartic in and out.
- auto quinticIn(Float t) -> Float
- Quintic in.
- auto quinticOut(Float t) -> Float
- Quintic out.
- auto quinticInOut(Float t) -> Float
- Quintic in and out.
- auto sineIn(Float t) -> Float
- Sine in.
- auto sineOut(Float t) -> Float
- Sine out.
- auto sineInOut(Float t) -> Float
- Sine in and out.
- auto circularIn(Float t) -> Float
- Circular in.
- auto circularOut(Float t) -> Float
- Circular out.
- auto circularInOut(Float t) -> Float
- Circular in and out.
- auto exponentialIn(Float t) -> Float
- Exponential in.
- auto exponentialOut(Float t) -> Float
- Exponential out.
- auto exponentialInOut(Float t) -> Float
- Exponential in and out.
- auto elasticIn(Float t) -> Float
- Elastic in.
- auto elasticOut(Float t) -> Float
- Elastic out.
- auto elasticInOut(Float t) -> Float
- Elastic in and out.
- auto backIn(Float t) -> Float
- Back in.
- auto backOut(Float t) -> Float
- Back out.
- auto backInOut(Float t) -> Float
- Back in and out.
- auto bounceIn(Float t) -> Float
- Bounce in.
- auto bounceOut(Float t) -> Float
- Bounce out.
- auto bounceInOut(Float t) -> Float
- Bounce in and out.

## Function documentation

###
Float Magnum::Animation::Easing:: step(Float t)

Step.

Similar to Math::`step()`

function with `edge = 0.5f`

.

###
Float Magnum::Animation::Easing:: smoothstep(Float t)

Implementation matching the GLSL `smoothstep()`

function. Combine with Math::

Math::lerp(a, b, Animation::Easing::smoothstep(t));

*Exact* Bézier representation:

CubicBezier2D{Vector2{0.0f}, Vector2{1.0f/3.0f, 0.0f}, Vector2{2.0f/3.0f, 1.0f}, Vector2{1.0f}}

###
Float Magnum::Animation::Easing:: smootherstep(Float t)

Improved version of smoothstep() by Ken Perlin.

###
Float Magnum::Animation::Easing:: quadraticIn(Float t)

Quadratic in.

*Exact* Bézier representation:

CubicBezier2D{Vector2{0.0f}, Vector2{1.0f/3.0f, 0.0f}, Vector2{2.0f/3.0f, 1.0f/3.0f}, Vector2{1.0f}}

###
Float Magnum::Animation::Easing:: quadraticOut(Float t)

Quadratic out.

*Exact* Bézier representation:

CubicBezier2D{Vector2{0.0f}, Vector2{1.0f/3.0f, 2.0f/3.0f}, Vector2{2.0f/3.0f, 1.0f}, Vector2{1.0f}}

###
Float Magnum::Animation::Easing:: quadraticInOut(Float t)

Quadratic in and out.

Combination of quadraticIn() and quadraticOut().

Approximate Bézier representation:

CubicBezier2D{Vector2{0.0f}, Vector2{0.455f, 0.0f}, Vector2{0.545f, 1.0f}, Vector2{1.0f}}

###
Float Magnum::Animation::Easing:: cubicInOut(Float t)

Cubic in and out.

Combination of cubicIn() and cubicOut().

Approximate Bézier representation:

CubicBezier2D{Vector2{0.0f}, Vector2{0.645f, 0.0f}, Vector2{0.355f, 1.0f}, Vector2{1.0f}}

###
Float Magnum::Animation::Easing:: quarticOut(Float t)

Quartic out.

###
Float Magnum::Animation::Easing:: quarticInOut(Float t)

Quartic in and out.

Combination of quarticIn() and quarticOut().

###
Float Magnum::Animation::Easing:: quinticOut(Float t)

Quintic out.

###
Float Magnum::Animation::Easing:: quinticInOut(Float t)

Quintic in and out.

Combination of quinticIn() and quinticOut().

###
Float Magnum::Animation::Easing:: circularIn(Float t)

Circular in.

###
Float Magnum::Animation::Easing:: circularOut(Float t)

Circular out.

###
Float Magnum::Animation::Easing:: circularInOut(Float t)

Circular in and out.

Combination of circularIn() and circularOut().

###
Float Magnum::Animation::Easing:: exponentialIn(Float t)

Exponential in.

Contrary to Robert Penner's book but consistently with other implementations has a special case for , because otherwise.

###
Float Magnum::Animation::Easing:: exponentialOut(Float t)

Exponential out.

Contrary to Robert Penner's book but consistently with other implementations has a special case for , because otherwise.

###
Float Magnum::Animation::Easing:: exponentialInOut(Float t)

Exponential in and out.

Combination of exponentialIn() and exponentialOut(). Contrary to Robert Penner's book but consistently with other implementations has a special case for , because otherwise.

###
Float Magnum::Animation::Easing:: elasticIn(Float t)

Elastic in.

Combines sineIn() and exponentialIn().

###
Float Magnum::Animation::Easing:: elasticOut(Float t)

Elastic out.

Combines sineOut() and exponentialOut().

###
Float Magnum::Animation::Easing:: elasticInOut(Float t)

Elastic in and out.

Combination of elasticIn() and elasticOut() (or sineInOut() and exponentialInOut()).

###
Float Magnum::Animation::Easing:: bounceInOut(Float t)

Bounce in and out.

Combination of bounceIn() and bounceOut().