embedded_graphics::mock_display

Struct MockDisplay

Source
pub struct MockDisplay<C>(/* private fields */)
where
    C: PixelColor;
Expand description

Mock display struct

See the module documentation for usage and examples.

Implementations§

Source§

impl<C> MockDisplay<C>
where C: PixelColor,

Source

pub fn new() -> Self

Creates a new empty mock display.

Source

pub fn width(&self) -> usize

Returns the width of the display.

Source

pub fn height(&self) -> usize

Returns the height of the display.

Source

pub fn get_pixel(&self, p: Point) -> Option<C>

Returns the color of a pixel.

Source

pub fn set_pixel(&mut self, p: Point, color: Option<C>)

Changes the color of a pixel.

Source§

impl<C> MockDisplay<C>
where C: PixelColor + ColorMapping<C>,

Source

pub fn from_pattern(pattern: &[&str]) -> MockDisplay<C>

Creates a new mock display from a character pattern.

The color pattern is specified by a slice of string slices. Each string slice represents a row of pixels and every character a single pixel.

A space character in the pattern represents a pixel which wasn’t modified by any drawing routine and is left in the default state. All other characters are converted by implementations of the ColorMapping trait.

Trait Implementations§

Source§

impl<C> Clone for MockDisplay<C>
where C: PixelColor + Clone,

Source§

fn clone(&self) -> MockDisplay<C>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C> Debug for MockDisplay<C>
where C: PixelColor + ColorMapping<C>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C> Default for MockDisplay<C>
where C: PixelColor,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<C> DrawTarget<C> for MockDisplay<C>
where C: PixelColor,

Source§

type Error = Infallible

Error type to return when a drawing operation fails. Read more
Source§

fn draw_pixel(&mut self, pixel: Pixel<C>) -> Result<(), Self::Error>

Draws a pixel on the display.
Source§

fn size(&self) -> Size

Returns the dimensions of the DrawTarget in pixels.
Source§

fn draw_iter<T>(&mut self, item: T) -> Result<(), Self::Error>
where T: IntoIterator<Item = Pixel<C>>,

Draws an object from an iterator over its pixels.
Source§

fn clear(&mut self, color: C) -> Result<(), Self::Error>
where Self: Sized,

Clears the display with the supplied color. Read more
Source§

fn draw_line( &mut self, item: &Styled<Line, PrimitiveStyle<C>>, ) -> Result<(), Self::Error>

Draws a styled line primitive. Read more
Source§

fn draw_triangle( &mut self, item: &Styled<Triangle, PrimitiveStyle<C>>, ) -> Result<(), Self::Error>

Draws a styled triangle primitive. Read more
Source§

fn draw_rectangle( &mut self, item: &Styled<Rectangle, PrimitiveStyle<C>>, ) -> Result<(), Self::Error>

Draws a styled rectangle primitive. Read more
Source§

fn draw_circle( &mut self, item: &Styled<Circle, PrimitiveStyle<C>>, ) -> Result<(), Self::Error>

Draws a styled circle primitive. Read more
Source§

fn draw_image<'a, 'b, I>( &mut self, item: &'a Image<'b, I, C>, ) -> Result<(), Self::Error>

Draws an image with known size Read more
Source§

impl<C> PartialEq for MockDisplay<C>
where C: PixelColor,

Source§

fn eq(&self, other: &MockDisplay<C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<C> Copy for MockDisplay<C>
where C: PixelColor + Copy,

Auto Trait Implementations§

§

impl<C> Freeze for MockDisplay<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for MockDisplay<C>
where C: RefUnwindSafe,

§

impl<C> Send for MockDisplay<C>
where C: Send,

§

impl<C> Sync for MockDisplay<C>
where C: Sync,

§

impl<C> Unpin for MockDisplay<C>
where C: Unpin,

§

impl<C> UnwindSafe for MockDisplay<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.