2 个版本
| 0.1.4 | 2021 年 12 月 31 日 |
|---|---|
| 0.1.3 |
|
| 0.1.2 | 2021 年 6 月 23 日 |
| 0.1.1 |
|
| 0.1.0 |
|
#359 在 GUI 中
660KB
2.5K SLoC
anim
为 Rust 提供的独立框架动画库,与 Iced 和其他库配合良好。
展示



如何安装?
在您的 Cargo.toml 依赖项中包含 anim
[dependencies]
anim = "0.1"
注意:默认情况下,anim 启用 iced-backend 功能。如果您不使用 iced,则需要禁用默认功能。
[dependencies]
anim = { version="0.1", default-features = false }
如何使用?
anim 有 3 个重要概念
-
Animatable从Animatable衍生的类型意味着其值可以根据时间进度进行计算,您可以使用它创建Animation对象。 -
Animation根据Animation的时间进度生成值。您可以从小的Animation构造大的Animation。 -
Timeline使用Timeline,您可以控制动画的生命周期。
对于简单场景,您只需要 Options。
use anim::{Options, Timeline, Animation, easing};
然后,构建并开始您的动画
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());
}
对于复杂场景,请参阅 示例 以获取一些灵感。
如何运行示例?
示例 #1:color-example
此示例向您展示了颜色动画
cargo run --release --example color-example
示例 #2:size-example
此示例向您展示了大小动画
cargo run --release --example size-example
示例 #3:animated-splash
此示例向您展示了雨滴溅射动画
cargo run --release --example animated-splash
许可证
MIT
依赖关系
~0–2.4MB
~44K SLoC