scal_core/anim.rs
1use crate::{AnimOP, Time};
2
3/// Wait for some time and do nothing :|
4/// Everyone needs some rest.
5#[must_use]
6pub const fn wait(duration: Time) -> AnimOP {
7 AnimOP::Wait(duration, None)
8}
9
10/// Execute Animations at once.
11///```
12/// parallel![
13/// cw.add_lines()
14/// .str(
15/// r"
16///fn fib(n: u32) -> u32 {
17/// match n {
18/// 0 => 0,
19/// 1 => 1,
20/// _ => fib(n - 1) + fib(n - 2),
21/// }
22///}
23/// "
24/// )
25/// .over(5.s())
26/// .style(CodeAnimationStyle::TypeWriterInstantResize),
27/// typing.play(),
28/// ],
29///```
30#[macro_export]
31macro_rules! parallel {
32 ( $( $op:expr ),* $(,)? ) => {
33 $crate::AnimOP::All($crate::timeline![ $( $op ),* ], None)
34 };
35}
36
37/// Allows you to do a sequence of animations inside of a parallel block
38///```
39///parallel![
40/// sequence![
41/// cw.close_button().scale().to(Vec2::ONE * 0.8).over(0.3.s()),
42/// cw.close_button().scale().to(Vec2::ONE).over(0.3.s()),
43/// ],
44/// click.play(),
45///],
46///```
47#[macro_export]
48macro_rules! sequence {
49 ( $( $op:expr ),* $(,)? ) => {
50 $crate::AnimOP::Sequence($crate::timeline![ $( $op ),* ], None)
51 };
52}