From 18287783d43aaad6d0a281dce6808be1a01f1c63 Mon Sep 17 00:00:00 2001 From: Victoria Fischer Date: Wed, 30 Oct 2024 21:54:27 +0100 Subject: [PATCH] lib8: implement layer blending --- src/lib8.rs | 10 ++++++++++ src/platform/embedded_graphics_lib.rs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib8.rs b/src/lib8.rs index cfa01d4..c44897d 100644 --- a/src/lib8.rs +++ b/src/lib8.rs @@ -2,6 +2,16 @@ use palette::encoding::srgb::Srgb; 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 { fn into_rgb8(self) -> RGB8; } diff --git a/src/platform/embedded_graphics_lib.rs b/src/platform/embedded_graphics_lib.rs index 76358cc..eb20bfb 100644 --- a/src/platform/embedded_graphics_lib.rs +++ b/src/platform/embedded_graphics_lib.rs @@ -103,7 +103,7 @@ impl Display for EmbeddedDisplay