pub struct Bitmap {
offset: usize,
width: usize,
data: Vec<[u8; 16]>,
}
impl Bitmap {
pub fn new(offset: usize, width: usize) -> Self {
Self {
offset,
width,
data: vec![]
}
}
pub fn raster_line(&mut self, line: &[bool]) {
let mut e = [0u8; 16];
if line.len() > self.width as usize {
panic!("Line width exceeds renderable width");
}
for i in 0..line.len() {
if !line[i] {
continue;
}
let offset_index = self.offset + i;
e[offset_index / 8] |= 1 << (7 - (offset_index % 8));
}
self.data.push(e);
}
pub fn data(&self) -> Vec<[u8; 16]> {
self.data.clone()
}
}