Embedded graphics
Documentation
A small 2D graphics library to draw things on embedded graphical LCDs, like the SSD1306 OLED display.
This crate aims to make drawing 2D graphics primitives super easy. It currently supports the following:
- 1 bit-per-pixel images
- 8 bit-per-pixel images (downsampled to 1BPP currently)
- Primitives
- Lines
- Rectangles (and squares)
- Circles
- Text with a 6x8 pixel font
A core goal is to do the above without using any buffers; the crate should work without a
dynamic memory allocator and without pre-allocating large chunks of memory. To achieve this, it
takes an Iterator
based approach, where pixel values 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.
To use this crate in a driver, you only need to implement the Drawing
trait to start drawing
things.
You can also add your own objects by implementing IntoIterator<Item = Pixel>
to create an
iterator that Drawable#draw()
can consume.
It currently only supports monochrome displays. Contributions to support full colour as well are very welcome!
Example usage from the SSD1306 driver:
extern crate cortex_m;
extern crate embedded_graphics;
extern crate embedded_hal as hal;
extern crate panic_abort;
extern crate ssd1306;
extern crate stm32f103xx_hal as blue_pill;
use ;
use *;
use Image1BPP;
use *;
use ;
TODO
- General matrix transforms
- Full colour support
Attribution
All source font PNGs are taken from the excellent Uzebox Wiki page.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.