use crate::bitmap::{BitmapData, GlyphBitmapData};

pub(super) struct BitmapDataRegion<'a, const N: usize> {
    pub(super) data: &'a mut GlyphBitmapData<u8, N>,
    pub(super) x: usize,
    pub(super) y: usize,
    pub(super) width: usize,
    pub(super) height: usize,
}
impl<const N: usize> BitmapData for BitmapDataRegion<'_, N> {
    type Pixel = [u8; N];

    #[inline]
    fn width(&self) -> usize {
        self.width
    }

    #[inline]
    fn height(&self) -> usize {
        self.height
    }

    #[inline]
    fn set_px(&mut self, px: Self::Pixel, x: usize, y: usize) {
        self.data.set_px(px, self.x + x, self.y + y);
    }

    #[inline]
    fn get_px(&self, x: usize, y: usize) -> Self::Pixel {
        self.data.get_px(self.x + x, self.y + y)
    }
}
