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.
Unreleased - ReleaseDate
- #592 Add support for defmt behind a feature (
defmt
). - #612, #699 Added
GetPixel
trait and implementations forImageRaw
andFramebuffer
. - #621 Added
Rgb666
andBgr666
color type support. - #641 Added
Line::with_delta
constructor. - #656 Added
Rgb666
andBgr666
conversions. - #673 Added
Framebuffer
. - #709 Added
Image::with_center
. - #710 Added
AnchorX
,AnchorY
,AnchorPoint::x
,AnchorPoint::y
andAnchorPoint::from_xy
. - #710 Added
Rectangle::resized_width
,Rectangle::resized_height
,Rectangle::anchor_x
andRectangle::anchor_y
.
- (breaking) #660 Remove
RawU18
color storage type and useRawU24
in is place forRgb666
andBgr666
. - #639 Made the following functions
const
: - (breaking) #690 Remove
ImageRaw::new_binary
const
helper method.ImageRaw::new
can now be used inconst
contexts, so use it instead ofnew_binary
. - #639, #690 Made the following functions
const
:Point::component_mul
Point::component_div
Size::saturating_add
Size::saturating_sub
Size::component_mul
Size::component_div
BinaryColor::invert
BinaryColor::is_on
BinaryColor::is_off
Rectangle::with_center
Rectangle::is_zero_sized
RawDataSlice::new
MonoTextStyle::new
Arc::with_center
Arc::from_circle
Arc::to_circle
Circle::with_center
Ellipse::with_center
Sector::with_center
Sector::from_circle
Sector::to_circle
Styled::new
ImageRaw::new
ImageRaw::data_width
Image::new
FancyDisplay::new
MockDisplay::get_pixel
MonoFont::mime
MonoFont::glyph_mapping
MonoTextStyleBuilder::new
MonoTextStyleBuilder::text_color
MonoTextStyleBuilder::background_color
MonoTextStyleBuilder::underline_with_color
MonoTextStyleBuilder::strikethrough_with_color
MonoTextStyleBuilder::build
Ellipse::new
Ellipse::contains
PrimitiveStyle::new
PrimitiveStyle::with_stroke
PrimitiveStyle::with_fill
PrimitiveStyle::is_transparent
PrimitiveStyleBuilder::new
PrimitiveStyleBuilder::fill_color
PrimitiveStyleBuilder::reset_fill_color
PrimitiveStyleBuilder::stroke_color
PrimitiveStyleBuilder::reset_stroke_color
PrimitiveStyleBuilder::stroke_width
PrimitiveStyleBuilder::stroke_alignment
PrimitiveStyleBuilder::build
DecorationColor::is_none
DecorationColor::is_text_color
DecorationColor::is_custom
- #651, #652 Improved performance of color conversions.
- #653 Don't ignore trailing newlines in
Text
. - #662
ImageRaw::new
no longer panics ifwidth == 0
. - (breaking) #688
MonoFont
is nowSend + Sync
; implementations ofGlyphMapping
must beSync
. - (breaking) #663 Upgraded Cargo dependencies to their latest versions.
- (breaking) #689 Bump Minimum Supported Rust Version (MSRV) to 1.61.
- (breaking) #715 Changed the direction of angles. Positive angles are now clockwise.
- #648 Fixed incorrect text bounding box calculation when multi-byte characters are used.
- #713 Fixed possible panic when drawing an invalid
MonoFont
.
0.7.1 - 2021-06-15
- #606 Bump minimum embedded-graphics-core version from
0.3.0
to0.3.2
0.7.0 - 2021-06-05
- #602 Implemented
core::fmt::Display
forPoint
andSize
.
- (breaking) - #600 Renamed
Mapping::all
toMapping::iter
. - (breaking) - #603
MockDisplay::eq
was replaced by aPartialEq
implementation forMockDisplay
.
- (breaking) - #604 Removed incomplete JIS X 0201 fonts.
0.7.0-beta.2 - 2021-05-24
- #587 Added
From<&TextStyle>
impl forTextStyleBuilder
andFrom<&MonoFont>
forMonoFontBuilder
. - #589 Implemented
From
trait to convert from RGB colors to grayscale colors, between different grayscale colors and from grayscale and RGB colors toBinaryColor
.
- (breaking) - #596 Added more ISO8859 glyph subsets as well as JIS_X0201 for bundled
MonoFont
s, supporting more languages. Thelatin1
subset was renamed toiso_8859_1
.
0.7.0-beta.1 - 2021-04-19
- (breaking) #552 Added the
Output
associated type toDrawable
to allow returning non-()
values from drawing operations. - #563 Added
is_none
,is_text_color
andis_custom
methods toDecorationColor
. - #563 Added
is_transparent
methods toPrimitiveStyle
andMonoTextStyle
. - #569 Added a
line_height
field toTextStyle
. - #571 Added
MockDisplay::set_pixels
to set pixels from an iterator. - #572 Added
ImageRaw::new_binary
to createconst
images with binary image data. - #576 Added reset methods for color settings to
MonoTextStyleBuilder
andPrimitiveStyleBuilder
. - #582 Added
StyledDrawable
,StyledDimensions
andStyledPixels
traits.
- (breaking) #561 Renamed
HorizontalAlignment
andVerticalAlignment
toAlignment
andBaseline
. - (breaking) #561 Replaced
TextRenderer::vertical_offset
bybaseline
arguments for the otherTextRenderer
methods. - (breaking) #563 The bounding boxes returned by
Dimensions
implementations for styled primitives no longer depend on the fill and stroke color. - (breaking) #563 Drawing a primitive with a transparent stroke (
stroke_color == None && stroke_width > 0
) will now reduce the filled area. - (breaking) #566 The
Drawable::Output
type was changed toPoint
for styledText
objects. The returned point can be used to chain texts with different styles. - (breaking) #569 Moved the text rendering API into a separate
text::renderer
submodule. - (breaking) #569 The
non_exhaustive
attribute was added to theTextStyle
struct. - (breaking) #571 Added color argument to
MockDisplay::from_points
to make it usable for all color types. - (breaking) #572 Removed the
height
argument fromImageRaw::new
. Theheight
is now calculated based on the width and data length. - (breaking) #572 Replaced
pixelcolor::raw::RawDataIter
by the types in theiterator::raw
module. - (breaking) #573 Changed
MonoFont
from a trait to a struct. - (breaking) #580 Changed
Text
to directly contain the styling information without needing aStyled
wrapper. - (breaking) #580 Removed
character_style
fromTextStyle
. Character and text style can now be set independently in theText
object. - (breaking) #580 Moved
Styled
from the crate root to theprimitives
module.
- (breaking) #582 Removed
iterator::IntoPixels
trait. UseStyled::pixels
instead.
- #571
Rectangle::points
did return a non empty iterator for rectangles with zero width.
0.7.0-alpha.3 - 2021-02-03
- #508 Added
MockDisplay::assert_eq_with_message
andMockDisplay::assert_pattern_with_message
. - #510 Added
vertical_alignment
andhorizontal_alignment
toMonoTextStyle
. - #510 Added
From
impl to convert an existingMonoTextStyle
into aMonoTextStyleBuilder
. - #523 Added support for underline and strikethrough attributes for
MonoTextStyle
.
- (breaking) #523 The external text renderer API was rewritten and the
TextStyle
trait was renamed toTextRenderer
. - (breaking) #523 The
fonts
module was split intotext
andmono_font
modules. - (breaking) #523 The vertical and horizontal alignment of
Text
objects must now be set using the newTextStyle
struct. - (breaking) #535 Replaced the builtin fonts with new fonts, that are generated from BDF files.
- (breaking) #538 The types inside the
style
module were moved to other locations and the module itself has been removed. - (breaking) #540 Renamed the
iterator::pixel::Translate
struct toTranslated
and thetranslate
method inPixelIteratorExt
totranslated
.
- (breaking) #508
MockDisplay
no longer implementsPartialEq
, useMockDisplay::assert_eq
instead. - (breaking) #509 Styled text can no longer be converted into a pixel iterator, because
IntoPixels
is no longer implemented forStyled<Text<'_>, S>
. - (breaking) #510
MonoTextStyleBuilder::new
no longer takes a font as an argument, useMonoTextStyleBuilder::new().font(SomeFont)
instead.
- #507 Fixed drawing of the join between the radial lines for sectors with a sweep angle close to 360°.
- #525
Triangle
s andPolyline
s with thick strokes would overdraw in some cases. - #527 Some cases where the ends of
Polyline
s would draw unwanted "spurs" are now fixed.
0.7.0-alpha.2 - 2020-11-29
- #386 Added
Line::midpoint
to get the midpoint of a line. - #386
Polyline
s can now be drawn with stroke widths greater than 1. - #386 Added the
delta
method toLine
to compute the difference between start and end points. - #450 Added
ColorConverted
andDrawTargetExt::color_converted
to support color conversion for draw targets. - #438 Added majority CSS web colors as associated
const
s to the RGB color types. - #470 Added support for external text renderers. External text renderers can be implemented using the new
TextStyle
trait. - #475
Triangle
s can now be drawn with stroke widths greater than 1. - #478 Added
resized
,anchor_point
,rows
,columns
andis_zero_sized
methods toRectangle
. - #493 Added
assert_eq
,assert_pattern
anddiff
methods toMockDisplay
. Improved error messages for failing assertions can be enabled by setting theEG_FANCY_PANIC
environment variable to1
at compile time. - #498 Added
Size::saturating_add
andSize::saturating_sub
.
- (breaking) #466 Upgrade Nalgebra from 0.19.0 to 0.23.0.
- (breaking) #470 Renamed
Font
,TextStyle
andTextStyleBuilder
toMonoFont
,MonoTextStyle
andMonoTextStyleBuilder
. - (breaking) #494 Triangle vertices are now stored in an array of 3 points, under the
vertices
field.
- (breaking) #470 Support for fonts with variable character width was removed from the internal text renderer.
- (breaking) #470
Font6x6
was removed. - (breaking) #494
Triangle::from_points
is removed. To create a triangle from a slice ofPoint
s, use the newTriangle::from_slice
method. - (breaking) #498
Primitive::from_points
is removed. Thepoints
method is now available on thePointsIter
trait, which must be implemented for allPrimitive
s.
- #477 Drawing a 90°
Arc
is now equal to drawing a quarter of a circle.
0.7.0-alpha.1 - 2020-09-19
- #307 Added
Primitive::points
to get an iterator over all points inside a primitive. - #317 Added
Rectangle::center
to get the center point of a rectangle. - #318 Added
ContainsPoint
trait to check if a point is inside a closed shape. - #320 Added the
Ellipse
primitive. - #333 Added
Rectangle::bottom_right
to get the bottom right corner of a rectangle. - #331 Added stroke alignment to
PrimitiveStyle
. - #331 Added
Rectangle::with_center
. - #331 Added
From<&PrimitiveStyle>
forPrimitiveStyleBuilder
. - #292 Added the
Polyline
primitive. - #337 Add
Point::x_axis
,Point::y_axis
,Size::x_axis
andSize::y_axis
. - #337 Add
Point::new_equal
andSize::new_equal
. - #336 Add
RoundedRectangle
primitive. - #353 Add
MockDisplay::swap_xy
method. - #357 Add
MockDisplay::map
method. - #357 Allow usage of all RGB color types in
MockDisplay
patterns. - #366 Allow usage of all grayscale color types in
MockDisplay
patterns. - #342 Added
Rectangle::intersection
method. - #363 Export
primitives::ContainsPoint
trait in prelude. - #310 Added the
Arc
primitive. - #310 Added the
Sector
primitive. - #398 Added
Point::length_squared
andcomponent_min
,component_max
,component_mul
andcomponent_div
forPoint
andSize
. - #400 Added
OffsetOutline
andStyledPrimitiveAreas
traits. - #409 Added
Clipped
,Cropped
andTranslated
draw targets. - #409 Added
OriginDimensions
trait for dimensions withtop_left == Point::zero()
. - #420 Added support for
SubImage
s. - #429 Added
ToBytes
trait to convert colors into byte arrays. - #431 Added
MockDisplay::affected_area
to get the area affected by previous drawing operations. - #439 Added support to render transparent characters with a colored background.
- #494 Add
Triangle::from_slice
to create a triangle from a slice ofPoint
s.
- (breaking) #274 The
Circle
is now defined by its bounding box top-left corner and its diameter instead of its center and its radius. To convert your code, you can replaceCircle::new(point, radius)
byCircle::with_center(point, 2 * radius + 1)
. - (breaking) #306 The
Rectangle
is now defined by its top-left corner and its size instead of the top-left and bottom-right corner. To convert your code, you can replaceRectangle::new
byRectangle::with_corners
. - (breaking) #312 The methods in the
Dimension
trait are replaced by a singlebounding_box
method that returns aRectangle
. - (breaking) #353 Lines with equal start and end points are now drawn by assuming they are oriented horizontally. This means that they are now drawn as a
stroke_width
high and 1px wide rectangle, instead of not being drawn at all. - (breaking) #353
primitives::line::StyledLineIterator
was renamed toprimitives::line::StyledIterator
. - (breaking) #357 Additional checks for overdraw and out of bounds drawing were added to
MockDisplay
which can cause tests to panic. See themock_display
module docs for more information. - (breaking) #342 Refactored the
DrawTarget
trait to better support common hardware capabilities. - (breaking) #360 Make the
drawable
module private.drawable::Drawable
anddrawable::Pixel
are now exported from the crate root. - (breaking) #390
Triangle.contains
now always returnsfalse
for colinear triangles. - (breaking) #393
DrawTarget::draw
now uses a reference toself
instead of taking ownership ofself
. Because of this changeDrawTarget
can no longer be implemented for pixel iterators (Iterator<Item = C>
), which can now be drawn using thedraw
method provided by thePixelIteratorExt
extension trait. - (breaking) #383 Replaced all
IntoIterator
impls with a customIntoPixels
trait. To get an iterator over pixels in an item, replace calls tointo_iter()
withinto_pixels()
. - (breaking) #403 Use an associated type to define the color type for
Drawable
s. - (breaking) #409
DrawTarget::size
was removed andDrawTarget
s are now required also implementDimensions
. - (breaking) #409 The
DrawTarget
trait was moved from the root of the crate to a newdraw_target
module. Projects that use theprelude
to importDrawTarget
won't be affected by this change. - (breaking) #420 To add support for additional image formats now
ImageDrawable
andOriginDimensions
needs to be implemented instead ofIntoPixelIterator
andImageDimensions
. - (breaking) #420 The color type parameter was removed from the
Image
struct and is now defined by the associatedColor
type of anImageDrawable
implementation.
- #317 The bounding box size for
Circle
s was off by one. - #401 Triangle pixel iterators no longer produce a pixel for each node twice.
- #431 Styled primitive bounding boxes now take the stroke width and alignment into account.
- (breaking) #351 Removed the
egtext!
,text_style!
andprimitive_style!
macros. Use theText
,TextStyleBuilder
andPrimitiveStyleBuilder
respectively instead. - (breaking) #351 Removed the
egcircle!
,egrectangle!
,egline!
andegtriangle!
macros.
0.6.2 - 2020-04-20
- #309 Prevent triangles with off-screen vertices from infinitely looping.
0.6.1 - 2020-04-01
- #285 Add multiplication and division by a scalar for
Point
andSize
.
- #271 Styled
Line
s are now drawn using thestroke_with
specified in thePrimitiveStyle
and no longer default to 1px width.
0.6.0 - 2020-03-20
- #269 Support for multiline text.
- #267 Added a
6x6
hand-drawn variable width font. - #267 Support for variable width fonts.
- #267 Fonts with CHARACTER_SPACING now properly render the background color between characters.
- #276 Fixed Chars like '°' and similar for
Font12x16
&Font24x32
0.6.0-beta.2 - 2020-03-06
- #262
Triangle
s with a fill color but no stroke color are now rendered instead of not rendered at all. - #262 A triangle with a different stroke and fill color now renders its left-most border with the stroke color, instead of fill color
- #262 Triangles and lines with a stroke width of 0 (and no fill for triangles) are no longer drawn.
- Added
draw_image
toDrawTarget
trait with default implementation.
0.6.0-beta.1 - 2020-02-17
-
#257 added the
.into_storage()
method onPixelColor
s via theIntoStorage
trait to allow for more ergonomic conversion from a color to its raw storage type.// IntoStorage is included in the prelude. // You can also import it with use embedded_graphics::pixelcolor::IntoStorage. + use embedded_graphics::prelude::*; - RawU1::from(color).into_inner() + color.into_storage()
-
Added as many
#[derive()]
s as possible to all embedded-graphics, tinybmp and tinytga types. -
Added
From<Point> for [i32; 2]
-
Added
From<Size> for [u32; 2]
-
Added the following fallible conversions to/from
Point
TryFrom<Point>
for(u32, u32)
TryFrom<(u32, u32)>
forPoint
TryFrom<Point>
for[u32; 2]
TryFrom<[u32; 2]>
forPoint
TryFrom<&[u32; 2]>
forPoint
-
#247 Added the
ImageData
trait. This trait can be implemented in an image format crate to add embedded-graphics support. -
#247 Added
Image
drawable. TheImage
drawable is used to make an implementation ofImageData
, e.g. fromtinytga
ortinybmp
, drawable to aDrawTarget
, like a display.
-
(breaking) #256 Make
PrimitiveStyleBuilder
andTextStyleBuilder
consuming by following the consuming builder pattern. -
(breaking) #247 The raw data
Image
struct is renamed toImageRaw
. TheImage
name is reused as a wrapper for other image types that implement theImageData
trait. -
(breaking) #247
ImageLE
andImageBE
are renamed toImageRawLE
andImageRawBE
respectively. -
(breaking) #247
ImageTga
andImageTga
are removed, along with their respective enabling featuresbmp
andtga
. To use BMP or TGA images, addtinybmp
ortinytga
to your dependencies with thegraphics
feature enabled. This allows usage ofBmp
andTga
in embedded-graphics contexts. Tinybmp or tinytga usage now looks like this:Cargo.toml
:[dependencies] embedded-graphics = "0.6.0" tinybmp = { version = "0.2.0", features = [ "graphics" ]}
Your code:
use embedded_graphics::{prelude::*, image::Image}; use tinybmp::Bmp; let image = Bmp::new(include_bytes!("../../../assets/patch.bmp")).unwrap(); let image = Image::new(&image); display.draw(&image);
-
(breaking) #243 All methods on
DrawTarget
that handle drawing to/updating the display are now fallible and returnResult<(), Self::Error>
to allow for error handling in user code. This also affectsDrawable::draw()
, which now propagates any errors that occur while drawing. -
(breaking) #243
DrawTarget::flush()
is removed. The display driver itself should provide this method if required. -
Expose
mock_display::MockDisplay
for use in tests, examples, etc in crates that pull embedded-graphics in as a dependency.
- #170 Added a
24x32
font based on the existing12x16
font.
-
#221 Implemented
Drawable
forPixel
to draw single pixels. -
#215 Added
PrimitiveStyleBuilder
. -
#215 Added
TextStyleBuilder
. -
#224 Added
Triangle::from_points
which accepts either[Point; 3]
, or an array of length 3 containing any item that implementsInto<Point>
.
- #143, #209 Circles with no stroke are now drawn correctly
-
(breaking) The
Drawable
trait now has a required trait methoddraw()
, which describes how the object will be drawn on the screen. See the docs for more details. -
(breaking) The
Drawing
trait has been renamed toDrawTarget
. The required trait method to implement has changed fromdraw()
todraw_pixel()
, and optional trait methods have been added to allow an implementing display driver to specify hardware-accelerated methods for drawing graphics primitives. -
(breaking) #161 The
.fill()
and.stroke()
style methods are renamed to.fill_color()
and.stroke_color()
respectively. This is to reduce confusion between names like.stroke()
and.stroke_width()
. Example:use embedded_graphics::{ prelude::*, primitives::Circle, egcircle }; let circle = Circle::new(Point::new(20, 20), 5) .stroke_width(10) .stroke_color(Some(BinaryColor::On)) .fill_color(Some(BinaryColor::Off));
-
(breaking) The type of
Style::stroke_width
changed fromu8
tou32
. -
(breaking) Primitives shapes need to be converted into
Styled
s to be drawn. -
(breaking) The primitive macros like
egline
don't accept astyle
setting anymore. Useobject.style = new_style
instead. -
(breaking) The
Style
struct was replaced byPrimitiveStyle
andTextStyle
.
- (breaking) Text rendering is now implemented using
Text
,TextStyle
andFont
objects instead of usingFont::render_str
.
-
(breaking) #224 Embedded Graphics macros now use named instead of positional parameters. Styling is now achieved using the
style
property which receives aPrimitiveStyle
for primitives, and aTextStyle
. There are convenience macros (primitive_style!()
andtext_style!()
respectively) to make styling objects easier.use embedded_graphics::{egcircle, egline, egrectangle, egtext, egtriangle, text_style}; // OLD egcircle!( (15, 20), 10, stroke = Some(Rgb565::RED), fill = Some(Rgb565::GREEN) ); // NEW egcircle!( center = (15, 20), radius = 10, style = primitive_style!(stroke = Rgb565::RED, fill = Rgb565::GREEN) ); // OLD egrectangle!( (0, 0), (64, 64), stroke = Some(Rgb565::RED), fill = Some(Rgb565::GREEN) ); // NEW egrectangle!( top_left = (0, 0), bottom_right = (64, 64), style = primitive_style!(stroke = Rgb565::RED, fill = Rgb565::GREEN) ); // OLD egtriangle!((32, 0), (0, 64), (64, 64)); // NEW egtriangle!( points = [(32, 0), (0, 64), (64, 64)], style = primitive_style!(stroke = Rgb565::RED, fill = Rgb565::GREEN) ); // OLD egline!((32, 0), (0, 64)); // NEW egline!( start = (32, 0), end = (0, 64), style = primitive_style!(stroke = Rgb565::RED,) ); // OLD egtext!("456", (10, 10), font = Font6x8, stroke = Some(Rgb565::RED)); // NEW egtext!( text = "456", top_left = (10, 10), style = text_style!(font = Font6x8, text_color = Rgb565::RED) );
- (breaking) The
SizedDrawing
trait is removed.
-
(breaking)
Coord
andUnsignedCoord
are replaced byPoint
andSize
. -
(breaking) The
Image
struct is removed from the prelude. Import it withuse embedded_graphics::image::Image
instead. -
(breaking) Integration with Nalgebra through the
nalgebra_support
feature is now achieved by converting Nalgebra types intoPoint
orSize
instead of Embedded Graphics aliasingPoint
andSize
tonalgebra::Vector2<i32>
andnalgebra::Vector2<u32>
respectively. Integration now requires callingPoint::from(my_nalgebra_var)
ormy_nalgebra_var.into()
.The benefit of this change is to allow more integer primitive types in
Vector2
. Embedded Graphics should now supportu8
,u16
andu32
conversions toSize
, andu8
,u16
,i8
,i16
andi32
conversions toPoint
. It also reduces coupling between Nalgebra and Embedded Graphics. -
(breaking)
Point
s can no longer be created from(u32, u32)
,[u32; 2]
or&[u32; 2]
; these conversions are dangerous as the full range ofu32
values cannot be represented by thei32
used for storage insidePoint
.
-
(breaking)
Pixel
now uses the signedPoint
type as the first element. Display drivers need to implement an additional check ifx
andy
are greater or equal to zero. -
(breaking) The image module has been rewritten to support big- and little-endian image formats.
Image1BPP
,Image8BPP
andImage16BPP
are no longer available, and have been replaced with the singleImage
type. To migrate from the previous image types, useImage
with a specified pixel color, like this:use embedded_graphics::{ image::Image, pixelcolor::{BinaryColor, Gray8, Rgb565} }; // Image1BPP let image: Image<BinaryColor> = Image::new(DATA, 12, 5); // Image8BPP let image: Image<Gray8> = Image::new(DATA, 12, 5); // Image16BPP let image: Image<Rgb565> = Image::new(DATA, 12, 5);
There are other pixel color types available. Take a look at the
pixelcolor
module for a full list.If you need to specify an endianness for the image data (like when using multiple bytes per pixel), the
ImageLE
andImageBE
type aliases have been added.
-
(breaking)
Coord::clamp_positive
is removed. -
(breaking) The
icoord!()
anducoord!()
macros are removed. UsePoint::new()
orSize::new()
respectively instead.
- The code examples
README.md
are now checked in CI during crate compilation. They were woefully outdated and have now been fixed.
Major breaking changes ahead! @rfuest has been hard at work making the colours story in Embedded Graphics much richer and easier to use.
As this is an alpha version, please give it a test and report back any issues you find!
- (breaking) Added many colour types
Small doc fixes and other minor changes.
- Added low-effort Embedded Graphics logo for https://docs.rs/embedded-graphics
- Wrap
Coord
code example in backticks so it's rendered as code by Rustdoc
A couple of breaking changes around naming, mostly polish around public APIs
- (breaking) Primitives macros have been renamed. This is primarily to fix conflicts with
std
'sline!()
macro, but I thought I'd take the opportunity to make the names a bit better/more consistent at the same time:line
->egline
triangle
->egtriangle
rect
->egrectangle
circle
->egcircle
- (breaking) The
Rect
primitive is now renamed toRectangle
to fit with the other non-truncated primitive names.
A big release, focussed on 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.
-
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( Circle::new(Coord::new(10, 10), 10 as u32) .with_stroke(Some(0u8)) .with_fill(Some(1u8)) .into_iter(), ); display.draw( Circle::new(Coord::new(10, 10), 10 as u32) .translate(Coord::new(10, 10)) .with_stroke(Some(0u8)) .with_fill(Some(0u8)) .into_iter(), ); display.draw( Rect::new(Coord::new(0, 0), Coord::new(64, 64)) .translate(Coord::new(96 + 32, 32)) .with_stroke(Some(0u8)) .with_fill(Some(0u8)) .into_iter(), ); display.draw( Triangle::new(Coord::new(32, 0), Coord::new(0, 64), Coord::new(64, 64)) .translate(Coord::new(96 * 2 + 16, 16)) .with_stroke(Some(0u8)) .with_fill(Some(1u8)) .into_iter(), );
Now looks like this:
display.draw(circle!((10, 10), 10 as u32, stroke = Some(0u8), fill = Some(1u8))); display.draw( circle!((10, 10), 10 as u32, stroke = Some(0u8), fill = Some(0u8)) .translate(icoord!(10, 10)), ); display.draw( rect!((0, 0), (64, 64), stroke = Some(0u8), fill = Some(1u8)) .translate(icoord!(96 + 16, 16)), ); display.draw( triangle!( (32, 0), (0, 64), (64, 64), stroke = Some(0u8), fill = Some(1u8) ) .translate(icoord!(96 * 2 + 16, 16)), );
-
Added
pixelcolor::RGB565
to make working with displays and images in the common RGB565 pixel format.
-
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( Circle::new(Coord::new(10, 10), 10 as u32) .into_iter() ); // After display.draw( Circle::new(Coord::new(10, 10), 10 as u32) );
This also means that objects can be passed by reference too:
let circle = Circle::new(Coord::new(10, 10), 10 as u32); display.draw(&circle); // 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 Font6x8::render_str("Hello Rust!").fill(Some(1u8.into())); // With macros text_6x8!("Hello Rust!", fill = Some(1u8.into()));
-
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.
-
From
is implemented for a few more types forCoord
andUnsignedCoord
. Among other things, they can now be converted to tuples by calling.into()
.
- (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
-
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:
fn multi() -> impl Iterator<Item = Pixel<u8>> { let line = Line::new(Coord::new(0, 1), Coord::new(2, 3)) .stroke(Some(1u8.into())); let circle = Circle::new(Coord::new(5, 5), 3) .stroke(Some(1u8.into())); line.into_iter().chain(circle) }