Crates.io | buffer-graphics-lib |
lib.rs | buffer-graphics-lib |
version | 0.19.0 |
source | src |
created_at | 2022-09-03 13:23:58.814933 |
updated_at | 2024-09-30 08:29:12.199495 |
description | Simple graphics library for buffers |
homepage | |
repository | https://github.com/emmabritton/buffer-graphics-lib |
max_upload_size | |
id | 657896 |
size | 432,592 |
This is a simple graphics library for drawing to a buffer, mainly designed to be used with Pixels Graphics or Pixels
It has basic shape drawing, bitmap text and image rendering.
The Graphics
struct needs a mutable buffer to work on and so mostly likely you'll need to create the struct and pass in the buffer from the rendering library every frame but this should be fine for performance as the struct is nearly empty.
ICI Tools can be useful when working with ICI files
ICI Image editor is a MSPaint like program for ICI and ICA files
Graphics tests has tests for this crate, and provides some examples
Integration tests shows how to use some third party libraries
In your Cargo.toml
file add
buffer-graphics-lib = "0.19.0"
Setup a graphics instance
let mut buffer: [u8; 1920000] = Graphics::create_buffer(800,600); //800 x 600 RGBA
let mut graphics = Graphics::new(&mut buffer, 800, 600)?;
Drawing is then quite simple:
let text = Text::new("Some text", (1,1), (WHITE, PixelFont::Standard6x7));
graphics.draw(&text);
graphics.draw_image(20, 20, &image);
graphics.draw_rect(Rect::new((40, 50), (100, 100)), stroke(BLUE));
Default features: "serde"
image_loading
Image
slet image = open_image("resources/example.png")?;
graphics.draw_image(40, 20, &image);
serde
Serialize
and Deserialize
for most structs and enumsgraphics-shapes/serde
, see Graphic Shapes readmemint
graphics-shapes/mint
, see Graphic Shapes readmenotosans
Add basic Renderable
impl for RasterizedChar
from notosans
embedded
Adds Graphics
as a target for embedded-graphics