From 61b28179d12cd9eb8aebc7f20a8136fe91636270 Mon Sep 17 00:00:00 2001 From: Victoria Fischer Date: Sat, 16 Nov 2024 11:48:11 +0100 Subject: [PATCH] lib8: implement scale8 from fastled --- src/lib8.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib8.rs b/src/lib8.rs index 6ee343d..60ba524 100644 --- a/src/lib8.rs +++ b/src/lib8.rs @@ -2,6 +2,11 @@ use palette::encoding::srgb::Srgb; use rgb::RGB8; +pub fn scale8(i: u8, scale: u8) -> u8 { + // borrowed from FastLED + (i as u16 * scale as u16).wrapping_shr(8) as u8 +} + pub trait Rgb8Blend { fn saturating_add(self, b: Self) -> Self; }