Expand description
embedded-canvas is a convenient crate for embedded-graphics
and provides a Canvas and CanvasAt on which you
can draw anything with ease before drawing the pixels on the embedded display.
canvas - a piece of cloth backed or framed as a surface for a painting
Based on embedded-graphics-core and embedded-graphics
(see transform feature in Crate features).
This crate is no_std and it has 2 sets of canvases:
CanvasandCanvasAt- requireallocfeatureCCanvasandCCanvasAt- do not requireallocfeature because they use const generics instead.
The main advantages of the canvases in this crate are:
- Transparency - pixels that haven’t been drawn, won’t override pixels on the display.

Example: Transparency - The canvas content (a circle) is drawn on the display where there’s already a drawn square.
- Cropping - The ability to crop leaves only the part of the canvas you want to draw on the display. This is especially useful when you want to partially show text, figures and images.

Example: Cropping text - The full canvas content is drawn on the left and only portion of it is cropped and drawn on the right.
§How to work with canvases
There are two main canvases you can work with:
§Canvas / CCanvas
A canvas which you can draw on with origin Point::zero().
The canvas location is not set for the provided display.
After drawing decide where to place it on the display using the methods:
Canvas::place_at(top_left: Point) -> CanvasAt(withallocfeature) orCCanvas::place_at(top_left: Point) -> CCanvasAtCanvas::place_center(center: Point) -> CanvasAt(withallocfeature) orCCanvas::place_center(center: Point) -> CCanvasAt
§CanvasAt / CCanavasAt
CanvasAt/CCanvasAt is a type of canvas ready to be drawn on the display
at specified location (hence the name CanvasAt/CCanvasAt).
There are two ways of using CanvasAt/CCanvasAt:
- Directly placing the
CanvasAt/CCanvasAton specified location on the display and drawing inside. - Create a
Canvas/CCanvasand when ready to draw it on the display place theCanvas/CCanvasat specified location using the methods:Canvas::place_at(top_left: Point) -> CanvasAt(withallocfeature) andCCanvas::place_at(top_left: Point) -> CCanvasAtCanvas::place_center(center: Point) -> CanvasAt(withallocfeature) andCCanvas::place_center(center: Point) -> CCanvasAt
§Crate features
defaultfeatures -transformalloc- enablesCanvasandCanvasAt.transform- enables the trait implementation ofembedded_graphics::transform::TransformforCanvasAt/CCanvasAt.
Structs§
- CCanvas
- Canvas on which you can draw but it’s not drawable on the display yet. Implemented using const generics.
- CCanvas
At - Canvas which is drawable at the provided
Point(location) on the display. - Canvas
alloc - Canvas on which you can draw but it’s not drawable on the display yet.
- Canvas
At alloc - Canvas which is drawable at the provided
Point(location) on the display.