A Rust library for blitting 2D sprites
Add this to your Cargo.toml
:
toml
[dependencies]
blit = "0.6"
Web: https://tversteeg.nl/blit/smiley/
Uses the ["image"]
feature flag.
Displays the use of loading an image, blitting it fully and also blitting a subrectangle from it.
console
cargo run --example smiley
Web: https://tversteeg.nl/blit/aseprite-animation/
Uses the ["image", "aseprite"]
feature flags.
Displays the use of using the AnimationBuffer
and Animation
structs to create a simple time based animation.
console
cargo run --example aseprite-animation
Web: https://tversteeg.nl/blit/aseprite-9slice/
Uses the ["image", "aseprite"]
feature flags.
console
cargo run --example aseprite-9slice
Uses the ["image"]
feature flag:
toml
[dependencies]
blit = { version = "0.6", features = ["image"] }
```rust use blit::BlitExt;
const WIDTH: usize = 180; const HEIGHT: usize = 180; const MASK_COLOR: u32 = 0xFF00FF;
// The target buffer the image will be blit to
let mut buffer: Vec
// Open the example image using the image crate let img = image::open("examples/smiley.png").unwrap().into_rgb8();
// Convert the image to a blit buffer let blitbuffer = imgrgb.toblitbuffer(Color::fromu32(MASKCOLOR));
// Blit the image twice to the buffer let pos = (10, 10); blitbuffer.blit(&mut buffer, WIDTH, pos); let pos = (20, 20); blitbuffer.blit(&mut buffer, WIDTH, pos); ```