Skip to Content

Animation

An animated prop declares a read-only property that approaches a target value over time: the source expression gives the target, the easing function and the duration give the path. The value you read is the intermediate value interpolated at the current moment — when the source changes, the value does not jump right over; it converges across the duration.

Three Forms

animated prop Name: T => sourceExpr ease easeExpr over durExpr; animated prop Name: T => sourceExpr over durExpr; // no ease, defaults to Linear animated prop Name: T => sourceExpr ease easeExpr over durExpr delay delayExpr;
class Fader { public animated prop Opacity: float => 0.0 ease QuadOut over 2.0s; public animated prop Fade: float => 1.0 over 1.0s delay 0.5s; }
  • ease picks the easing curve: it takes an Easing enum variant; the bare variant name QuadOut equals the qualified name Easing.QuadOut.
  • over sets the duration: it takes a constant Duration expression — a Duration literal (2.0s, 500ms), arithmetic (2s + 500ms), or a Duration.From* factory.
  • delay is optional and postpones the start of the animation (also a constant Duration expression).

Rules

  • Read-only: animated has no storage slot and cannot be written, same as computed.
  • Interpolation: numeric and geometric core types (int/float, vec2/3/4, vec2i/3i/4i, color) work out of the box. A custom struct interpolates frame by frame too once it implements the Lerpable protocol. Types with neither do not error: the value holds at the old one during the transition and hard-switches when the duration ends.
  • Full participation in the reactive system: animated can depend on computed, drive bind, and enter event prop pipelines; a change in the source expression is a new animation target.
Note

An animation is a function of time; what you read is always the interpolation at the current moment.

The tween Statement

tween is statement-level imperative animation: it transitions a writable event prop to a target value over a given duration. The full family of forms:

tween target to endExpr over durExpr; // to + over tween target to endExpr over durExpr ease easeExpr; // + ease (defaults to Linear) tween target to endExpr over durExpr delay delayExpr; // + delay tween target to endExpr over durExpr cancel ct; // + cancel (takes a cancellation token) tween target from startExpr to endExpr over durExpr; // from: explicit start tween target by offsetExpr over durExpr; // by: relative offset
  • The target must be a member access on a writable event prop (a bare name counts as the implicit self.X).
  • Produces a task: inside an async func, await tween ... blocks until completion.
  • Same target supersedes: on the same “node + property” key, a new tween cancels the old one; cancel ct shares that semantics — the property stops at the current frame and the task completes normally.
  • ease takes an Easing enum value or a custom function.

Notes

  • The source expression gives the target value: the animation transitions from the current value toward it, and when the target changes the animation steers smoothly toward the new one.
  • Common easings: Linear, QuadIn, QuadOut, QuadInOut, CubicIn, CubicOut, CubicInOut — the seven variants of the Easing enum, declared in the std::Animation module.
  • A duration of 0 degenerates into a plain assignment.
Last updated on October 11, 2026