multi_spinner/
spinners.rs

1#![allow(dead_code)]
2
3#[derive(Clone)]
4pub enum Animation {
5    Dots2(usize),
6    Dots3(usize),
7    Bars10(usize),
8}
9
10impl Animation {
11    pub fn next_frame(&mut self) -> &str {
12        match self {
13            Self::Dots2(idx) => *idx = (*idx + 1) % DOTS_2.len(),
14            Self::Dots3(idx) => *idx = (*idx + 1) % DOTS_3.len(),
15            Self::Bars10(idx) => *idx = (*idx + 1) % BARS_10.len(),
16        }
17        match self {
18            Self::Dots2(idx) => DOTS_2[*idx],
19            Self::Dots3(idx) => DOTS_3[*idx],
20            Self::Bars10(idx) => BARS_10[*idx],
21        } 
22    } 
23}
24
25static DOTS_2: &[&str] = &[
26    "⠈", "⠉", "⠋", 
27    "⠓", "⠒", "⠐", 
28    "⠐", "⠒", "⠖", 
29    "⠦", "⠤", "⠠",
30    "⠠", "⠤", "⠦", 
31    "⠖", "⠒", "⠐",
32    "⠐", "⠒", "⠓", 
33    "⠋", "⠉", "⠈"
34];
35
36static DOTS_3: &[&str] = &[
37    " ⠈", " ⠉", "⠈⠉", "⠋ ", 
38    "⠓ ", "⠐⠒", " ⠒", " ⠐", 
39    " ⠐", " ⠒", "⠐⠒", "⠖ ", 
40    "⠦ ", "⠠⠤", " ⠤", " ⠠",
41    " ⠠", " ⠤", "⠠⠤", "⠦ ", 
42    "⠖ ", "⠐⠒", " ⠒", " ⠐",
43    " ⠐", " ⠒", "⠐⠒", "⠓ ", 
44    "⠋ ", "⠈⠉", " ⠉", " ⠈"
45];
46
47static BARS_10: &[&str] = &[
48    "▰▱▱▱▱▱▱▱▱▱",
49    "▰▰▱▱▱▱▱▱▱▱",
50    "▰▰▰▱▱▱▱▱▱▱",
51    "▰▰▰▰▱▱▱▱▱▱",
52    "▰▰▰▰▰▱▱▱▱▱",
53    "▰▰▰▰▰▰▱▱▱▱",
54    "▰▰▰▰▰▰▰▱▱▱",
55    "▰▰▰▰▰▰▰▰▱▱",
56    "▰▰▰▰▰▰▰▰▰▱",
57    "▰▰▰▰▰▰▰▰▰▰",
58];
59