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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use crate::RGB;
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Fill {
pub color: RGB,
}
impl Fill {
pub fn new(color: RGB) -> Fill {
Fill { color }
}
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Stroke {
pub width: u32,
pub color: RGB,
}
impl Stroke {
pub fn new(width: u32, color: RGB) -> Stroke {
Stroke { width, color }
}
}
#[derive(Default, Clone, Debug, PartialEq)]
pub struct Style {
pub fill: Option<Fill>,
pub stroke: Option<Stroke>,
}
impl Style {
pub fn default() -> Style {
Style {
fill: None,
stroke: None,
}
}
pub fn new(fill: Fill, stroke: Stroke) -> Style {
Style {
fill: Some(fill),
stroke: Some(stroke),
}
}
pub fn filled(color: RGB) -> Style {
Style {
fill: Some(Fill::new(color)),
stroke: None,
}
}
pub fn stroked(width: u32, color: RGB) -> Style {
Style {
fill: None,
stroke: Some(Stroke::new(width, color)),
}
}
}