Skip to content

Easing

Easing functions control how values interpolate between the start and end of a tween. All built-in easings are pure functions mapping [0, 1] → [0, 1]. They are stored in an indexed table (EasingTable) for fast lookup during batch iteration — the Tween component stores the easing as an Int32 index, not a string.

31 easing functions are included, matching anime.js naming conventions:

NameDescription
linearConstant speed
inQuadAccelerating from zero velocity
outQuadDecelerating to zero velocity
inOutQuadAcceleration until halfway, then deceleration
inCubicAccelerating from zero velocity (cubic)
outCubicDecelerating to zero velocity (cubic)
inOutCubicAcceleration then deceleration (cubic)
inQuartAccelerating from zero velocity (quartic)
outQuartDecelerating to zero velocity (quartic)
inOutQuartAcceleration then deceleration (quartic)
inQuintAccelerating from zero velocity (quintic)
outQuintDecelerating to zero velocity (quintic)
inOutQuintAcceleration then deceleration (quintic)
inSineAccelerating from zero velocity (sine)
outSineDecelerating to zero velocity (sine)
inOutSineAcceleration then deceleration (sine)
inExpoExponential acceleration
outExpoExponential deceleration
inOutExpoExponential acceleration then deceleration
inCircCircular acceleration
outCircCircular deceleration
inOutCircCircular acceleration then deceleration
inBackOvershoots start, then accelerates
outBackOvershoots end, then decelerates
inOutBackOvershoots both ends
inElasticElastic wobble at start
outElasticElastic wobble at end
inOutElasticElastic wobble at both ends
inBounceBouncing at start
outBounceBouncing at end
inOutBounceBouncing at both ends

Pass the easing name as a string in TweenOptions:

animate.tween(entity, Transform2D, {
x: 100,
duration: 500,
ease: 'outElastic',
});

Register custom easing functions at runtime:

const index = animate.registerEasing('myEase', (t) => t * t);
animate.tween(entity, Transform2D, {
x: 100,
ease: 'myEase',
});

Custom easing functions must:

  • Accept a single number parameter t in the range [0, 1]
  • Return a number in the range [0, 1]
  • Be pure (no side effects)
export type EasingFn = (t: number) => number;
export type EasingName = keyof typeof EasingIndex;
export const EasingTable: EasingFn[];
export const EasingIndex: Record<string, number>;

EasingIndex maps easing names to their numeric indices in EasingTable. Runtime-registered easings are appended to EasingTable and tracked internally by the Animate resource.