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§
sourcetype Color: PixelColor
type Color: PixelColor
The color type.
Required Methods§
sourcefn draw<D>(&self, target: &mut D) -> Result<(), <D as DrawTarget>::Error>where
D: DrawTarget<Color = Self::Color>,
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.
sourcefn draw_sub_image<D>(
&self,
target: &mut D,
area: &Rectangle,
) -> 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>,
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.