lib8: use Rgb<u8> instead of RGB8
This commit is contained in:
parent
c53a9e27ae
commit
e4b8863513
@ -4,31 +4,32 @@ pub mod trig;
|
|||||||
|
|
||||||
use palette::encoding::srgb::Srgb;
|
use palette::encoding::srgb::Srgb;
|
||||||
|
|
||||||
use rgb::RGB8;
|
use rgb::Rgb;
|
||||||
|
|
||||||
pub trait Rgb8Blend {
|
pub trait Rgb8Blend {
|
||||||
fn saturating_add(self, b: Self) -> Self;
|
fn saturating_add<T: Into<Self>>(self, b: T) -> Self where Self: Sized;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Rgb8Blend for RGB8 {
|
impl Rgb8Blend for Rgb<u8> {
|
||||||
fn saturating_add(self, b: Self) -> Self {
|
fn saturating_add<T: Into<Self>>(self, b: T) -> Self where Self: Sized {
|
||||||
RGB8::new(self.r.saturating_add(b.r), self.g.saturating_add(b.g), self.b.saturating_add(b.b))
|
let rgb = b.into();
|
||||||
|
Rgb::new(self.r.saturating_add(rgb.r), self.g.saturating_add(rgb.g), self.b.saturating_add(rgb.b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait IntoRgb8 {
|
pub trait IntoRgb8 {
|
||||||
fn into_rgb8(self) -> RGB8;
|
fn into_rgb8(self) -> Rgb<u8>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoRgb8 for RGB8 {
|
impl IntoRgb8 for Rgb<u8> {
|
||||||
fn into_rgb8(self) -> RGB8 {
|
fn into_rgb8(self) -> Rgb<u8> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoRgb8 for palette::Hsv<Srgb, u8> {
|
impl IntoRgb8 for palette::Hsv<Srgb, u8> {
|
||||||
//TODO: Borrowed from FastLED
|
//TODO: Borrowed from FastLED
|
||||||
fn into_rgb8(self) -> RGB8 {
|
fn into_rgb8(self) -> Rgb<u8> {
|
||||||
const HSV_SECTION_3: u8 = 0x40;
|
const HSV_SECTION_3: u8 = 0x40;
|
||||||
|
|
||||||
let value: u8 = self.value;
|
let value: u8 = self.value;
|
||||||
@ -50,9 +51,9 @@ impl IntoRgb8 for palette::Hsv<Srgb, u8> {
|
|||||||
let rampdown_adj_with_floor: u8 = rampdown_amp_adj + brightness_floor;
|
let rampdown_adj_with_floor: u8 = rampdown_amp_adj + brightness_floor;
|
||||||
|
|
||||||
match section {
|
match section {
|
||||||
1 => RGB8::new(brightness_floor, rampdown_adj_with_floor, rampup_adj_with_floor),
|
1 => Rgb::new(brightness_floor, rampdown_adj_with_floor, rampup_adj_with_floor),
|
||||||
0 => RGB8::new(rampdown_adj_with_floor, rampup_adj_with_floor, brightness_floor),
|
0 => Rgb::new(rampdown_adj_with_floor, rampup_adj_with_floor, brightness_floor),
|
||||||
_ => RGB8::new(rampup_adj_with_floor, brightness_floor, rampdown_adj_with_floor)
|
_ => Rgb::new(rampup_adj_with_floor, brightness_floor, rampdown_adj_with_floor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user