AnimatedValue struct
#include <Jazz2/UI/Menu/Tweening.h>
Self-advancing animated scalar.
Lightweight 0–1 (or arbitrary range) value that eases toward a target at a fixed per-frame speed. Replaces the dozens of hand-rolled if (_a < 1.0f) _a += timeMult * k; and _a -= timeMult * k; counters previously duplicated across menu sections. Convert to the eased value implicitly, or read Raw for the linear value.
Constructors, destructors, conversion operators
-
AnimatedValue(float value = 0.0f,
float target = 1.0f,
float speed = 0.016f,
Easing::
Fn ease = Easing:: Linear) - operator float() const
- Implicitly converts to the eased value.
Public functions
- void Update(float timeMult)
- Advances the value toward the target.
- auto Eased() const -> float
- Returns the eased value.
- auto Raw() const -> float
- Returns the raw (un-eased) value.
- auto IsDone() const -> bool
- Returns
trueif the value reached its target. - void Restart(float from = 0.0f, float to = 1.0f)
- Restarts the animation from the specified value toward
1.0f.
Public variables
- float Value
- Current raw (un-eased) progress.
- float Target
- Target the value advances toward.
- float Speed
- Amount the raw value changes per
timeMultunit. -
Easing::
Fn Ease - Easing function applied when reading the value.