gfx-xtra

Crates.iogfx-xtra
lib.rsgfx-xtra
version0.2.0
sourcesrc
created_at2022-11-22 15:41:22.08908
updated_at2023-10-28 12:52:42.497735
descriptionembedded-graphics xtras.
homepage
repositoryhttps://github.com/ivmarkov/gfx-xtra
max_upload_size
id720889
size44,654
(ivmarkov)

documentation

README

gfx-xtra

CI crates.io

Various add-ons to embedded-graphics. Currently, all of the add-ons are DrawTarget (display) transformations.

TL;DR: To use these, add one or both of the following to your Rust module:

use gfx_xtra::draw_target::DrawTargetExt2;
use gfx_xtra::draw_target::OwnedDrawTarget;

MSRV

1.65, because the Owned<...> transformations use GATs, which just got stabilized.

PackedFrameBuffer

An offscreen DrawTarget frame buffer implementation, with resolution of 1 to 8 bits per color. Used to implement flicker-free drawing and sending update deltas to the actual screen.

If you have 16 or 32bpp screen, use the ColorConverted DrawTarget transformation to convert your custom 1 to 8 bit color into the RGB color supported by your screen. The 8 bit color restriction is unlikely to be lifted, as offscreen buffers with higher bpp require too much RAM.

Owned<...> transformations

The DrawTargetExt trait in embedded-graphics allows you to clip, crop, translate and color-convert your display, but these transformations take a &mut reference to your original display, which sometimes can be inconvenient - as in when you want to transform your screen and then send an owned (Box-ed or not) instance to a generic piece of drawing code.

Trait OwnedDrawTargetExt provides "owned" versions of these transformations, as well as of all transformations defined in this crate (rotated, scaled, buffered and flushing).

See this embedded-graphics PR for more details.

Buffered transformation

Uses two PackedFrameBuffer instances to achieve flicker-free incremental updates to the actual screen.

Additional transformations

  • Rotated - rotates the draw target to 90, 180 or 270 degrees
  • (a bit controversial) Scaled - scales the draw target by a predefined ratio; makes sense for scaling down, not up
  • Flushing - implements Flushable - an extension trait of DrawTarget that features a flush method. Useful when your display needs to be flushed at the end of the drawing, or when using a buffered transformation.

Documentation, tests

None, as of now :p

Commit count: 7

cargo fmt