blit
A Rust library for blitting 2D sprites
Documentation
Usage
Add this to your Cargo.toml
:
[]
= "0.5"
And this to your crate root:
extern crate blit;
Run the example
On Linux you need the xorg-dev
package as required by minifb
. sudo apt install xorg-dev
cargo run --example smiley
This should produce the following window:
Examples
extern crate image;
use *;
const WIDTH: usize = 180;
const HEIGHT: usize = 180;
const MASK_COLOR: u32 = 0xFF00FF;
let mut buffer: = vec!;
let img = open.unwrap;
let img_rgb = img.as_rgb8.unwrap;
// Blit directly to the buffer
let pos = ;
img_rgb.blit;
// Blit by creating a special blitting buffer first, this has some initial
// overhead but is a lot faster after multiple calls
let blit_buffer = img_rgb.to_blit_buffer;
let pos = ;
blit_buffer.blit;
let pos = ;
blit_buffer.blit;
// Save the blit buffer to a file
blit_buffer.save;