anim/lib.rs
1// anim
2//
3// A framework independent animation library for rust, works nicely with Iced and the others
4// Copyright: 2021, Joylei <leingliu@gmail.com>
5// License: MIT
6
7/*!
8# anim
9
10This is a framework independent animation library for rust, works nicely with [Iced](https://github.com/hecrj/iced) and the others.
11
12## Showcase
13
14<center>
15
16
17
18
19
20
21
22</center>
23
24## How to install?
25
26Include `anim` in your `Cargo.toml` dependencies:
27
28```toml
29[dependencies]
30anim = "0.1"
31```
32
33Note: `anim` turns on `iced-backend` feature by default. You need to disable default features if you do not work with `iced`.
34
35```toml
36[dependencies]
37anim = { version="0.1", default-features = false }
38```
39
40## How to use?
41
42There are 3 important concepts in `anim`:
43- `Animatable`
44Types derived from `Animatable` means that its values can be calculated based on timing progress, with which you can create `Animation` objects.
45
46- `Animation`
47The `Animation` generates values based on its timing progress. You can construct a big `Animation` from small ones.
48
49- `Timeline`
50With `Timeline` you can control your animations' lifetime.
51
52---
53
54For simple scenarios, you just need `Options`.
55
56```rust
57use anim::{Options, Timeline, Animation, easing};
58```
59
60Then, build and start your animation:
61
62```rust
63use std::time::Duration;
64use anim::{Options, Timeline, Animation, easing};
65
66let mut timeline = Options::new(20,100).easing(easing::bounce_ease())
67 .duration(Duration::from_millis(300))
68 .begin_animation();
69
70loop {
71 let status = timeline.update();
72 if status.is_completed() {
73 break;
74 }
75 println!("animated value: {}", timeline.value());
76}
77```
78
79For complex scenarios, please look at [examples](https://github.com/Joylei/anim-rs/tree/master/examples/) to gain some ideas.
80
81
82*/
83
84#![warn(missing_docs)]
85
86mod core;
87/// iced animation backend
88#[cfg(feature = "iced-backend")]
89mod iced;
90/// thread local based timeline
91#[cfg(feature = "local")]
92pub mod local;
93
94// reexports
95pub use crate::core::*;
96#[cfg(feature = "iced-backend")]
97pub use crate::iced::*;
98
99#[cfg(feature = "derive")]
100pub use anim_derive::Animatable;