pub struct Image {
pixels: Vec<Pixel>,
width: usize,
#[allow(dead_code)]
height: usize,
}
#[derive(Clone, Copy)]
pub struct Pixel {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
impl Image {
pub fn new(width: usize, height: usize) -> Self {
Self {
pixels: vec![
Pixel {
r: 0,
g: 0,
b: 0,
a: 0
};
width * height
],
width,
height,
}
}
pub fn put_pixel(&mut self, x: usize, y: usize, pixel: Pixel) {
self.pixels[self.width * y + x] = pixel;
}
}