embedded-sprites

Crates.ioembedded-sprites
lib.rsembedded-sprites
version0.2.0
sourcesrc
created_at2023-01-12 21:24:20.771344
updated_at2024-04-14 13:53:46.925656
descriptionEmbedded no std graphics libary for bundling image at compile time
homepage
repositoryhttps://github.com/LuckyTurtleDev/embedded-sprites
max_upload_size
id757455
size26,602
(LuckyTurtleDev)

documentation

README

embedded-sprites License: MIT OR Apache-2.0 embedded-sprites on crates.io embedded-sprites on docs.rs Source Code Repository

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 Sprites;

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();
Commit count: 34

cargo fmt