Motion
Spring and tween animations (spring, tween) stepped once per frame, plus perceptual Color utilities.
local width = Flux.spring(function() return if open() then 300 else 0 end)Types
Spring type
type Spring<T> = Graph.Node<T> & {
-- Adds `delta` to the spring's current velocity without changing its target.
impulse: (self: any, delta: T) -> (),
-- Replaces the spring's velocity outright without changing its target.
setVelocity: (self: any, velocity: T) -> (),
-- Sets the spring's current animated value immediately without altering its target or velocity.
setCurrent: (self: any, value: T) -> (),
-- Jumps both the target and current value to `value` and zeroes the velocity.
snap: (self: any, value: T) -> (),
}Functions
step
Motion.step(dt: number?)Advances every active spring and tween by dt seconds (or the time since the last step). Wired to RunService automatically in Roblox, so you only call this in tests (Flux.Motion.step(1 / 60)).
spring
Motion.spring<A>(target: A, frequency: Reactive<number>?, damping: Reactive<number>?, initialVelocity: any?): Spring<Unwrap<A>>Creates a node that animates toward target using an analytic harmonic oscillator (frequency in Hz and damping ratio both default to 1 and may be reactive). Retargets preserve current velocity.
local size = Flux.spring(function() return if open() then 300 else 0 end, 4)tween
Motion.tween<A>(target: A, tweenInfo: Reactive<TweenInfo>?): Graph.Node<Unwrap<A>>Creates a node that eases toward target over a TweenInfo curve. When target or tweenInfo changes, the tween restarts from its current value without waiting for DelayTime.
Oklab
fromLinear
Converts a Color3 in linear sRGB space to a Vector3 in Oklab space.
toLinear
Converts a Vector3 in Oklab space to a Color3 in linear sRGB space.
fromRGB
Converts a Color3 in sRGB space to a Vector3 in Oklab space.
toRGB
Converts a Vector3 in Oklab space to a Color3 in sRGB space.
lighten
Raises Oklab lightness by amount (negative darkens).
saturate
Raises Oklab chroma by amount, preserving hue and lightness (negative desaturates).
rotateHue
Rotates hue by degrees, preserving chroma and lightness.
grayscale
Removes all chroma, preserving Oklab lightness.
mix
Linearly interpolates between lab1 and lab2 in Oklab space by alpha.
sRGB
fromLinear
Converts linear sRGB space to sRGB space.
toLinear
Converts sRGB space to linear sRGB space.
Color
lighten
Raises the perceptual lightness of c in Oklab space by amount (negative darkens).
saturate
Raises the chroma of c in Oklab space by amount while preserving hue and lightness (negative desaturates).
rotateHue
Rotates the hue of c by degrees around the Oklab color wheel while preserving chroma and lightness.
grayscale
Strips all chroma from c, returning a neutral gray with the same Oklab perceptual lightness.
mix
Blends a and b in Oklab space by unclamped fraction t (0 = a, 1 = b).
luminance
Motion.Color.luminance(c: Color3): numberReturns the WCAG relative luminance of c from 0 (black) to 1 (white).
contrast
Returns the WCAG contrast ratio between a and b from 1 (identical) to 21 (black on white).
readable
Returns whichever of dark (default black) or light (default white) has the higher WCAG contrast ratio against bg.
Spring
Constructors: Motion.spring · Motion.tween
set
Spring:set<T>(value: T)Retargets the animation toward value from its current position (motion(value) does the same). If value is a node, it's read once.
impulse
Spring:impulse<T>(delta: T)(Spring only) Adds delta to the spring's current velocity without changing its goal.
setVelocity
Spring:setVelocity<T>(velocity: T)(Spring only) Replaces the spring's current velocity with velocity without changing its goal.
setCurrent
Spring:setCurrent<T>(value: T)(Spring only) Sets the spring's current animated value immediately without changing its target or velocity.
snap
Spring:snap<T>(value: T)(Spring only) Jumps both the target and current value of the spring to value and zeroes its velocity.