Trait embedded_graphics::image::ImageDrawable

source ·
pub trait ImageDrawable: OriginDimensions {
    type Color: PixelColor;

    // Required methods
    fn draw<D>(&self, target: &mut D) -> Result<(), <D as DrawTarget>::Error>
       where D: DrawTarget<Color = Self::Color>;
    fn draw_sub_image<D>(
        &self,
        target: &mut D,
        area: &Rectangle,
    ) -> Result<(), <D as DrawTarget>::Error>
       where D: DrawTarget<Color = Self::Color>;
}
Expand description

Image drawable.

ImageDrawable is implemented for types that contains image information, which makes them usable with the Image object.

The methods in this trait shouldn’t be called directly by user code. Instead the object that implements ImageDrawable should be wrapped in an Image object.

§Implementing ImageDrawable

All image drawables are positioned at the origin and need to implement OriginDimensions, in addition to this trait, to define their dimensions.

Required Associated Types§

source

type Color: PixelColor

The color type.

Required Methods§

source

fn draw<D>(&self, target: &mut D) -> Result<(), <D as DrawTarget>::Error>
where D: DrawTarget<Color = Self::Color>,

Draws the entire image to the target.

This method shouldn’t be called directly by user code. Use an Image object instead.

§Implementation notes

The implementation of this method must draw the image inside the bounding box defined by the OriginDimensions trait implementation. This means that the top left corner is at the origin and no drawing operations outside the bounding box are allowed.

source

fn draw_sub_image<D>( &self, target: &mut D, area: &Rectangle, ) -> Result<(), <D as DrawTarget>::Error>
where D: DrawTarget<Color = Self::Color>,

Draws a part of the image to the target.

This method shouldn’t be called directly by user code. Use a SubImage object instead.

§Implementation notes

The implementation of this method must draw the image inside the given area. It must be ensured that no drawing operation outside this Rectangle occur.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, C, BO> ImageDrawable for ImageRaw<'a, C, BO>
where C: PixelColor + From<<C as PixelColor>::Raw>, BO: ByteOrder, RawDataSlice<'a, C::Raw, BO>: IntoIterator<Item = C::Raw>,

§

type Color = C

source§

impl<'a, T> ImageDrawable for SubImage<'a, T>
where T: ImageDrawable,

§

type Color = <T as ImageDrawable>::Color