A no_std graphics library for embedded applications
A no_std graphics library for embedded applications
Embedded-graphics is a 2D graphics library that is focused on memory constrained embedded devices.
A core goal of embedded-graphics is to draw graphics without using any buffers; the crate is
no_std compatible and works without a dynamic memory allocator, and without pre-allocating
large chunks of memory. To achieve this, it takes an Iterator based approach, where pixel
colors and positions are calculated on the fly, with the minimum of saved state. This allows the
consuming application to use far less RAM at little to no performance penalty.
It contains built in items that make it easy to draw 2D graphics primitives:
Embedded-graphics is designed to be extended by the application or other crates. Examples of this are adding support for different image formats or implementing custom fonts.
tinybmptinytgatinyqoiembedded-graphics-profontu8g2-fontsprofontembedded-picofontembedded-mogeefontibm437embedded-graphics 0.6 - embedded-vintage-fontsembedded-ttfembedded-layoutembedded-textembedded-plotseg-seven-segmentembedded-canvasembedded-fpsembedded-graphics-framebufembedded-rgbaminitypeBinaryColor image format - embedded-mono-imgBinaryColor images to other colors (with transparency support) - embedded-graphics-colorcastmousefoodembedded-graphics-unicodefontsNote that some of these crates may not support the latest version of embedded-graphics.
If you know of a crate that is not in this list, please open an issue to add it.
To support many different kinds of display, embedded-graphics doesn't include any drivers
directly but provides the DrawTarget API in [embedded-graphics-core] that can be
implemented by external crates. In addition to the drivers for real displays, the
simulator can be used to test code during
development.
These are just some of the displays the community has added embedded-graphics support to. This list is taken from the dependent crates list on crates.io so might be missing some unpublished entries. Please open an issue if there's a display driver that should be added to this list.
Note that some drivers may not support the latest version of embedded-graphics.
Embedded graphics comes with a [simulator]! The simulator can be used to test and debug embedded graphics code, or produce examples and interactive demos to show off embedded graphics features.
Take a look at the examples repository to see what embedded-graphics can do, and how it might look on a display. You can run the examples like this:
git clone https://github.com/embedded-graphics/examples.git
cd examples/eg-0.7
cargo run --example hello-worldAdditional features can be enabled by adding the following features to your Cargo.toml.
nalgebra_support - use the Nalgebra crate with no_std
support to enable conversions from nalgebra::Vector2 to Point and Size.
fixed_point - use fixed point arithmetic instead of floating point for all trigonometric
calculation.
defmt - provide implementations of defmt::Format for all types where possible. [defmt]
is a library for logging that moves as much work as possible over to a separate logging
machine, making it especially suited to low-resource MCUs. Note that defmt might not work with
older versions of rustc that are otherwise supported by embedded-graphics.
embedded_graphics support for a display driverTo add support for embedded-graphics to a display driver, DrawTarget from
[embedded-graphics-core] must be implemented. This allows all embedded-graphics items to be
rendered by the display. See the DrawTarget documentation for implementation details.
Example usage of drawing primitives, text and images with embedded-graphics can be found here.
The following example draws some shapes and text to a FrameBuffer
in place of target hardware. The simulator can also be used for
debugging, development or if hardware is not available.
…This example is also included in the examples repository and
can be run using cargo run --example hello-world. It produces this output:
Additional examples can be found in the examples repository.
No open issues yet, or sync has not completed.