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
|
use super::color::{Color, RGBAColor};
/// Style for any of shape
#[derive(Clone)]
pub struct ShapeStyle {
pub color: RGBAColor,
pub filled: bool,
pub stroke_width: u32,
}
impl ShapeStyle {
/// Make a filled shape style
pub fn filled(&self) -> Self {
Self {
color: self.color.to_rgba(),
filled: true,
stroke_width: self.stroke_width,
}
}
pub fn stroke_width(&self, width: u32) -> Self {
Self {
color: self.color.to_rgba(),
filled: self.filled,
stroke_width: width,
}
}
}
impl<'a, T: Color> From<&'a T> for ShapeStyle {
fn from(f: &'a T) -> Self {
ShapeStyle {
color: f.to_rgba(),
filled: false,
stroke_width: 1,
}
}
}
|