#!/usr/bin/env python3 from color import Color import time WIDTH = 64 HEIGHT = 32 PIXEL = '\033[38;2;{};{};{}m██' class Matrix: def __init__(self) -> None: self.buffer = [ [Color(0, 0, 0) for _ in range(WIDTH)] for __ in range(HEIGHT) ] def drawPixel(self, x: int, y: int, c: Color): self.buffer[y][x] = c def clear(self) -> None: self.__init__() def show(self) -> None: # clear print("\033[H\033[J", end="") for line in self.buffer: output = ''.join(PIXEL.format(px.r, px.g, px.b) for px in line) print(output) def main() -> None: m = Matrix() for i in range(32): m.drawPixel(i, i, Color(255, 0, 4*i)) for i in range(32): m.drawPixel(32 + i, 31 - i, Color(255, 0, (4*i))) m.show() if __name__ == '__main__': main()