All animation and tweening utilities are imported fromDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sanchedev/fraxel/llms.txt
Use this file to discover all available pages before exploring further.
fraxel/animation. The module covers numeric property tweening, composable tween sequences, sprite-sheet keyframe generation, and a full library of easing functions. For a conceptual overview and practical recipes, see the Animation guide.
tween(options)
Creates a tween that interpolates a numeric property on a target object over time. Returns aTweenController you can use to pause, resume, or stop the animation.
Options
The object whose property will be interpolated. Any object with numeric properties works — nodes, plain objects, etc.
The name of the property to animate. Must be a key that holds a
number value on target.The start value of the interpolation.
The end value of the interpolation.
Total duration of the tween in seconds.
An easing function
(t: number) => number that maps normalised time t (0–1) to an eased output. Defaults to linear. See the easing functions table below.Called every frame with the current interpolated value. Useful for side-effects that don’t directly map to a property.
Called once when the tween finishes (progress reaches 1).
TweenController
tween() returns a TweenController with the following interface:
Usage with hooks
tweenValue(options)
Identical totween() but without a target object or property name. The interpolated value is delivered exclusively via onUpdate. Returns a TweenController.
Start value.
End value.
Duration in seconds.
Easing function applied to the normalised time. See easing functions.
Receives the current interpolated value every frame.
Called when the tween finishes.
sequence(tweens)
Runs an array ofTweenController instances one after another — each tween starts only after the previous one finishes. Returns void (no controller is returned for the sequence itself).
An ordered array of tween controllers. The first tween plays immediately; subsequent tweens are paused and resume once the prior tween completes.
Pass pre-constructed
TweenController objects — tween() starts playing immediately, so sequence() internally pauses every tween except the first and resumes each one in turn.parallel(tweens)
Runs an array ofTweenController instances simultaneously — all tweens start at the same time. Returns void.
Array of tween controllers to run simultaneously. Each is immediately resumed.
animationFromSheet(sprite, textureId, options)
Creates a completeAnimation object from a sprite sheet. Combines keyframesFromSheet() with automatic FPS calculation — fps = (columns × rows) / duration. The returned object is ready to pass to an <animation-player> node.
The sprite instance or a
NodeReference created with useNode(). When a NodeReference is passed, the animation is built lazily when the animations factory is evaluated.Texture symbol returned by
loadTexture(). Pass null to keep the sprite’s current texture across all frames. Pass undefined to use the sprite’s current texture for UV calculations.Number of columns in the sprite sheet grid.
Number of rows in the sprite sheet grid.
Optional
[from, to] tuple (0-indexed, inclusive) to select a subset of frames from the full grid. For example, [0, 3] selects the first four frames.Total animation duration in seconds. FPS is derived as
(columns × rows) / duration.Whether the animation should loop after the last frame.
Animation — { keyframes: AnimationKeyframe[], fps: number, loop?: boolean }.
keyframesFromSheet(sprite, textureId, columns, rows, range?)
Generates a raw keyframe array from a sprite sheet. Use this when you need fine-grained control over FPS or want to compose keyframes manually.animationFromSheet() calls this internally.
The
Sprite instance to animate. Source texture dimensions are read directly from the sprite.Texture symbol used to read image dimensions and set
textureId on frame zero. Pass null to leave the texture unchanged.Number of columns in the sprite sheet grid.
Number of rows in the sprite sheet grid.
Optional
[from, to] tuple (0-indexed, inclusive) selecting a frame range. Defaults to the full sheet [0, columns × rows − 1].AnimationKeyframe[] — array of frame callbacks ready for an Animation definition.
kfFromProp(node, property, value)
Creates a single keyframe that sets a property on a node to a given value when the frame is reached.Any Fraxel node instance.
The property name to set on the node.
The value to assign to the property when this keyframe fires.
AnimationKeyframe — a callback (time: number) => void that sets node[property] = value.
multiKF(keyframes)
Combines multiple keyframes into a single keyframe that executes all of them in the same frame. Useful for changing both the texture and UV offset simultaneously on frame zero.Array of keyframes to merge. All will be called with the same
time argument when the combined keyframe fires.AnimationKeyframe — a single callback that invokes every provided keyframe.
Easing Functions
All easing functions implementEasingFn = (t: number) => number, mapping normalised time t (0–1) to an eased output value.
| Function | Signature | Description |
|---|---|---|
linear | (t: number) => number | No easing — constant speed |
easeInQuad | (t: number) => number | Slow start, accelerates (quadratic) |
easeOutQuad | (t: number) => number | Fast start, decelerates (quadratic) |
easeInOutQuad | (t: number) => number | Slow start and slow end (quadratic) |
easeInCubic | (t: number) => number | Cubic acceleration from zero |
easeOutCubic | (t: number) => number | Cubic deceleration to zero |
easeInOutCubic | (t: number) => number | Cubic slow start and slow end |
easeBackOut | (t: number) => number | Overshoots target then settles back |
easeBackInOut | (t: number) => number | Overshoots in both directions |
easeOutBounce | (t: number) => number | Bounces at the end like a dropped ball |
easeInBounce | (t: number) => number | Bounces at the start |
easeOutElastic | (t: number) => number | Spring-like elastic overshoot at the end |
(t: number) => number as a custom easing. The input t is always clamped to [0, 1] by the tween engine before it is passed to the easing function.
Related guides
- Animation guide — AnimationPlayer, reactive
currentAnim, and sprite sheet workflow - Nodes 2D API —
<animation-player>node props reference - Math API —
Vector2used inkfFromPropmargin values