pub struct SimulatorDisplay<C> { /* private fields */ }
Expand description
Simulator display.
Implementations§
source§impl<C: PixelColor> SimulatorDisplay<C>
impl<C: PixelColor> SimulatorDisplay<C>
sourcepub fn with_default_color(size: Size, default_color: C) -> Self
pub fn with_default_color(size: Size, default_color: C) -> Self
Creates a new display filled with a color.
This constructor can be used if C
doesn’t implement From<BinaryColor>
or another
default color is wanted.
sourcepub fn diff(
&self,
other: &SimulatorDisplay<C>,
) -> Option<SimulatorDisplay<BinaryColor>>
pub fn diff( &self, other: &SimulatorDisplay<C>, ) -> Option<SimulatorDisplay<BinaryColor>>
Compares the content of this display with another display.
If both displays are equal None
is returned, otherwise a difference image is returned.
All pixels that are different will be filled with BinaryColor::On
and all equal pixels
with BinaryColor::Off
.
§Panics
Panics if the both display don’t have the same size.
source§impl<C> SimulatorDisplay<C>
impl<C> SimulatorDisplay<C>
source§impl<C> SimulatorDisplay<C>
impl<C> SimulatorDisplay<C>
sourcepub fn to_rgb_output_image(
&self,
output_settings: &OutputSettings,
) -> OutputImage<Rgb888>
pub fn to_rgb_output_image( &self, output_settings: &OutputSettings, ) -> OutputImage<Rgb888>
Converts the display contents into a RGB output image.
§Examples
use embedded_graphics::{pixelcolor::Rgb888, prelude::*};
use embedded_graphics_simulator::{OutputSettingsBuilder, SimulatorDisplay};
let output_settings = OutputSettingsBuilder::new().scale(2).build();
let display = SimulatorDisplay::<Rgb888>::new(Size::new(128, 64));
// draw something to the display
let output_image = display.to_rgb_output_image(&output_settings);
assert_eq!(output_image.size(), Size::new(256, 128));
// use output image:
// example: output_image.save_png("out.png")?;
sourcepub fn to_grayscale_output_image(
&self,
output_settings: &OutputSettings,
) -> OutputImage<Gray8>
pub fn to_grayscale_output_image( &self, output_settings: &OutputSettings, ) -> OutputImage<Gray8>
Converts the display contents into a grayscale output image.
§Examples
use embedded_graphics::{pixelcolor::Gray8, prelude::*};
use embedded_graphics_simulator::{OutputSettingsBuilder, SimulatorDisplay};
let output_settings = OutputSettingsBuilder::new().scale(2).build();
let display = SimulatorDisplay::<Gray8>::new(Size::new(128, 64));
// draw something to the display
let output_image = display.to_grayscale_output_image(&output_settings);
assert_eq!(output_image.size(), Size::new(256, 128));
// use output image:
// example: output_image.save_png("out.png")?;
source§impl<C> SimulatorDisplay<C>
impl<C> SimulatorDisplay<C>
sourcepub fn to_be_bytes(&self) -> Vec<u8>
pub fn to_be_bytes(&self) -> Vec<u8>
Converts the display content to big endian raw data.
sourcepub fn to_le_bytes(&self) -> Vec<u8>
pub fn to_le_bytes(&self) -> Vec<u8>
Converts the display content to little endian raw data.
sourcepub fn to_ne_bytes(&self) -> Vec<u8>
pub fn to_ne_bytes(&self) -> Vec<u8>
Converts the display content to native endian raw data.
source§impl<C> SimulatorDisplay<C>
impl<C> SimulatorDisplay<C>
sourcepub fn load_png<P: AsRef<Path>>(path: P) -> ImageResult<Self>
pub fn load_png<P: AsRef<Path>>(path: P) -> ImageResult<Self>
Loads a PNG file.
Trait Implementations§
source§impl<C: Clone> Clone for SimulatorDisplay<C>
impl<C: Clone> Clone for SimulatorDisplay<C>
source§fn clone(&self) -> SimulatorDisplay<C>
fn clone(&self) -> SimulatorDisplay<C>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<C: Debug> Debug for SimulatorDisplay<C>
impl<C: Debug> Debug for SimulatorDisplay<C>
source§impl<C: PixelColor> DrawTarget for SimulatorDisplay<C>
impl<C: PixelColor> DrawTarget for SimulatorDisplay<C>
§type Error = Infallible
type Error = Infallible
source§fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
source§fn fill_contiguous<I>(
&mut self,
area: &Rectangle,
colors: I,
) -> Result<(), Self::Error>where
I: IntoIterator<Item = Self::Color>,
fn fill_contiguous<I>(
&mut self,
area: &Rectangle,
colors: I,
) -> Result<(), Self::Error>where
I: IntoIterator<Item = Self::Color>,
source§impl<C: Hash> Hash for SimulatorDisplay<C>
impl<C: Hash> Hash for SimulatorDisplay<C>
source§impl<C: Ord> Ord for SimulatorDisplay<C>
impl<C: Ord> Ord for SimulatorDisplay<C>
source§fn cmp(&self, other: &SimulatorDisplay<C>) -> Ordering
fn cmp(&self, other: &SimulatorDisplay<C>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<C> OriginDimensions for SimulatorDisplay<C>
impl<C> OriginDimensions for SimulatorDisplay<C>
source§impl<C: PartialEq> PartialEq for SimulatorDisplay<C>
impl<C: PartialEq> PartialEq for SimulatorDisplay<C>
source§impl<C: PartialOrd> PartialOrd for SimulatorDisplay<C>
impl<C: PartialOrd> PartialOrd for SimulatorDisplay<C>
impl<C: Eq> Eq for SimulatorDisplay<C>
impl<C> StructuralPartialEq for SimulatorDisplay<C>
Auto Trait Implementations§
impl<C> Freeze for SimulatorDisplay<C>
impl<C> RefUnwindSafe for SimulatorDisplay<C>where
C: RefUnwindSafe,
impl<C> Send for SimulatorDisplay<C>where
C: Send,
impl<C> Sync for SimulatorDisplay<C>where
C: Sync,
impl<C> Unpin for SimulatorDisplay<C>
impl<C> UnwindSafe for SimulatorDisplay<C>where
C: UnwindSafe,
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> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Dimensions for Twhere
T: OriginDimensions,
impl<T> Dimensions for Twhere
T: OriginDimensions,
source§fn bounding_box(&self) -> Rectangle
fn bounding_box(&self) -> Rectangle
source§impl<T> DrawTargetExt for Twhere
T: DrawTarget,
impl<T> DrawTargetExt for Twhere
T: DrawTarget,
source§fn translated(&mut self, offset: Point) -> Translated<'_, T>
fn translated(&mut self, offset: Point) -> Translated<'_, T>
source§fn cropped(&mut self, area: &Rectangle) -> Cropped<'_, T>
fn cropped(&mut self, area: &Rectangle) -> Cropped<'_, T>
source§fn clipped(&mut self, area: &Rectangle) -> Clipped<'_, T>
fn clipped(&mut self, area: &Rectangle) -> Clipped<'_, T>
source§fn color_converted<C>(&mut self) -> ColorConverted<'_, T, C>
fn color_converted<C>(&mut self) -> ColorConverted<'_, T, C>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more