use wxbox_pal::Color; pub struct Pixmap { data: [Color; 256 * 256], } impl Pixmap { #[inline] pub fn new() -> Self { Self { data: [Color { red: 0, green: 0, blue: 0, alpha: 0, }; 256 * 256], } } #[inline] pub fn set(&mut self, x: usize, y: usize, color: Color) { self.data[256 * x + y] = color; } #[inline] pub fn get(&self, x: usize, y: usize) -> Color { self.data[256 * x + y] } pub fn to_raw(self) -> [u8; 256 * 256 * 4] { let mut output = [0u8; 256 * 256 * 4]; for (idx, color) in self.data.iter().enumerate() { output[4 * idx] = color.red; output[4 * idx + 1] = color.green; output[4 * idx + 2] = color.blue; output[4 * idx + 3] = color.alpha; } output } }