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.
Built-in easings
Section titled “Built-in easings”31 easing functions are included, matching anime.js naming conventions:
| Name | Description |
|---|---|
linear | Constant speed |
inQuad | Accelerating from zero velocity |
outQuad | Decelerating to zero velocity |
inOutQuad | Acceleration until halfway, then deceleration |
inCubic | Accelerating from zero velocity (cubic) |
outCubic | Decelerating to zero velocity (cubic) |
inOutCubic | Acceleration then deceleration (cubic) |
inQuart | Accelerating from zero velocity (quartic) |
outQuart | Decelerating to zero velocity (quartic) |
inOutQuart | Acceleration then deceleration (quartic) |
inQuint | Accelerating from zero velocity (quintic) |
outQuint | Decelerating to zero velocity (quintic) |
inOutQuint | Acceleration then deceleration (quintic) |
inSine | Accelerating from zero velocity (sine) |
outSine | Decelerating to zero velocity (sine) |
inOutSine | Acceleration then deceleration (sine) |
inExpo | Exponential acceleration |
outExpo | Exponential deceleration |
inOutExpo | Exponential acceleration then deceleration |
inCirc | Circular acceleration |
outCirc | Circular deceleration |
inOutCirc | Circular acceleration then deceleration |
inBack | Overshoots start, then accelerates |
outBack | Overshoots end, then decelerates |
inOutBack | Overshoots both ends |
inElastic | Elastic wobble at start |
outElastic | Elastic wobble at end |
inOutElastic | Elastic wobble at both ends |
inBounce | Bouncing at start |
outBounce | Bouncing at end |
inOutBounce | Bouncing at both ends |
Pass the easing name as a string in TweenOptions:
animate.tween(entity, Transform2D, { x: 100, duration: 500, ease: 'outElastic',});Custom easing
Section titled “Custom easing”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
numberparametertin the range[0, 1] - Return a
numberin the range[0, 1] - Be pure (no side effects)
Type definitions
Section titled “Type definitions”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.