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
use color::{Rgba, Rgb, ToRgba};
use super::AlphaType;
use mutiny_derive::Material;
use derive_builder::Builder;
use super::Parameter;


#[derive(Debug, Material, Builder, Clone)]
#[builder(build_fn(name = "_build", private))]
#[builder(setter(into))]
#[builder(default)]
#[material(default)]
pub struct OutlineMaterial{
    #[material(default = "Rgba::new(Rgb::new(1., 1., 1.), 1.)")]
    #[material(uniform="color_outline")]
    #[builder(private)]
    #[builder(setter(name = "hidden_base_color"))]
    pub base_color: Parameter<Rgba<f32>>,

    #[material(default = 1f32)]
    #[material(uniform)]
    pub offset: Parameter<f32>,

    pub alpha_type: Parameter<AlphaType>,
}

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

    pub fn base_color<C: ToRgba>(&mut self, color: C) -> &mut OutlineMaterialBuilder{
        self.base_color = Some(Parameter::new(color.to_rgba().to_standard()));
        self
    }

    pub fn build(&mut self) -> OutlineMaterial{
        self._build().unwrap()
    }
}