diff --git a/src/color.rs b/src/color.rs index 130e04ac..e2583328 100644 --- a/src/color.rs +++ b/src/color.rs @@ -346,8 +346,8 @@ impl From for embedded_graphics_core::pixelcolor::Rgb888 { fn from(color: Color) -> Self { use embedded_graphics_core::pixelcolor::RgbColor; match color { - Color::Black => embedded_graphics_core::pixelcolor::Rgb888::WHITE, - Color::White => embedded_graphics_core::pixelcolor::Rgb888::BLACK, + Color::Black => Self::BLACK, + Color::White => Self::WHITE, } } } @@ -357,15 +357,15 @@ impl From for Color { fn from(rgb: embedded_graphics_core::pixelcolor::Rgb565) -> Self { use embedded_graphics_core::pixelcolor::RgbColor; if rgb == RgbColor::BLACK { - Color::White - } else if rgb == RgbColor::WHITE { Color::Black + } else if rgb == RgbColor::WHITE { + Color::White } else { // choose closest color if (rgb.r() as u16 + rgb.g() as u16 + rgb.b() as u16) > 255 * 3 / 2 { - Color::Black - } else { Color::White + } else { + Color::Black } } } @@ -376,8 +376,8 @@ impl From for embedded_graphics_core::pixelcolor::Rgb565 { fn from(color: Color) -> Self { use embedded_graphics_core::pixelcolor::RgbColor; match color { - Color::Black => Self::WHITE, - Color::White => Self::BLACK, + Color::Black => Self::BLACK, + Color::White => Self::WHITE, } } } @@ -387,15 +387,15 @@ impl From for Color { fn from(rgb: embedded_graphics_core::pixelcolor::Rgb555) -> Self { use embedded_graphics_core::pixelcolor::RgbColor; if rgb == RgbColor::BLACK { - Color::White - } else if rgb == RgbColor::WHITE { Color::Black + } else if rgb == RgbColor::WHITE { + Color::White } else { // choose closest color if (rgb.r() as u16 + rgb.g() as u16 + rgb.b() as u16) > 255 * 3 / 2 { - Color::Black - } else { Color::White + } else { + Color::Black } } } @@ -406,8 +406,8 @@ impl From for embedded_graphics_core::pixelcolor::Rgb555 { fn from(color: Color) -> Self { use embedded_graphics_core::pixelcolor::RgbColor; match color { - Color::Black => Self::WHITE, - Color::White => Self::BLACK, + Color::Black => Self::BLACK, + Color::White => Self::WHITE, } } }