1
use easygpu_lyon::lyon_tessellation::StrokeOptions;
2
use figures::Figure;
3

            
4
use crate::color::Color;
5
use crate::math::Scaled;
6

            
7
/// A shape stroke (outline) options.
8
#[derive(Default, Clone, Debug)]
9
pub struct Stroke {
10
    /// The color to stroke the shape's with.
11
    pub color: Color,
12
    /// The options for drawing the stroke.
13
    pub options: StrokeOptions,
14
}
15

            
16
impl Stroke {
17
    /// Creates a new instance using `color` with default options.
18
    #[must_use]
19
    pub fn new(color: Color) -> Self {
20
        Self {
21
            color,
22
            options: StrokeOptions::default(),
23
        }
24
    }
25

            
26
    /// Builder-style function. Sets `options` and return self.
27
    #[must_use]
28
    pub const fn with_options(mut self, options: StrokeOptions) -> Self {
29
        self.options = options;
30
        self
31
    }
32

            
33
    /// Builder-style function. Sets `options.line_width` and return self.
34
    #[must_use]
35
    pub fn line_width<F: Into<Figure<f32, Scaled>>>(mut self, width: F) -> Self {
36
        self.options.line_width = width.into().get();
37
        self
38
    }
39
}