lib8: implement layer blending
This commit is contained in:
parent
6fc4cb224f
commit
18287783d4
10
src/lib8.rs
10
src/lib8.rs
@ -2,6 +2,16 @@ use palette::encoding::srgb::Srgb;
|
|||||||
|
|
||||||
use rgb::RGB8;
|
use rgb::RGB8;
|
||||||
|
|
||||||
|
pub trait Rgb8Blend {
|
||||||
|
fn saturating_add(&self, b: Self) -> Self;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Rgb8Blend for RGB8 {
|
||||||
|
fn saturating_add(&self, b: Self) -> Self {
|
||||||
|
RGB8::new(self.r.saturating_add(b.r), self.g.saturating_add(b.g), self.b.saturating_add(b.b))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait IntoRgb8 {
|
pub trait IntoRgb8 {
|
||||||
fn into_rgb8(self) -> RGB8;
|
fn into_rgb8(self) -> RGB8;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ impl<T: LedPixelShape, S: Surface> Display<S> for EmbeddedDisplay<Ws2812DrawTarg
|
|||||||
let mut pixel = RGB8::new(0, 0, 0);
|
let mut pixel = RGB8::new(0, 0, 0);
|
||||||
for surface in self.surfaces.iter() {
|
for surface in self.surfaces.iter() {
|
||||||
surface.with_shader(|shader| {
|
surface.with_shader(|shader| {
|
||||||
pixel = shader.draw(virtCoords.clone());
|
pixel = pixel.saturating_add(shader.draw(virtCoords.clone()));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
self.total_mw += pixel.as_milliwatts();
|
self.total_mw += pixel.as_milliwatts();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user