[][src]Function sprite_gen::gen_sprite

pub fn gen_sprite<T>(
    mask_buffer: &[T],
    mask_width: usize,
    options: Options
) -> Vec<u32> where
    T: Into<i8> + Clone

Randomly generate a new sprite.

A mask buffer of i8 values should be passed together with the width of that buffer. The height is automatically calculated by dividing the size of the buffer with the width. The i8 values should be one of the following, and will generate a bitmap:

  • -1: This pixel will always be a border.
  • 0: This pixel will always be empty.
  • 1: This pixel will either be empty or filled (body).
  • 2: This pixel will either be a border or filled (body).
use sprite_gen::{gen_sprite, Options, MaskValue};

let mask = vec![MaskValue::Empty; 12 * 12];
let buffer = gen_sprite(&mask, 12, Options::default());