Embedded graphics 0.5.0
Version 0.5.0 is released! This is a pretty big one, focussed around ergonomics. There are new
macros to make drawing and positioning primitives and text much less noisy, as well as changes to
the Drawing
trait to remove the explicit .into_iter()
call when passing objects to it.
Embedded Graphics is a no_std library for adding graphics features to display drivers. It aims to use the minimum amount of memory for builtin graphics objects by leveraging Rust's iterators to avoid large allocations. It targets embedded environments, but can run anywhere like a Raspberry Pi up to full desktop machines.
Here's a copy of the changelog:
Added
-
Add
SizedDrawing
trait. This is useful for displays that support partial screen updates. If the passed object has known dimensions (via theDimensions
) trait, a smaller draw area can be specified, reducing the number of bytes sent over the wire. This also opens up the possibility of bufferless display drivers! -
Macros for primitives, text,
UnsignedCoord
andCoord
! This should make graphics-heavy code much quicker to write, and much cleaner to read. For example, to create a line and a circle:Code that looked like this:
display.draw; display.draw; display.draw; display.draw;
Now looks like this:
display.draw; display.draw; display.draw; display.draw;
-
Added
pixelcolor::RGB565
to make working with displays and images in the common RGB565 pixel format.
Changed
-
Drawing#draw
now acceptsIntoIterator
instead ofIter
.This is a breaking change for driver implementors. Client code should still be fine, as
.into_iter()
can still be called.This allows passing of embedded_graphics objects without having to explicitly call
.into_iter
:// Before (still works) display.draw; // After display.draw;
This also means that objects can be passed by reference too:
let circle = new; display.draw; // Reuse `circle` here
-
(breaking) All
with_<prop>()
style methods are replaced by their unprefixed<prop>()
counterparts - #106with_style()
->style()
with_stroke()
->stroke()
with_stroke_width()
->stroke_width()
with_fill()
->fill()
-
(breaking)
ImageBMP
andImageTGA
are now disabled by default behind Cargo features- Get
ImageBMP
by adding thebmp
feature to yourCargo.toml
- Get
ImageTGA
by adding thetga
feature to yourCargo.toml
- Get
-
(breaking) fonts now render with a transparent background by default. To get the old behaviour back, add a
fill
like this:// Without macros render_str.fill; // With macros text_6x8!;
-
Added a bunch of examples and docs. I hope it makes the crate easier to use! Please open an issue if anything is missing or hard to understand.
-
The builtin simulator now supports colour pixel types, like
RGB565
. -
From
is implemented for a few more types forCoord
andUnsignedCoord
. Among other things, they can now be converted to tuples by calling.into()
.
Deprecated
- None
Removed
- (breaking)
PixelColorU*
types. Use vanillau8
,u16
oru32
instead.PixelColorU8
->u8
PixelColorU16
->u16
PixelColorU32
->u32
- (breaking) The deprecated
.dimensions()
method for fonts is replaced by the.size()
method from theWithStyle
trait. This makes fonts consistent with other embedded-graphics objects
Fixed
-
Circles with no stroke but
Some(...)
fill are now rendered instead of skipped. -
Embedded graphics objects can now be returned from functions, chained or not. For example:
Security
- None