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
use arrayvec::ArrayVec;
type DashArray = [f64; MAX_DASH];
const MAX_DASH: usize = 5;
#[derive(Clone, PartialEq, Debug)]
pub struct StrokeStyle {
pub line_join: Option<LineJoin>,
pub line_cap: Option<LineCap>,
pub dash: Option<(ArrayVec<DashArray>, f64)>,
pub miter_limit: Option<f64>,
}
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum LineJoin {
Miter,
Round,
Bevel,
}
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum LineCap {
Butt,
Round,
Square,
}
impl StrokeStyle {
pub fn new() -> StrokeStyle {
StrokeStyle {
line_join: None,
line_cap: None,
dash: None,
miter_limit: None,
}
}
pub fn set_line_join(&mut self, line_join: LineJoin) {
self.line_join = Some(line_join);
}
pub fn set_line_cap(&mut self, line_cap: LineCap) {
self.line_cap = Some(line_cap);
}
pub fn set_dash(&mut self, dashes: ArrayVec<DashArray>, offset: f64) {
self.dash = Some((dashes, offset));
}
pub fn set_miter_limit(mut self, miter_limit: f64) {
self.miter_limit = Some(miter_limit);
}
}