Table of Contents

Class Easing

Namespace
Stride.CommunityToolkit.Mathematics
Assembly
Stride.CommunityToolkit.dll

Easing curves: functions from a normalised time in [0, 1] to a progress in [0, 1] that start at 0, end at 1, and shape the motion in between.

public static class Easing
Inheritance
Easing

Remarks

Every curve is one generic method over any IEEE floating-point type, so Easing.CubicEaseOut(0.3f) and Easing.CubicEaseOut(0.3) both work and share one implementation; the JIT specialises the arithmetic per type, so the float path costs what a hand-written one would. The curve methods are the raw formulas and do not clamp their input: a time past 1 keeps following the polynomial. Ease<T>(T, EasingFunction), which picks a curve by EasingFunction, clamps the time first, because that is what an animation wants when its clock runs past the end.

The polynomial, sine, circular, exponential, elastic, back and bounce families are the classic set from Robert Penner's easing functions, modeled after the equations noted on each method. SmoothStep<T>(T) and SmootherStep<T>(T) are the two Hermite blends graphics code reaches for. To interpolate between two values with a curve, see Interpolate(float, float, float, EasingFunction) and its vector and colour overloads, or the fluent EasingFunctionExtensions.

Methods

BackEaseInOut<T>(T)

Back ease-in-out: pulls back at the start and overshoots at the end.

public static T BackEaseInOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress, leaving [0, 1] near both ends.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the piecewise overshooting cubic y = (1/2)((2x)³ - (2x) sin(2xπ)) on [0, 0.5] and y = (1/2)(1 - ((1 - x)³ - (1 - x) sin((1 - x)π))) + 1/2 on [0.5, 1], with x rescaled to the half.

BackEaseIn<T>(T)

Back ease-in: pulls back below 0 before setting off.

public static T BackEaseIn<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress, dipping below 0 early on.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the overshooting cubic y = x³ - x sin(xπ).

BackEaseOut<T>(T)

Back ease-out: overshoots past 1 and settles back onto it.

public static T BackEaseOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress, rising above 1 late on.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the overshooting cubic y = 1 - ((1 - x)³ - (1 - x) sin((1 - x)π)).

BounceEaseInOut<T>(T)

Bounce ease-in-out: bounces off the start and lands with bounces.

public static T BounceEaseInOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

BounceEaseIn<T>(T) squeezed into the first half and BounceEaseOut<T>(T) into the second.

BounceEaseIn<T>(T)

Bounce ease-in: bounces off the start, a dropped ball played in reverse.

public static T BounceEaseIn<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

The mirror of BounceEaseOut<T>(T): y = 1 - BounceEaseOut(1 - x).

BounceEaseOut<T>(T)

Bounce ease-out: lands with diminishing bounces, as a dropped ball.

public static T BounceEaseOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after four parabolic arcs of shrinking height, with the breaks at 4/11, 8/11 and 9/10 of the time; the classic coefficients from Penner's bounce.

CircularEaseInOut<T>(T)

Circular ease-in-out: two quarter circles meeting in the middle.

public static T CircularEaseInOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the piecewise circular function y = (1/2)(1 - √(1 - 4x²)) on [0, 0.5] and y = (1/2)(√(-(2x - 3)(2x - 1)) + 1) on [0.5, 1].

CircularEaseIn<T>(T)

Circular ease-in: barely moves, then rushes the end.

public static T CircularEaseIn<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the shifted fourth quadrant of the unit circle, y = 1 - √(1 - x²).

CircularEaseOut<T>(T)

Circular ease-out: rushes the start, then barely moves.

public static T CircularEaseOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the shifted second quadrant of the unit circle, y = √((2 - x)x).

CubicEaseInOut<T>(T)

Cubic ease-in-out: slow, fast, slow.

public static T CubicEaseInOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the piecewise cubic y = (1/2)((2x)³) on [0, 0.5] and y = (1/2)((2x - 2)³ + 2) on [0.5, 1].

CubicEaseIn<T>(T)

Cubic ease-in: starts slowly and accelerates harder than the quadratic.

public static T CubicEaseIn<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the cubic y = x³.

CubicEaseOut<T>(T)

Cubic ease-out: starts fast and decelerates harder than the quadratic.

public static T CubicEaseOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the cubic y = (x - 1)³ + 1.

Ease<T>(T, EasingFunction)

Evaluates the curve named by function at a normalised time, clamped to [0, 1].

public static T Ease<T>(T amount, EasingFunction function) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time. Values below 0 read as 0 and values above 1 as 1, so a clock that runs past the end holds at the end.

function EasingFunction

The curve to evaluate.

Returns

T

The eased progress: 0 at time 0, 1 at time 1, and for the elastic and back families briefly outside [0, 1] between.

Type Parameters

T

A floating-point type: float, double or Half.

Remarks

This is the entry point for an animation configured by name. Call a curve method directly, such as ElasticEaseOut<T>(T), when the curve is fixed and the input is known to be in range, or when the formula's behaviour outside [0, 1] is wanted.

ElasticEaseInOut<T>(T)

Elastic ease-in-out: wobbles out of the start and into the end.

public static T ElasticEaseInOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress, leaving [0, 1] near both ends.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the piecewise exponentially damped sine wave y = (1/2) sin(13π(2x)/2) 2^(10(2x - 1)) on [0, 0.5] and y = (1/2)(sin(-13π((2x - 1) + 1)/2) 2^(-10(2x - 1)) + 2) on [0.5, 1].

ElasticEaseIn<T>(T)

Elastic ease-in: winds up with growing wobbles, then snaps to the end.

public static T ElasticEaseIn<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress, dipping below 0 on the way.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the damped sine wave y = sin(13πx/2) 2^(10(x - 1)).

ElasticEaseOut<T>(T)

Elastic ease-out: snaps past the end and wobbles back onto it.

public static T ElasticEaseOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress, rising above 1 on the way.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the damped sine wave y = sin(-13π(x + 1)/2) 2^(-10x) + 1.

ExponentialEaseInOut<T>(T)

Exponential ease-in-out: still, explosive through the middle, still.

public static T ExponentialEaseInOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the piecewise exponential y = (1/2)2^(10(2x - 1)) on [0, 0.5] and y = -(1/2)2^(-10(2x - 1)) + 1 on [0.5, 1], pinned to the exact ends.

ExponentialEaseIn<T>(T)

Exponential ease-in: almost still, then explosive.

public static T ExponentialEaseIn<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after y = 2^(10(x - 1)), pinned to exactly 0 at time 0, where the formula alone would give 1/1024.

ExponentialEaseOut<T>(T)

Exponential ease-out: explosive, then almost still.

public static T ExponentialEaseOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after y = 1 - 2^(-10x), pinned to exactly 1 at time 1.

Linear<T>(T)

No easing: the progress is the time.

public static T Linear<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The same value.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the line y = x.

QuadraticEaseInOut<T>(T)

Quadratic ease-in-out: slow, fast, slow.

public static T QuadraticEaseInOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the piecewise quadratic y = (1/2)((2x)²) on [0, 0.5] and y = -(1/2)((2x - 1)(2x - 3) - 1) on [0.5, 1].

QuadraticEaseIn<T>(T)

Quadratic ease-in: starts slowly and accelerates.

public static T QuadraticEaseIn<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the parabola y = x².

QuadraticEaseOut<T>(T)

Quadratic ease-out: starts fast and decelerates.

public static T QuadraticEaseOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the parabola y = -x² + 2x.

QuarticEaseInOut<T>(T)

Quartic ease-in-out: slow, fast, slow.

public static T QuarticEaseInOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the piecewise quartic y = (1/2)((2x)⁴) on [0, 0.5] and y = -(1/2)((2x - 2)⁴ - 2) on [0.5, 1].

QuarticEaseIn<T>(T)

Quartic ease-in: starts very slowly and accelerates.

public static T QuarticEaseIn<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the quartic y = x⁴.

QuarticEaseOut<T>(T)

Quartic ease-out: starts fast and decelerates into a long tail.

public static T QuarticEaseOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the quartic y = 1 - (x - 1)⁴.

QuinticEaseInOut<T>(T)

Quintic ease-in-out: slow, fast, slow.

public static T QuinticEaseInOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the piecewise quintic y = (1/2)((2x)⁵) on [0, 0.5] and y = (1/2)((2x - 2)⁵ + 2) on [0.5, 1].

QuinticEaseIn<T>(T)

Quintic ease-in: the slowest start of the polynomial family.

public static T QuinticEaseIn<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the quintic y = x⁵.

QuinticEaseOut<T>(T)

Quintic ease-out: the longest tail of the polynomial family.

public static T QuinticEaseOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after the quintic y = (x - 1)⁵ + 1.

SineEaseInOut<T>(T)

Sine ease-in-out: soft at both ends.

public static T SineEaseInOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after half a sine wave, y = (1 - cos(xπ)) / 2.

SineEaseIn<T>(T)

Sine ease-in: the softest possible start.

public static T SineEaseIn<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after a quarter cycle of a sine wave, y = sin((x - 1)π/2) + 1.

SineEaseOut<T>(T)

Sine ease-out: the softest possible finish.

public static T SineEaseOut<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after a quarter cycle of a sine wave in a different phase, y = sin(xπ/2).

SmoothStep<T>(T)

The Hermite blend: gentle at both ends, straight through the middle.

public static T SmoothStep<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after y = x²(3 - 2x), the cubic whose slope is 0 at both ends; what shader languages call smoothstep.

SmootherStep<T>(T)

Ken Perlin's smoother blend: flat at both ends, with no curvature there either.

public static T SmootherStep<T>(T amount) where T : IFloatingPointIeee754<T>

Parameters

amount T

The normalised time.

Returns

T

The eased progress.

Type Parameters

T

A floating-point type.

Remarks

Modeled after y = x³(x(6x - 15) + 10), the quintic whose first and second derivatives are 0 at both ends.