pub struct BarcodeRow {
row: Vec<u8>,
currentLocation: usize,
}
impl BarcodeRow {
pub fn new(width: usize) -> Self {
Self {
row: vec![0; width],
currentLocation: 0,
}
}
pub fn set<T: Into<u8>>(&mut self, x: usize, value: T) {
self.row[x] = value.into()
}
pub fn addBar(&mut self, black: bool, width: usize) {
for _ii in 0..width {
self.set(self.currentLocation, black);
self.currentLocation += 1;
}
}
pub fn getScaledRow(&self, scale: usize) -> Vec<u8> {
let mut output = vec![0; self.row.len() * scale];
for (i, row) in output.iter_mut().enumerate() {
*row = self.row[i / scale];
}
output
}
}