[−][src]Enum embedded_graphics::pixelcolor::BinaryColor
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.
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]
fn clone(&self) -> BinaryColor[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl ColorMapping<BinaryColor> for BinaryColor[src]
fn char_to_color(c: char) -> Self[src]
fn color_to_char(color: BinaryColor) -> char[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]
fn from(color: BinaryColor) -> Self[src]
impl From<BinaryColor> for Rgb555[src]
fn from(color: BinaryColor) -> Self[src]
impl From<BinaryColor> for Bgr555[src]
fn from(color: BinaryColor) -> Self[src]
impl From<BinaryColor> for Rgb565[src]
fn from(color: BinaryColor) -> Self[src]
impl From<BinaryColor> for Bgr565[src]
fn from(color: BinaryColor) -> Self[src]
impl From<BinaryColor> for Rgb888[src]
fn from(color: BinaryColor) -> Self[src]
impl From<BinaryColor> for Bgr888[src]
fn from(color: BinaryColor) -> Self[src]
impl From<BinaryColor> for Gray2[src]
fn from(color: BinaryColor) -> Self[src]
impl From<BinaryColor> for Gray4[src]
fn from(color: BinaryColor) -> Self[src]
impl From<BinaryColor> for Gray8[src]
fn from(color: BinaryColor) -> Self[src]
impl From<RawU1> for BinaryColor[src]
impl From<bool> for BinaryColor[src]
impl Hash for BinaryColor[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl Ord for BinaryColor[src]
fn cmp(&self, other: &BinaryColor) -> Ordering[src]
#[must_use]
fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]
fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]
fn clamp(self, min: Self, max: Self) -> Self[src]
impl PartialEq<BinaryColor> for BinaryColor[src]
fn eq(&self, other: &BinaryColor) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialOrd<BinaryColor> for BinaryColor[src]
fn partial_cmp(&self, other: &BinaryColor) -> Option<Ordering>[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl PixelColor for BinaryColor[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<C> IntoStorage for C where
C: PixelColor,
<C as PixelColor>::Raw: From<C>, [src]
C: PixelColor,
<C as PixelColor>::Raw: From<C>,
type Storage = <<C as PixelColor>::Raw as RawData>::Storage
The underlying storage type for the pixel color
fn into_storage(Self) -> <C as IntoStorage>::Storage[src]
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]
T: PartialEq<T> + Copy + Any + Debug,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,