summaryrefslogtreecommitdiffstats
path: root/vendor/plotters-backend/src/style.rs
blob: 028a06bcb9093db01291583cfa6784d72ba38f50 (plain)
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
/// The color type that is used by all the backend
#[derive(Clone, Copy)]
pub struct BackendColor {
    pub alpha: f64,
    pub rgb: (u8, u8, u8),
}

impl BackendColor {
    #[inline(always)]
    pub fn mix(&self, alpha: f64) -> Self {
        Self {
            alpha: self.alpha * alpha,
            rgb: self.rgb,
        }
    }
}

/// The style data for the backend drawing API
pub trait BackendStyle {
    /// Get the color of current style
    fn color(&self) -> BackendColor;

    /// Get the stroke width of current style
    fn stroke_width(&self) -> u32 {
        1
    }
}

impl BackendStyle for BackendColor {
    fn color(&self) -> BackendColor {
        *self
    }
}