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§
Implementations§
Source§impl 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§
Source§impl Clone for BinaryColor
impl Clone for BinaryColor
Source§fn clone(&self) -> BinaryColor
fn clone(&self) -> BinaryColor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl ColorMapping<BinaryColor> for BinaryColor
impl ColorMapping<BinaryColor> for BinaryColor
Source§fn char_to_color(c: char) -> Self
fn char_to_color(c: char) -> Self
C
.Source§fn color_to_char(color: BinaryColor) -> char
fn color_to_char(color: BinaryColor) -> char
C
into a char.Source§impl Debug for BinaryColor
impl Debug for BinaryColor
Source§impl Default for BinaryColor
impl Default for BinaryColor
Source§impl From<BinaryColor> for Bgr555
impl From<BinaryColor> for Bgr555
Source§fn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Source§impl From<BinaryColor> for Bgr565
impl From<BinaryColor> for Bgr565
Source§fn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Source§impl From<BinaryColor> for Bgr888
impl From<BinaryColor> for Bgr888
Source§fn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Source§impl From<BinaryColor> for Gray2
impl From<BinaryColor> for Gray2
Source§fn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Source§impl From<BinaryColor> for Gray4
impl From<BinaryColor> for Gray4
Source§fn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Source§impl From<BinaryColor> for Gray8
impl From<BinaryColor> for Gray8
Source§fn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Source§impl From<BinaryColor> for RawU1
impl From<BinaryColor> for RawU1
Source§fn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Source§impl From<BinaryColor> for Rgb555
impl From<BinaryColor> for Rgb555
Source§fn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Source§impl From<BinaryColor> for Rgb565
impl From<BinaryColor> for Rgb565
Source§fn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Source§impl From<BinaryColor> for Rgb888
impl From<BinaryColor> for Rgb888
Source§fn from(color: BinaryColor) -> Self
fn from(color: BinaryColor) -> Self
Source§impl From<RawU1> for BinaryColor
impl From<RawU1> for BinaryColor
Source§impl From<bool> for BinaryColor
impl From<bool> for BinaryColor
Source§impl Hash for BinaryColor
impl Hash for BinaryColor
Source§impl Ord for BinaryColor
impl Ord for BinaryColor
Source§fn cmp(&self, other: &BinaryColor) -> Ordering
fn cmp(&self, other: &BinaryColor) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for BinaryColor
impl PartialEq for BinaryColor
Source§impl PartialOrd for BinaryColor
impl PartialOrd for BinaryColor
Source§impl PixelColor for BinaryColor
impl PixelColor for BinaryColor
impl Copy for BinaryColor
impl Eq for BinaryColor
impl StructuralPartialEq for BinaryColor
Auto Trait Implementations§
impl Freeze for BinaryColor
impl RefUnwindSafe for BinaryColor
impl Send for BinaryColor
impl Sync for BinaryColor
impl Unpin for BinaryColor
impl UnwindSafe for BinaryColor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<C> IntoStorage for C
impl<C> IntoStorage for C
Source§type Storage = <<C as PixelColor>::Raw as RawData>::Storage
type Storage = <<C as PixelColor>::Raw as RawData>::Storage
Source§fn into_storage(self) -> <C as IntoStorage>::Storage
fn into_storage(self) -> <C as IntoStorage>::Storage
PixelColor
into its raw storage formLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 1 byte
Size for each variant:
Off
: 0 bytesOn
: 0 bytes