import time try: import re2 as re except ImportError: import re import numpy as np from PIL import Image from pixelterm import xtermcolors from config import * from font import * default_palette = [ (0x00, 0x00, 0x00), # 0 normal colors (0xcd, 0x00, 0x00), # 1 (0x00, 0xcd, 0x00), # 2 (0xcd, 0xcd, 0x00), # 3 (0x00, 0x00, 0xee), # 4 (0xcd, 0x00, 0xcd), # 5 (0x00, 0xcd, 0xcd), # 6 (0xe5, 0xe5, 0xe5), # 7 (0x7f, 0x7f, 0x7f), # 8 bright colors (0xff, 0x00, 0x00), # 9 (0x00, 0xff, 0x00), # 10 (0xff, 0xff, 0x00), # 11 (0x5c, 0x5c, 0xff), # 12 (0xff, 0x00, 0xff), # 13 (0x00, 0xff, 0xff), # 14 (0xff, 0xff, 0xff)] # 15 default_colors = (default_palette[8], default_palette[0]) class CharGenerator: def __init__(self, seq=None, lg=None, text=''): settings = False, False, False, default_colors if lg: settings = lg.bold, lg.blink, lg.underscore, (lg.fg, lg.bg) self.bold, self.blink, self.underscore, (self.fg, self.bg) = settings self.text = text if seq: self.parse_escape_sequence(seq) def parse_escape_sequence(self, seq): codes = list(map(int, seq[2:-1].split(';'))) fg, bg, reverse, i = self.fg, self.bg, False, 0 while i