13 releases (3 stable)
2.0.0 | Jun 9, 2024 |
---|---|
1.2.0 | Jun 9, 2024 |
1.0.0 | Feb 20, 2024 |
0.8.0 | Jan 16, 2024 |
0.3.0 | Nov 14, 2023 |
#95 in No standard library
Used in 2 crates
31KB
778 lines
simple-blit
Provides simple blitting from one surface to another with some possible transformations.
Example
use simple_blit::*;
let mut dest: [u8; 25] = [
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
];
let src: [u8; 16] = [
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
];
blit(
// construct a surface which holds width and height
GenericSurface::new(&mut dest, size(5, 5))
.unwrap()
// offset on the destination
.offset_surface_mut(point(1, 1)),
// you can borrow the surface if you don't want to drop it
// (the destination has to be borrowed mutably of course)
&GenericSurface::new(&src, size(4, 4))
.unwrap()
.sub_surface(
point(0, 0), // source offset
size(3, 3) // size of the area to copy
),
// no transformations
Default::default(),
);
assert_eq!(dest, [
0, 0, 0, 0, 0,
0, 1, 1, 1, 0,
0, 1, 1, 1, 0,
0, 1, 1, 1, 0,
0, 0, 0, 0, 0,
]);
Cargo features
pixels-integration
(off by default): implementsSurface
andSurfaceMut
forPixels
.image-integration
(off by default): implementsSurface
andSurfaceMut
forImageSurface
serde
(off by default): implementsSerialize
andDeserialize
for surface types andTransform
.
License
As of version 1.0.0, this crate's license has been changed from MIT to MIT-0 (aka MIT No Attribution).
Dependencies
~0–31MB
~470K SLoC