Skip to main content

wallrnd/
lib.rs

1pub mod cfg;
2pub mod chooser;
3pub mod color;
4pub mod deserializer;
5pub mod frame;
6pub mod log;
7pub mod paint;
8pub mod pos;
9pub mod salt;
10pub mod scene;
11pub mod shape;
12pub mod svg;
13pub mod tesselate;
14
15pub mod prelude {
16    pub use super::Verbosity;
17    use super::*;
18    pub use cfg::{Pattern, Tiling};
19    pub use chooser::Chooser;
20    pub use color::Color;
21    pub use frame::Frame;
22    pub use pos::{radians, Pos};
23    pub use salt::{Salt, SaltItem};
24
25    use std::collections::HashMap;
26    pub type ColorList = HashMap<String, Color>;
27    pub type ThemeList = HashMap<String, Chooser<ThemeItem>>;
28
29    #[derive(Clone, Debug)]
30    pub struct ThemeItem(pub Color, pub Option<usize>, pub Option<usize>, pub Salt);
31}
32
33#[derive(Clone, Copy, Default)]
34pub struct Verbosity {
35    pub info: bool,
36    pub warn: bool,
37    pub prog: bool,
38    pub details: bool,
39}
40
41impl Verbosity {
42    pub fn from(s: &str) -> Self {
43        let mut v = Verbosity::default();
44        for option in s.chars() {
45            match option {
46                'A' => {
47                    v.info = true;
48                    v.warn = true;
49                    v.prog = true;
50                    v.details = true;
51                }
52                'I' => v.info = true,
53                'W' => v.warn = true,
54                'P' => v.prog = true,
55                'D' => v.details = true,
56                c => println!(
57                    "Unknown verbosity option '{}', use one or more of 'IWPDA'",
58                    c
59                ),
60            }
61        }
62        v
63    }
64}