1use crate::{LineCap, LineJoin, Stroke};
4
5impl Stroke {
6 pub fn builder(line_width: f32) -> StrokeBuilder {
13 assert_initialized_main_thread!();
14 StrokeBuilder(Stroke::new(line_width))
15 }
16}
17
18#[must_use = "The builder must be built to be used"]
23pub struct StrokeBuilder(Stroke);
24
25impl StrokeBuilder {
26 pub fn dash(self, dash: &[f32]) -> Self {
27 self.0.set_dash(dash);
28 self
29 }
30
31 pub fn dash_offset(self, dash_offset: f32) -> Self {
32 self.0.set_dash_offset(dash_offset);
33 self
34 }
35
36 pub fn line_cap(self, line_cap: LineCap) -> Self {
37 self.0.set_line_cap(line_cap);
38 self
39 }
40
41 pub fn line_join(self, line_join: LineJoin) -> Self {
42 self.0.set_line_join(line_join);
43 self
44 }
45
46 pub fn miter_limit(self, miter_limit: f32) -> Self {
47 self.0.set_miter_limit(miter_limit);
48 self
49 }
50
51 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
54 pub fn build(self) -> Stroke {
55 self.0
56 }
57}