class Canvas:
    """Boolean pixel grid for braille rendering.

    Each terminal character cell maps to a 2x4 pixel block (braille dot pattern).
    The canvas stores pixels at this sub-character resolution.
    """

    def __init__(self, char_width: int, char_height: int):
        self.char_width = char_width
        self.char_height = char_height
        self.pixel_width = char_width * 2
        self.pixel_height = char_height * 4
        self._pixels = bytearray(self.pixel_width * self.pixel_height)

    def set_pixel(self, x: int, y: int) -> None:
        if 0 <= x < self.pixel_width and 0 <= y < self.pixel_height:
            self._pixels[y * self.pixel_width + x] = 1

    def get_pixel(self, x: int, y: int) -> bool:
        if 0 <= x < self.pixel_width and 0 <= y < self.pixel_height:
            return bool(self._pixels[y * self.pixel_width + x])
        return False

    def clear(self) -> None:
        for i in range(len(self._pixels)):
            self._pixels[i] = 0
