[][src]Enum embedded_graphics::pixelcolor::BinaryColor

pub enum BinaryColor {
    Off,
    On,
}

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.

Methods

impl BinaryColor[src]

pub fn invert(self) -> Self[src]

Inverts the color.

Examples

use embedded_graphics::pixelcolor::BinaryColor;

assert_eq!(BinaryColor::Off.invert(), BinaryColor::On);
assert_eq!(BinaryColor::On.invert(), BinaryColor::Off);

pub fn is_on(self) -> bool[src]

Returns true if this color is On.

Examples

use embedded_graphics::pixelcolor::BinaryColor;

assert!(BinaryColor::On.is_on());

pub fn is_off(self) -> bool[src]

Returns true if this color is Off.

Examples

use embedded_graphics::pixelcolor::BinaryColor;

assert!(BinaryColor::Off.is_off());

Trait Implementations

impl Clone for BinaryColor[src]

impl ColorMapping<BinaryColor> for BinaryColor[src]

impl Copy for BinaryColor[src]

impl Debug for BinaryColor[src]

impl Default for BinaryColor[src]

impl Eq for BinaryColor[src]

impl From<BinaryColor> for RawU1[src]

impl From<BinaryColor> for Rgb555[src]

impl From<BinaryColor> for Bgr555[src]

impl From<BinaryColor> for Rgb565[src]

impl From<BinaryColor> for Bgr565[src]

impl From<BinaryColor> for Rgb888[src]

impl From<BinaryColor> for Bgr888[src]

impl From<BinaryColor> for Gray2[src]

impl From<BinaryColor> for Gray4[src]

impl From<BinaryColor> for Gray8[src]

impl From<RawU1> for BinaryColor[src]

impl From<bool> for BinaryColor[src]

impl Hash for BinaryColor[src]

impl Ord for BinaryColor[src]

impl PartialEq<BinaryColor> for BinaryColor[src]

impl PartialOrd<BinaryColor> for BinaryColor[src]

impl PixelColor for BinaryColor[src]

type Raw = RawU1

Raw data type. Read more

impl StructuralEq for BinaryColor[src]

impl StructuralPartialEq for BinaryColor[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<C> IntoStorage for C where
    C: PixelColor,
    <C as PixelColor>::Raw: From<C>, 
[src]

type Storage = <<C as PixelColor>::Raw as RawData>::Storage

The underlying storage type for the pixel color

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: PartialEq<T> + Copy + Any + Debug
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,