Expand description
Types for creating animations.
Animations in Cushy are performed by transitioning a Dynamic
’s contained
value over time. This starts with Dynamic::transition_to()
, which
returns a DynamicTransition
.
DynamicTransition
implements AnimationTarget
, a trait that describes
types that can be updated using linear interpolation.
AnimationTarget
is also implemented for tuples of AnimationTarget
implementors, allowing multiple transitions to be an AnimationTarget
.
Next, the AnimationTarget
is turned into an animation by invoking
AnimationTarget::over()
with the Duration
the transition should
occur over. The animation can further be customized using
Animation::with_easing()
to utilize any Easing
implementor.
use std::time::Duration;
use cushy::animation::easings::EaseInOutElastic;
use cushy::animation::{AnimationTarget, Spawn};
use cushy::value::{Dynamic, Source};
let value = Dynamic::new(0);
let mut reader = value.create_reader();
value
.transition_to(100)
.over(Duration::from_millis(100))
.with_easing(EaseInOutElastic)
.launch();
drop(value);
while reader.block_until_updated() {
println!("{}", reader.get());
}
assert_eq!(reader.get(), 100);
Modules§
- Built-in
Easing
implementations.
Structs§
- A handle to a spawned animation. When dropped, the associated animation will be stopped.
- A wrapper that implements
LinearInterpolate
such that the value switches after 50%. - An animation combinator that runs animation
A
, then animationB
. - An animation that repeats another animation.
- A pending transition for a
Dynamic
to a new value. - An easing function for customizing animations.
- A wrapper that implements
LinearInterpolate
such that the target value is immediately returned as long as percent is > 0. - An animation wrapper that invokes a callback upon the animation completing.
- A
Chain
that is currently animating. - A
DynamicTransition
that has begun its transition. - An
f32
that is clamped between 0.0 and 1.0 and cannot be NaN or Infinity.
Traits§
- A type that can animate.
- The target of an
Animate
implementor. - A target for a timed
Animation
. - A type that can convert into
Box<dyn Animate>
. - Performs easing for value interpolation.
- A type that can be converted into an animation.
- Performs a linear interpolation between two values.
- Calculates the ratio of one value against a minimum and maximum.
- An animation that can be spawned.
Derive Macros§
- Derives
LinerarInterpolate
for structs and fieldless enums.