Expand description
§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).
Structs§
- Generic
Surface - Generic surface with width and height.
- Single
Value Surface - A ‘surface’ that holds a single value, like a plain-colored rectangle.
- SubSurface
- A surface that only uses a rectangular part of another surface.
Enums§
- Transform
- Transformations that can be applied when blitting.
Traits§
- Surface
- 2D immutable surface trait.
- Surface
Mut - 2D mutable surface trait.
Functions§
- blit
- Blit part of one surface to another, cloning the values.
- blit_
convert - Blit part of one surface to another, converting the values.
- blit_
masked - Blit part of one surface to another, ignoring the
mask
values. - blit_
with - Blit part of one surface to another (generalized function).
- point
- Quickly construct a
Point
. - size
- Quickly construct a
Size
.