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
/// Represents a stippled brush stroke, with the parameters
/// - translation: [f32; 2] from -1 to 1
/// - scale: [f32; 2] from -`inf` to +`inf`: controls the size of the stipple bounds
/// - colormap_scale: [f32; 2] from -`inf` to +`inf`: controls the colormap rate of change.  large values produce more color variance
/// - rotation: [f32; 2] from -`inf` to +`inf` (radians)
#[derive(Clone, Debug)]
pub struct Stipple {
    pub(crate) translation: [f32; 2],
    pub(crate) scale: [f32; 2],
    pub(crate) colormap_scale: [f32; 2],
    pub(crate) rotation: f32,
    pub(crate) texture_rotation: f32,
    pub(crate) gamma: f32,
}

impl Stipple {
    pub fn new() -> Stipple {
        Self::default()
    }

    pub fn with_translation(mut self, translation: [f32; 2]) -> Self {
        self.translation = translation;
        self
    }

    pub fn with_scale(mut self, scale: [f32; 2]) -> Self {
        self.scale = scale;
        self
    }

    pub fn with_colormap_scale(mut self, scale: [f32; 2]) -> Self {
        self.colormap_scale = scale;
        self
    }

    pub fn with_rotation(mut self, rotation: f32) -> Self {
        self.rotation = rotation;
        self
    }

    pub fn with_texture_rotation(mut self, texture_rotation: f32) -> Self {
        self.texture_rotation = texture_rotation;
        self
    }

    pub fn with_gamma(mut self, gamma: f32) -> Self {
        self.gamma = gamma;
        self
    }
}

impl Default for Stipple {
    fn default() -> Stipple {
        Stipple {
            translation: [0.0, 0.0],
            scale: [1.0, 1.0],
            colormap_scale: [1.0, 1.0],
            rotation: 0.0,
            texture_rotation: 0.0,
            gamma: 1.0,
        }
    }
}