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
    &mut GenericSurface::new(&mut dest, size(5, 5)).unwrap(),
    // where to blit
    point(1, 1),
    &GenericSurface::new(&src, size(4, 4)).unwrap(),
    // where to blit from
    point(0, 0),
    // size of the area
    size(3, 3),
    // 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§

Enums§

  • Transformations that can be applied when blitting.

Traits§

Functions§

  • Blit part of one surface to another, cloning the values.
  • Blit part of one surface to another, converting the values.
  • Blit part of one surface to another, ignoring the mask values.
  • Blit one whole surface to another.
  • Blit part of one surface to another (generalized function).
  • Quickly construct a Point.
  • Quickly construct a Size.

Type Aliases§