59 lines
1.7 KiB
Markdown
59 lines
1.7 KiB
Markdown
# tween
|
|
|
|
### Tween <sub>object</sub>
|
|
|
|
|
|
An object providing methods to create and control tweens with additional features
|
|
like looping, custom easing, multiple stages, etc.
|
|
|
|
Properties:
|
|
- default: A template object with loop/time/ease/whole/cb properties.
|
|
Methods:
|
|
- start(obj, target, tvals, options): Create a tween over multiple target values.
|
|
- make: Alias of start.
|
|
|
|
|
|
### Ease <sub>object</sub>
|
|
|
|
|
|
This object provides multiple easing functions that remap a 0..1 input to produce
|
|
a smoothed or non-linear output. They can be used standalone or inside tweens.
|
|
|
|
Available functions:
|
|
- linear(t)
|
|
- in(t), out(t), inout(t)
|
|
- quad.in, quad.out, quad.inout
|
|
- cubic.in, cubic.out, cubic.inout
|
|
- quart.in, quart.out, quart.inout
|
|
- quint.in, quint.out, quint.inout
|
|
- expo.in, expo.out, expo.inout
|
|
- bounce.in, bounce.out, bounce.inout
|
|
- sine.in, sine.out, sine.inout
|
|
- elastic.in, elastic.out, elastic.inout
|
|
|
|
All easing functions expect t in [0..1] and return a remapped value in [0..1].
|
|
|
|
|
|
### tween(from, to, time, fn, cb) <sub>function</sub>
|
|
|
|
|
|
|
|
Creates a simple tween that linearly interpolates from "from" to "to" over "time"
|
|
and calls "fn" with each interpolated value. Once finished, "fn" is called with "to",
|
|
then "cb" is invoked if provided, and the tween is cleaned up.
|
|
|
|
|
|
**from**: The starting object or value to interpolate from.
|
|
|
|
**to**: The ending object or value to interpolate to.
|
|
|
|
**time**: The total duration of the tween in milliseconds or some time unit.
|
|
|
|
**fn**: A callback function that receives the interpolated value at each update.
|
|
|
|
**cb**: (Optional) A callback invoked once the tween completes.
|
|
|
|
|
|
**Returns**: A function that, when called, cleans up and stops the tween.
|
|
|