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) -> BinaryColor
pub fn invert(self) -> BinaryColor
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
sourcepub fn clone(&self) -> BinaryColor
pub 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 for BinaryColor
impl ColorMapping 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: Self) -> char
fn color_to_char(color: Self) -> char
Converts a color of type C
into a char.
sourceconst NONE_COLOR: Rgb888
const NONE_COLOR: Rgb888
Color used to display None
values when EG_FANCY_PANIC
is enabled. Read more
sourceimpl Debug for BinaryColor
impl Debug for BinaryColor
sourceimpl Default for BinaryColor
impl Default for BinaryColor
sourcepub fn default() -> BinaryColor
pub fn default() -> BinaryColor
Returns the “default value” for a type. Read more
sourceimpl From<Bgr555> for BinaryColor
impl From<Bgr555> for BinaryColor
sourcepub fn from(color: Bgr555) -> BinaryColor
pub fn from(color: Bgr555) -> BinaryColor
Performs the conversion.
sourceimpl From<Bgr565> for BinaryColor
impl From<Bgr565> for BinaryColor
sourcepub fn from(color: Bgr565) -> BinaryColor
pub fn from(color: Bgr565) -> BinaryColor
Performs the conversion.
sourceimpl From<Bgr888> for BinaryColor
impl From<Bgr888> for BinaryColor
sourcepub fn from(color: Bgr888) -> BinaryColor
pub fn from(color: Bgr888) -> BinaryColor
Performs the conversion.
sourceimpl From<BinaryColor> for Rgb888
impl From<BinaryColor> for Rgb888
sourcepub fn from(color: BinaryColor) -> Rgb888
pub fn from(color: BinaryColor) -> Rgb888
Performs the conversion.
sourceimpl From<BinaryColor> for Rgb555
impl From<BinaryColor> for Rgb555
sourcepub fn from(color: BinaryColor) -> Rgb555
pub fn from(color: BinaryColor) -> Rgb555
Performs the conversion.
sourceimpl From<BinaryColor> for Gray8
impl From<BinaryColor> for Gray8
sourcepub fn from(color: BinaryColor) -> Gray8
pub fn from(color: BinaryColor) -> Gray8
Performs the conversion.
sourceimpl From<BinaryColor> for Gray4
impl From<BinaryColor> for Gray4
sourcepub fn from(color: BinaryColor) -> Gray4
pub fn from(color: BinaryColor) -> Gray4
Performs the conversion.
sourceimpl From<BinaryColor> for Bgr555
impl From<BinaryColor> for Bgr555
sourcepub fn from(color: BinaryColor) -> Bgr555
pub fn from(color: BinaryColor) -> Bgr555
Performs the conversion.
sourceimpl From<BinaryColor> for RawU1
impl From<BinaryColor> for RawU1
sourcepub fn from(color: BinaryColor) -> RawU1
pub fn from(color: BinaryColor) -> RawU1
Performs the conversion.
sourceimpl From<BinaryColor> for Bgr888
impl From<BinaryColor> for Bgr888
sourcepub fn from(color: BinaryColor) -> Bgr888
pub fn from(color: BinaryColor) -> Bgr888
Performs the conversion.
sourceimpl From<BinaryColor> for Rgb565
impl From<BinaryColor> for Rgb565
sourcepub fn from(color: BinaryColor) -> Rgb565
pub fn from(color: BinaryColor) -> Rgb565
Performs the conversion.
sourceimpl From<BinaryColor> for Bgr565
impl From<BinaryColor> for Bgr565
sourcepub fn from(color: BinaryColor) -> Bgr565
pub fn from(color: BinaryColor) -> Bgr565
Performs the conversion.
sourceimpl From<BinaryColor> for Gray2
impl From<BinaryColor> for Gray2
sourcepub fn from(color: BinaryColor) -> Gray2
pub fn from(color: BinaryColor) -> Gray2
Performs the conversion.
sourceimpl From<Gray2> for BinaryColor
impl From<Gray2> for BinaryColor
sourcepub fn from(color: Gray2) -> BinaryColor
pub fn from(color: Gray2) -> BinaryColor
Performs the conversion.
sourceimpl From<Gray4> for BinaryColor
impl From<Gray4> for BinaryColor
sourcepub fn from(color: Gray4) -> BinaryColor
pub fn from(color: Gray4) -> BinaryColor
Performs the conversion.
sourceimpl From<Gray8> for BinaryColor
impl From<Gray8> for BinaryColor
sourcepub fn from(color: Gray8) -> BinaryColor
pub fn from(color: Gray8) -> BinaryColor
Performs the conversion.
sourceimpl From<RawU1> for BinaryColor
impl From<RawU1> for BinaryColor
sourcepub fn from(data: RawU1) -> BinaryColor
pub fn from(data: RawU1) -> BinaryColor
Performs the conversion.
sourceimpl From<Rgb555> for BinaryColor
impl From<Rgb555> for BinaryColor
sourcepub fn from(color: Rgb555) -> BinaryColor
pub fn from(color: Rgb555) -> BinaryColor
Performs the conversion.
sourceimpl From<Rgb565> for BinaryColor
impl From<Rgb565> for BinaryColor
sourcepub fn from(color: Rgb565) -> BinaryColor
pub fn from(color: Rgb565) -> BinaryColor
Performs the conversion.
sourceimpl From<Rgb888> for BinaryColor
impl From<Rgb888> for BinaryColor
sourcepub fn from(color: Rgb888) -> BinaryColor
pub fn from(color: Rgb888) -> BinaryColor
Performs the conversion.
sourceimpl From<bool> for BinaryColor
impl From<bool> for BinaryColor
sourcepub fn from(value: bool) -> BinaryColor
pub fn from(value: bool) -> BinaryColor
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
sourcepub fn partial_cmp(&self, other: &BinaryColor) -> Option<Ordering>
pub 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
sourceimpl<T> CheckedAs for T
impl<T> CheckedAs for T
sourcepub fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
pub fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
sourcepub fn checked_cast_from(src: Src) -> Option<Dst>
pub fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
sourceimpl<T> OverflowingAs for T
impl<T> OverflowingAs for T
sourcepub fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
pub fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
sourcepub fn overflowing_cast_from(src: Src) -> (Dst, bool)
pub fn overflowing_cast_from(src: Src) -> (Dst, bool)
OverflowingCasts the value.
sourceimpl<T> SaturatingAs for T
impl<T> SaturatingAs for T
sourcepub fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
pub fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
sourcepub fn saturating_cast_from(src: Src) -> Dst
pub fn saturating_cast_from(src: Src) -> Dst
Casts the value.
sourceimpl<C> ToBytes for C where
C: PixelColor + Into<<C as PixelColor>::Raw>,
impl<C> ToBytes for C where
C: PixelColor + Into<<C as PixelColor>::Raw>,
type Bytes = <<C as PixelColor>::Raw as ToBytes>::Bytes
type Bytes = <<C as PixelColor>::Raw as ToBytes>::Bytes
Return type of methods in this trait.
sourcepub fn to_le_bytes(self) -> <C as ToBytes>::Bytes
pub fn to_le_bytes(self) -> <C as ToBytes>::Bytes
Converts a color into a byte array with little endian byte order.
sourcepub fn to_be_bytes(self) -> <C as ToBytes>::Bytes
pub fn to_be_bytes(self) -> <C as ToBytes>::Bytes
Converts a color into a byte array with big endian byte order.
sourcepub fn to_ne_bytes(self) -> <C as ToBytes>::Bytes
pub fn to_ne_bytes(self) -> <C as ToBytes>::Bytes
Converts a color into a byte array with native byte order.
sourceimpl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
sourcepub fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
pub fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
sourcepub fn unwrapped_cast_from(src: Src) -> Dst
pub fn unwrapped_cast_from(src: Src) -> Dst
UnwrappedCasts the value.
sourceimpl<T> WrappingAs for T
impl<T> WrappingAs for T
sourcepub fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
pub fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
sourcepub fn wrapping_cast_from(src: Src) -> Dst
pub fn wrapping_cast_from(src: Src) -> Dst
WrappingCasts the value.