| 1 | /// The color type that is used by all the backend |
| 2 | #[derive (Clone, Copy)] |
| 3 | pub struct BackendColor { |
| 4 | pub alpha: f64, |
| 5 | pub rgb: (u8, u8, u8), |
| 6 | } |
| 7 | |
| 8 | impl BackendColor { |
| 9 | #[inline (always)] |
| 10 | pub fn mix(&self, alpha: f64) -> Self { |
| 11 | Self { |
| 12 | alpha: self.alpha * alpha, |
| 13 | rgb: self.rgb, |
| 14 | } |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | /// The style data for the backend drawing API |
| 19 | pub trait BackendStyle { |
| 20 | /// Get the color of current style |
| 21 | fn color(&self) -> BackendColor; |
| 22 | |
| 23 | /// Get the stroke width of current style |
| 24 | fn stroke_width(&self) -> u32 { |
| 25 | 1 |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | impl BackendStyle for BackendColor { |
| 30 | fn color(&self) -> BackendColor { |
| 31 | *self |
| 32 | } |
| 33 | } |
| 34 | |