Enum embedded_graphics::pixelcolor::BinaryColor [−][src]
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
Inactive pixel.
Active pixel.
Implementations
Inverts the color.
Examples
use embedded_graphics::pixelcolor::BinaryColor; assert_eq!(BinaryColor::Off.invert(), BinaryColor::On); assert_eq!(BinaryColor::On.invert(), BinaryColor::Off);
Returns true if this color is On.
Examples
use embedded_graphics::pixelcolor::BinaryColor; assert!(BinaryColor::On.is_on());
Trait Implementations
Converts a char into a color of type C.
Converts a color of type C into a char.
Color used to display None values when EG_FANCY_PANIC is enabled. Read more
Returns the “default value” for a type. Read more
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for BinaryColorimpl Send for BinaryColorimpl Sync for BinaryColorimpl Unpin for BinaryColorimpl UnwindSafe for BinaryColorBlanket Implementations
Mutably borrows from an owned value. Read more
Casts the value.
Performs the conversion.
Performs the conversion.
Casts the value.
type Output = T
type Output = TShould always be Self
Casts the value.
The inverse inclusion map: attempts to construct self from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> boolChecks if self is actually part of its subset T (and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SSUse with care! Same as self.to_subset but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SPThe inclusion map: converts self to the equivalent element of its superset.
type Bytes = <<C as PixelColor>::Raw as ToBytes>::Bytes
type Bytes = <<C as PixelColor>::Raw as ToBytes>::BytesReturn type of methods in this trait.
Converts a color into a byte array with little endian byte order.
Converts a color into a byte array with big endian byte order.
Converts a color into a byte array with native byte order.
Casts the value.
pub fn vzip(self) -> VCasts the value.