/
animations.rs
74 lines (68 loc) · 1.74 KB
/
animations.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use kdam::{term, tqdm, Animation, BarExt};
use std::io::Result;
fn main() -> Result<()> {
term::init(false);
term::hide_cursor()?;
let render_length = 300;
let mut pb1 = tqdm!(
total = render_length,
desc = "tqdm ",
position = 0,
force_refresh = true
);
let mut pb2 = tqdm!(
total = render_length,
desc = "ascii ",
animation = "ascii",
position = 2,
force_refresh = true
);
let mut pb3 = tqdm!(
total = render_length,
desc = "fillup ",
animation = "fillup",
position = 4,
force_refresh = true
);
let mut pb4 = tqdm!(
total = render_length,
desc = "classic ",
animation = "classic",
position = 6,
force_refresh = true
);
let mut pb5 = tqdm!(
total = render_length,
desc = "arrow ",
animation = "arrow",
position = 8,
force_refresh = true
);
let mut pb6 = tqdm!(
total = render_length,
desc = "custom1 ",
animation = Animation::custom(&["\\", "|", "/", "-"], None),
position = 10,
force_refresh = true
);
let mut pb7 = tqdm!(
total = render_length,
desc = "custom2 ",
animation = Animation::custom(&["\\", "|", "/", "-"], Some(".")),
position = 12,
force_refresh = true
);
println!("animations:\n");
for _ in 0..render_length {
pb1.update(1)?;
pb2.update(1)?;
pb3.update(1)?;
pb4.update(1)?;
pb5.update(1)?;
pb6.update(1)?;
pb7.update(1)?;
std::thread::sleep(std::time::Duration::from_secs_f32(0.02));
}
eprint!("{}", "\n".repeat(13));
Ok(())
}