Crate simple_blit

Source
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): implements Surface and SurfaceMut for Pixels.
  • image-integration (off by default): implements Surface and SurfaceMut for ImageSurface
  • serde (off by default): implements Serialize and Deserialize for surface types and Transform.

§License

As of version 1.0.0, this crate’s license has been changed from MIT to MIT-0 (aka MIT No Attribution).

Structs§

GenericSurface
Generic surface with width and height.
SingleValueSurface
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.
SurfaceMut
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.

Type Aliases§

Point
Point type.
Size
Size type.