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
use crate::color::{Alpha, Rgb, Rgba};
use std::collections::HashMap;

/// A set of styling defaults used for coloring texturing geometric primitives that have no entry
/// within the **Draw**'s inner **ColorMap**.
#[derive(Clone, Debug, Default)]
pub struct Theme {
    /// Color defaults.
    pub color: Color,
}

/// A set of defaults used for coloring.
#[derive(Clone, Debug)]
pub struct Color {
    pub default: Rgba,
    pub primitive: HashMap<Primitive, Rgba>,
}

/// Primitive geometry types that may have unique default styles.
///
/// These are used as keys into the **Theme**'s geometry primitive default values.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub enum Primitive {
    Cuboid,
    Ellipse,
    Line,
    Polygon,
    Polyline,
    Quad,
    Rect,
    Tri,
}

impl Default for Color {
    fn default() -> Self {
        let default = Alpha {
            color: Rgb::new(1.0, 1.0, 1.0),
            alpha: 1.0,
        };
        let primitive = Default::default();
        Color { default, primitive }
    }
}