displayio.py
1 class Bitmap: 2 def __init__(self, width, height, color_count): 3 self.width = width 4 self.height = height 5 if color_count > 255: 6 raise ValueError("Cannot support that many colors") 7 self.values = bytearray(width * height) 8 9 def __setitem__(self, index, value): 10 if isinstance(index, tuple): 11 index = index[0] + index[1] * self.width 12 self.values[index] = value 13 14 def __getitem__(self, index): 15 if isinstance(index, tuple): 16 index = index[0] + index[1] * self.width 17 return self.values[index] 18 19 def __len__(self): 20 return self.width * self.height