Skip to content

Commit

Permalink
Invert colors back to match the rest of conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
bemyak committed Dec 5, 2024
1 parent 80d364d commit 9c0fb76
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ impl From<Color> 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,
}
}
}
Expand All @@ -357,15 +357,15 @@ impl From<embedded_graphics_core::pixelcolor::Rgb565> 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
}
}
}
Expand All @@ -376,8 +376,8 @@ impl From<Color> 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,
}
}
}
Expand All @@ -387,15 +387,15 @@ impl From<embedded_graphics_core::pixelcolor::Rgb555> 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
}
}
}
Expand All @@ -406,8 +406,8 @@ impl From<Color> 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,
}
}
}
Expand Down

0 comments on commit 9c0fb76

Please sign in to comment.