Motion.tween
luastra/motionMotion.tween(options: TweenOptions): Tween
Creates one deterministic numeric transition from a starting value to an ending value over a bounded duration and easing curve. A Tween becomes meaningful only when assigned to a supported motion channel or placed in a Sequence.
Before you use it
Add luastra/motion to this module's dependencies in luastra.json, then import it with require("luastra/motion"). Motion itself needs no capability; a visible result requires ui.render and a component that accepts the returned descriptor through its motion field.
How it fits
The function returns immutable motion data synchronously. Assign a preset MotionMap directly, or place Tween/Sequence values under supported motion channel names; the host animates without rerunning app.render on every frame.
When to use it
Use Motion.tween when you need direct control of one opacity, translation, scale, or rotation channel. Prefer a named preset when it already expresses the intended interaction and respect reduced-motion behavior supplied by the host.
Parameters
| Parameter | Type / values | Description |
|---|---|---|
| options | TweenOptions | Start, end, duration, and optional easing for one numeric motion channel. |
| options.from | number | Required finite value at the beginning of the transition. |
| options.to | number | Required finite value at the end of the transition. |
| options.durationMs | number (0..60000) | Required transition duration in milliseconds. |
| options.easing | "linear" | "easeOutCubic" | "easeInOutCubic"? | Optional interpolation curve; defaults to "linear". |
Returns
Tween — an immutable descriptor for one bounded numeric transition.
What happens next
A descriptor or MotionMap ready to attach to a supported UI node.
Failures and fixes
Unknown options, invalid bounds, or unsupported channels fail validation. Motion must not drive application logic; use Timer for state changes, and rely on the host to present the final state when reduced motion is enabled.
Availability
Public-source alpha API in 0.5.0-alpha; presentation follows host and reduced-motion policy.
Focused example
local Motion = require("luastra/motion")
local grow = Motion.tween { from = 1, to = 1.08, durationMs = 300, easing = "easeOutCubic" }Continue with a complete recipe
This checked recipe uses Motion.tween inside complete authored files with the required manifest, test, and run steps.
Open replay declarative motion recipe