Skip to main content

Crate ravenrs_animation

Crate ravenrs_animation 

Source
Expand description

Motion primitives: pure functions of time, with no timers or frame loop.

Animated is the center of the crate: a value that heads for a target under a Transition and can be sent somewhere else at any moment without a jump in position or velocity.

use ravenrs_animation::{Animated, Transition};

let mut x = Animated::new(0.0_f32);
x.set_target(100.0, Transition::snappy(), 0.0);
assert!(x.value(0.05) > 0.0);
// Interrupted halfway: it turns around smoothly, from where it is.
let before = x.value(0.1);
x.set_target(0.0, Transition::snappy(), 0.1);
assert!((x.value(0.1) - before).abs() < 1e-3);

Structs§

Animated
A value on its way to a target. It holds no clock: every call takes the time.
CubicBezier
A timing curve from (0, 0) to (1, 1) with two control points, the same as CSS cubic-bezier().
Spring
A damped harmonic oscillator with unit mass, solved in closed form.

Enums§

Easing
How a timed transition moves from start to end.
Transition
How a value travels to a new target.

Traits§

Animatable
A value that can be animated: up to four numbers that add and subtract.

Functions§

from_oklab
Converts [L, a, b, alpha] back to a color, clamped to the sRGB gamut.
mix_oklab
Mixes two colors in OKLab with premultiplied alpha, so a fade from transparent keeps the destination’s hue instead of passing through gray.
to_oklab
Converts a color to OKLab: [L, a, b, alpha]. Equal steps in this space look like equal steps to the eye, which is not true of sRGB.