6 releases (3 breaking)
0.4.0 | Dec 2, 2020 |
---|---|
0.3.2 | Oct 20, 2020 |
0.2.0 | Oct 10, 2020 |
0.1.0 | Sep 25, 2020 |
#12 in #velocity
Used in 2 crates
(via yoyo)
31KB
601 lines
This library implements the basic physics-based primitives we use in Yoyo. The most important task of this library is to support continuous animation.
Continuous animation is when a running, uncompleted animation with a particular value and velocity is replaced with a new animation that starts from that same value and velocity so that it is seemingly one and the same animation to the user.
Example
use yoyo_physics::Curve;
use yoyo_physics::bezier::Bezier;
use yoyo_physics::spring::Spring;
// Start a Bezier with strong easing.
let bezier = Bezier {
from_value: 0.0,
to_value: 320.0,
duration: 1.0,
control_points: [(0.95, 0.05), (0.05, 0.95)],
};
// Pause the Bezier midway.
let sample = bezier.approximate(0.5);
// Start a spring from the Bezier's state.
let spring = Spring {
from_value: sample.value,
to_value: 320.0,
initial_velocity: sample.velocity,
..Default::default()
};
// Verify that the spring's starting velocity equals the Bezier's midway
// velocity.
assert_eq!(spring.approximate(0.0).velocity, sample.velocity);
Dependencies
~150KB