5 unstable releases
0.2.0 | Apr 14, 2024 |
---|---|
0.1.2 | May 23, 2023 |
0.1.1 | Feb 28, 2023 |
0.1.0 | Feb 28, 2023 |
0.0.0 | Jan 12, 2023 |
#343 in Graphics APIs
33 downloads per month
15KB
204 lines
embedded-sprites
Embedded no std graphics library for bundling image at compile time, to be used at the embedded-graphics crate.
The include_image
macro can be usede to create a Image
from an existing image file at compile time. Every image formats supported by the image crate can be used. The image will be automatically be converted to the requested pixelcolor. Current only rgb pixelcolors are supported.
use embedded_graphics::pixelcolor::Bgr565;
use embedded_sprites::{image::Image, include_image};
#[include_image]
const IMAGE: Image<Bgr565> = "embedded-sprites/grass.png";
To draw a Image
it must be put inside a Sprite
. You can use the same Image
inside multiple Sprite
s;
use embedded_graphics::{geometry::Point, pixelcolor::Bgr565, Drawable};
use embedded_sprites::sprite::Sprite;
const SPRITE1: Sprite<Bgr565> = Sprite::new(Point::new(0, 0), &IMAGE);
const SPRITE2: Sprite<Bgr565> = Sprite::new(Point::new(32, 32), &IMAGE);
SPRITE1.draw(&mut display).unwrap();
SPRITE2.draw(&mut display).unwrap();
Dependencies
~7.5MB
~126K SLoC