Enum embedded_graphics::pixelcolor::BinaryColor
source · [−]pub enum BinaryColor {
Off,
On,
}
Expand description
Binary color.
BinaryColor
is used for displays and images with two possible color states.
The interpretation of active and inactive states can be different for
different types of displays. A BinaryColor::On
might represent a black
pixel on an LCD and a white pixel on an OLED display.
To simplify the conversion from BinaryColor
to RGB and grayscale color
types the default conversions assume that BinaryColor::Off
is black and
BinaryColor::On
is white.
Conversion between BinaryColor and bool
use embedded_graphics::pixelcolor::BinaryColor;
// A BinaryColor can be converted to a bool by using the is_on and is_off methods.
let color = BinaryColor::On;
assert!(color.is_on());
assert!(color.invert().is_off());
// BinaryColor implements From<bool>.
let bool_value = true;
let color: BinaryColor = bool_value.into();
assert_eq!(color, BinaryColor::On);
// this is equivalent to:
let bool_value = true;
let color = if bool_value {
BinaryColor::On
} else {
BinaryColor::Off
};
assert_eq!(color, BinaryColor::On);
Variants
Off
Inactive pixel.
On
Active pixel.
Implementations
sourceimpl BinaryColor
impl BinaryColor
sourcepub fn invert(self) -> Self
pub fn invert(self) -> Self
Inverts the color.
Examples
use embedded_graphics::pixelcolor::BinaryColor;
assert_eq!(BinaryColor::Off.invert(), BinaryColor::On);
assert_eq!(BinaryColor::On.invert(), BinaryColor::Off);
Trait Implementations
sourceimpl Clone for BinaryColor
impl Clone for BinaryColor
sourcefn clone(&self) -> BinaryColor
fn clone(&self) -> BinaryColor
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl ColorMapping<BinaryColor> for BinaryColor
impl ColorMapping<BinaryColor> for BinaryColor
sourcefn char_to_color(c: char) -> Self
fn char_to_color(c: char) -> Self
Converts a char into a color of type C
.
sourcefn color_to_char(color: BinaryColor) -> char
fn color_to_char(color: BinaryColor) -> char
Converts a color of type C
into a char.
sourceimpl Debug for BinaryColor
impl Debug for BinaryColor
sourceimpl Default for BinaryColor
impl Default for BinaryColor
sourceimpl From<BinaryColor> for RawU1
impl From<BinaryColor> for RawU1
sourcefn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Performs the conversion.
sourceimpl From<BinaryColor> for Rgb555
impl From<BinaryColor> for Rgb555
sourcefn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Performs the conversion.
sourceimpl From<BinaryColor> for Bgr555
impl From<BinaryColor> for Bgr555
sourcefn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Performs the conversion.
sourceimpl From<BinaryColor> for Rgb565
impl From<BinaryColor> for Rgb565
sourcefn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Performs the conversion.
sourceimpl From<BinaryColor> for Bgr565
impl From<BinaryColor> for Bgr565
sourcefn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Performs the conversion.
sourceimpl From<BinaryColor> for Rgb888
impl From<BinaryColor> for Rgb888
sourcefn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Performs the conversion.
sourceimpl From<BinaryColor> for Bgr888
impl From<BinaryColor> for Bgr888
sourcefn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Performs the conversion.
sourceimpl From<BinaryColor> for Gray2
impl From<BinaryColor> for Gray2
sourcefn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Performs the conversion.
sourceimpl From<BinaryColor> for Gray4
impl From<BinaryColor> for Gray4
sourcefn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Performs the conversion.
sourceimpl From<BinaryColor> for Gray8
impl From<BinaryColor> for Gray8
sourcefn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Performs the conversion.
sourceimpl Hash for BinaryColor
impl Hash for BinaryColor
sourceimpl Ord for BinaryColor
impl Ord for BinaryColor
sourceimpl PartialEq<BinaryColor> for BinaryColor
impl PartialEq<BinaryColor> for BinaryColor
sourceimpl PartialOrd<BinaryColor> for BinaryColor
impl PartialOrd<BinaryColor> for BinaryColor
sourcefn partial_cmp(&self, other: &BinaryColor) -> Option<Ordering>
fn partial_cmp(&self, other: &BinaryColor) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl PixelColor for BinaryColor
impl PixelColor for BinaryColor
impl Copy for BinaryColor
impl Eq for BinaryColor
impl StructuralEq for BinaryColor
impl StructuralPartialEq for BinaryColor
Auto Trait Implementations
impl RefUnwindSafe for BinaryColor
impl Send for BinaryColor
impl Sync for BinaryColor
impl Unpin for BinaryColor
impl UnwindSafe for BinaryColor
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more