Crates.io | anim |
lib.rs | anim |
version | 0.1.4 |
source | src |
created_at | 2021-06-19 07:44:34.978163 |
updated_at | 2021-12-31 07:44:02.29297 |
description | A framework independent animation library for rust, works nicely with Iced and the others |
homepage | https://github.com/Joylei/anim-rs |
repository | https://github.com/Joylei/anim-rs.git |
max_upload_size | |
id | 412024 |
size | 1,094,394 |
A framework independent animation library for rust, works nicely with Iced and the others.
Include anim
in your Cargo.toml
dependencies:
[dependencies]
anim = "0.1"
Note: anim
turns on iced-backend
feature by default. You need to disable default features if you do not work with iced
.
[dependencies]
anim = { version="0.1", default-features = false }
There are 3 important concepts in anim
:
Animatable
Types derived from Animatable
means that its values can be calculated based on timing progress, with which you can create Animation
objects.
Animation
The Animation
generates values based on its timing progress. You can construct a big Animation
from small ones.
Timeline
With Timeline
you can control your animations' lifetime.
For simple scenarios, you just need Options
.
use anim::{Options, Timeline, Animation, easing};
Then, build and start your animation:
use std::time::Duration;
use anim::{Options, Timeline, Animation, easing};
let mut timeline = Options::new(20,100).easing(easing::bounce_ease())
.duration(Duration::from_millis(300))
.begin_animation();
loop {
let status = timeline.update();
if status.is_completed() {
break;
}
println!("animated value: {}", timeline.value());
}
For complex scenarios, please look at examples to gain some ideas.
color-example
This example shows you color animations:
cargo run --release --example color-example
size-example
This example shows you size animations:
cargo run --release --example size-example
animated-splash
This example shows you rain dop splash animations:
cargo run --release --example animated-splash
MIT