chargrid_render/
blend.rs

1use rgb24::Rgb24;
2
3pub trait Blend: Copy {
4    fn blend(self, current: Rgb24, new: Rgb24, alpha: u8) -> Rgb24;
5}
6
7pub mod blend_mode {
8    use super::*;
9
10    #[derive(Clone, Copy)]
11    pub struct Replace;
12    impl Blend for Replace {
13        fn blend(self, _current: Rgb24, new: Rgb24, _alpha: u8) -> Rgb24 {
14            new
15        }
16    }
17
18    #[derive(Clone, Copy)]
19    pub struct LinearInterpolate;
20    impl Blend for LinearInterpolate {
21        fn blend(self, current: Rgb24, new: Rgb24, alpha: u8) -> Rgb24 {
22            current.linear_interpolate(new, alpha)
23        }
24    }
25}