Modules · Interface · Animate

Animate

Drive a value smoothly over time. Animate turns a start and a target into a reactive value that moves between them over a duration in milliseconds, shaping the motion with the same easeIn/easeOut controls as Maths.Real.Ease. The core driver Animate.Real yields a Maths.Real progress that the other drivers build on to tween integers, colours and booleans, and there are timed helpers that flip a value's lock or error state after a delay.

Contents

Functions

Functions

Animate.After

Holds a start value, then switches to an end value once a delay elapses.

Generics

NameDescription
ValueTypeThe type of the two values and of the result.

Parameters

NameTypeDescription
durationMsMaths.RealThe delay before switching, in milliseconds.
startValueValueTypeThe value held until the delay elapses.
endValueValueTypeThe value taken once the delay elapses.

Returns

Returns ValueTypestartValue until durationMs has passed, then endValue.

Example

LET Text label = Animate.After 500.0 "Loading" "Ready"
Shows “Loading” for half a second, then “Ready”.

Animate.Bool

Switches from a start to a target boolean at the halfway point of a duration.

Parameters

NameTypeDescription
startValueLogic.MaybeThe value before the switch.
targetValueLogic.MaybeThe value after the switch.
durationMsMaths.RealHow long the animation runs, in milliseconds.
easeInMaths.RealStrength of the ease at the start.
easeOutMaths.RealStrength of the ease at the end.

Returns

Returns Logic.MaybestartValue until the eased progress passes one half, then targetValue.

Animate.Counter

Advances an integer state by one on a fixed interval.

Parameters

NameTypeDescription
counterMaths.IntegerThe integer state to advance on each tick.
intervalMsMaths.IntegerThe time between ticks, in milliseconds.

Returns

Returns nothing — it increments counter once every intervalMs milliseconds.

Example

STATE Maths.Integer tick = 0
Animate.Counter tick 1000
Advances tick once per second.

Animate.ErrorAfter

Puts a value into an error state once a delay elapses.

Generics

NameDescription
ValueTypeThe type of the value being guarded.

Parameters

NameTypeDescription
valueValueTypeThe value to hold until the delay elapses.
errorMessageTextThe message raised once the delay elapses.
durationMsMaths.RealThe delay before erroring, in milliseconds.

Returns

Returns ValueType — the value until durationMs has passed, then an error carrying errorMessage.

Animate.ErrorAfterWithRetry

Errors a value after a delay, offering a retry that restarts the timer.

Generics

NameDescription
ValueTypeThe type of the value being guarded.

Parameters

NameTypeDescription
valueValueTypeThe value to hold until the delay elapses.
errorMessageTextThe message raised once the delay elapses.
durationMsMaths.RealThe delay before erroring, in milliseconds.

Returns

Returns ValueType — the value until durationMs has passed, then an error carrying errorMessage with a retry that restarts the delay.

Animate.Integer

Drives a whole number from a start to a target over a duration, with easing.

Parameters

NameTypeDescription
startValueMaths.IntegerThe value at the start of the animation.
targetValueMaths.IntegerThe value to reach at the end.
durationMsMaths.RealHow long the animation runs, in milliseconds.
easeInMaths.RealStrength of the ease at the start.
easeOutMaths.RealStrength of the ease at the end.

Returns

Returns Maths.Integer — the eased progress interpolated between startValue and targetValue and rounded to a whole number.

Example

LET Maths.Integer step = Animate.Integer 0 10 1000.0 0.0 0.0
Counts from 0 to 10 over one second.

Animate.LockAfter

Locks a value once a delay elapses.

Generics

NameDescription
ValueTypeThe type of the value being locked.

Parameters

NameTypeDescription
valueValueTypeThe value to keep unlocked until the delay elapses.
durationMsMaths.RealThe delay before locking, in milliseconds.

Returns

Returns ValueType — the same value, unlocked until durationMs has passed and locked thereafter.

Animate.RGBA

Blends a colour from a start to a target over a duration, with easing.

Parameters

NameTypeDescription
startColorColour.RGBAThe colour at the start of the animation.
targetColorColour.RGBAThe colour to reach at the end.
durationMsMaths.RealHow long the animation runs, in milliseconds.
easeInMaths.RealStrength of the ease at the start.
easeOutMaths.RealStrength of the ease at the end.

Returns

Returns Colour.RGBA — the colour eased from startColor to targetColor over durationMs.

Example

LET Colour.RGBA fade = Animate.RGBA start finish 300.0 1.0 1.0
Cross-fades between two colours over 300 ms.

Animate.Real

Drives a real number from a start to a target over a duration, with easing.

Parameters

NameTypeDescription
startValueMaths.RealThe value at the start of the animation.
targetValueMaths.RealThe value to reach at the end.
durationMsMaths.RealHow long the animation runs, in milliseconds.
easeInMaths.RealStrength of the ease at the start.
easeOutMaths.RealStrength of the ease at the end.

Returns

Returns Maths.Real — a reactive value that eases from startValue to targetValue over durationMs.

Example

LET Maths.Real slide = Animate.Real 0.0 100.0 500.0 1.0 1.0
Eases a value from 0 to 100 over 500 ms.

Animate.UnlockAfter

Unlocks a value once a delay elapses.

Generics

NameDescription
ValueTypeThe type of the value being unlocked.

Parameters

NameTypeDescription
valueValueTypeThe value to keep locked until the delay elapses.
durationMsMaths.RealThe delay before unlocking, in milliseconds.

Returns

Returns ValueType — the same value, locked until durationMs has passed and unlocked thereafter.