import math from PyQt6.QtGui import QColor color_normal_table = [ QColor(85,87,83), QColor(239,41,41), QColor(138,226,52), QColor(252,233,79), QColor(114,159,207), QColor(173,127,168), QColor(52,226,226), QColor(238,238,236), ] color_bold_table = [ QColor(46,52,54), QColor(204,0,0), QColor(78,154,6), QColor(196,160,0), QColor(52,101,164), QColor(117,80,123), QColor(6,152,154), QColor(211,215,207), ] color4_table = [ QColor(12, 12, 12), QColor(197, 15, 31), QColor(19, 161, 14), QColor(193, 156, 0), QColor(0, 55, 218), QColor(136, 23, 218), QColor(58, 150, 221), QColor(204, 204, 204), QColor(118, 118, 118), QColor(231, 72, 86), QColor(22, 198, 12), QColor(249, 241, 165), QColor(59, 120, 255), QColor(180, 0, 158), QColor(97, 214, 214), QColor(242, 242, 242), ] # color4_table = [ # QColor(1, 1, 1), # QColor(222, 56, 43), # QColor(57, 181, 74), # QColor(255, 199, 6), # QColor(0, 111, 184), # QColor(118, 38, 113), # QColor(44, 181, 233), # QColor(204, 204, 204), # QColor(128, 128, 128), # QColor(255, 0, 0), # QColor(0, 255, 0), # QColor(255, 255, 0), # QColor(0, 0, 255), # QColor(255, 0, 255), # QColor(0, 255, 255), # QColor(255, 255, 255), # ] color8_table = [ QColor(0x00, 0x00, 0x00), QColor(0x80, 0x00, 0x00), QColor(0x00, 0x80, 0x00), QColor(0x80, 0x80, 0x00), QColor(0x00, 0x00, 0x80), QColor(0x80, 0x00, 0x80), QColor(0x00, 0x80, 0x80), QColor(0xc0, 0xc0, 0xc0), QColor(0x80, 0x80, 0x80), QColor(0xff, 0x00, 0x00), QColor(0x00, 0xff, 0x00), QColor(0xff, 0xff, 0x00), QColor(0x00, 0x00, 0xff), QColor(0xff, 0x00, 0xff), QColor(0x00, 0xff, 0xff), QColor(0xff, 0xff, 0xff), QColor(0x00, 0x00, 0x00), QColor(0x00, 0x00, 0x5f), QColor(0x00, 0x00, 0x87), QColor(0x00, 0x00, 0xaf), QColor(0x00, 0x00, 0xd7), QColor(0x00, 0x00, 0xff), QColor(0x00, 0x5f, 0x00), QColor(0x00, 0x5f, 0x5f), QColor(0x00, 0x5f, 0x87), QColor(0x00, 0x5f, 0xaf), QColor(0x00, 0x5f, 0xd7), QColor(0x00, 0x5f, 0xff), QColor(0x00, 0x87, 0x00), QColor(0x00, 0x87, 0x5f), QColor(0x00, 0x87, 0x87), QColor(0x00, 0x87, 0xaf), QColor(0x00, 0x87, 0xd7), QColor(0x00, 0x87, 0xff), QColor(0x00, 0xaf, 0x00), QColor(0x00, 0xaf, 0x5f), QColor(0x00, 0xaf, 0x87), QColor(0x00, 0xaf, 0xaf), QColor(0x00, 0xaf, 0xd7), QColor(0x00, 0xaf, 0xff), QColor(0x00, 0xd7, 0x00), QColor(0x00, 0xd7, 0x5f), QColor(0x00, 0xd7, 0x87), QColor(0x00, 0xd7, 0xaf), QColor(0x00, 0xd7, 0xd7), QColor(0x00, 0xd7, 0xff), QColor(0x00, 0xff, 0x00), QColor(0x00, 0xff, 0x5f), QColor(0x00, 0xff, 0x87), QColor(0x00, 0xff, 0xaf), QColor(0x00, 0xff, 0xd7), QColor(0x00, 0xff, 0xff), QColor(0x5f, 0x00, 0x00), QColor(0x5f, 0x00, 0x5f), QColor(0x5f, 0x00, 0x87), QColor(0x5f, 0x00, 0xaf), QColor(0x5f, 0x00, 0xd7), QColor(0x5f, 0x00, 0xff), QColor(0x5f, 0x5f, 0x00), QColor(0x5f, 0x5f, 0x5f), QColor(0x5f, 0x5f, 0x87), QColor(0x5f, 0x5f, 0xaf), QColor(0x5f, 0x5f, 0xd7), QColor(0x5f, 0x5f, 0xff), QColor(0x5f, 0x87, 0x00), QColor(0x5f, 0x87, 0x5f), QColor(0x5f, 0x87, 0x87), QColor(0x5f, 0x87, 0xaf), QColor(0x5f, 0x87, 0xd7), QColor(0x5f, 0x87, 0xff), QColor(0x5f, 0xaf, 0x00), QColor(0x5f, 0xaf, 0x5f), QColor(0x5f, 0xaf, 0x87), QColor(0x5f, 0xaf, 0xaf), QColor(0x5f, 0xaf, 0xd7), QColor(0x5f, 0xaf, 0xff), QColor(0x5f, 0xd7, 0x00), QColor(0x5f, 0xd7, 0x5f), QColor(0x5f, 0xd7, 0x87), QColor(0x5f, 0xd7, 0xaf), QColor(0x5f, 0xd7, 0xd7), QColor(0x5f, 0xd7, 0xff), QColor(0x5f, 0xff, 0x00), QColor(0x5f, 0xff, 0x5f), QColor(0x5f, 0xff, 0x87), QColor(0x5f, 0xff, 0xaf), QColor(0x5f, 0xff, 0xd7), QColor(0x5f, 0xff, 0xff), QColor(0x87, 0x00, 0x00), QColor(0x87, 0x00, 0x5f), QColor(0x87, 0x00, 0x87), QColor(0x87, 0x00, 0xaf), QColor(0x87, 0x00, 0xd7), QColor(0x87, 0x00, 0xff), QColor(0x87, 0x5f, 0x00), QColor(0x87, 0x5f, 0x5f), QColor(0x87, 0x5f, 0x87), QColor(0x87, 0x5f, 0xaf), QColor(0x87, 0x5f, 0xd7), QColor(0x87, 0x5f, 0xff), QColor(0x87, 0x87, 0x00), QColor(0x87, 0x87, 0x5f), QColor(0x87, 0x87, 0x87), QColor(0x87, 0x87, 0xaf), QColor(0x87, 0x87, 0xd7), QColor(0x87, 0x87, 0xff), QColor(0x87, 0xaf, 0x00), QColor(0x87, 0xaf, 0x5f), QColor(0x87, 0xaf, 0x87), QColor(0x87, 0xaf, 0xaf), QColor(0x87, 0xaf, 0xd7), QColor(0x87, 0xaf, 0xff), QColor(0x87, 0xd7, 0x00), QColor(0x87, 0xd7, 0x5f), QColor(0x87, 0xd7, 0x87), QColor(0x87, 0xd7, 0xaf), QColor(0x87, 0xd7, 0xd7), QColor(0x87, 0xd7, 0xff), QColor(0x87, 0xff, 0x00), QColor(0x87, 0xff, 0x5f), QColor(0x87, 0xff, 0x87), QColor(0x87, 0xff, 0xaf), QColor(0x87, 0xff, 0xd7), QColor(0x87, 0xff, 0xff), QColor(0xaf, 0x00, 0x00), QColor(0xaf, 0x00, 0x5f), QColor(0xaf, 0x00, 0x87), QColor(0xaf, 0x00, 0xaf), QColor(0xaf, 0x00, 0xd7), QColor(0xaf, 0x00, 0xff), QColor(0xaf, 0x5f, 0x00), QColor(0xaf, 0x5f, 0x5f), QColor(0xaf, 0x5f, 0x87), QColor(0xaf, 0x5f, 0xaf), QColor(0xaf, 0x5f, 0xd7), QColor(0xaf, 0x5f, 0xff), QColor(0xaf, 0x87, 0x00), QColor(0xaf, 0x87, 0x5f), QColor(0xaf, 0x87, 0x87), QColor(0xaf, 0x87, 0xaf), QColor(0xaf, 0x87, 0xd7), QColor(0xaf, 0x87, 0xff), QColor(0xaf, 0xaf, 0x00), QColor(0xaf, 0xaf, 0x5f), QColor(0xaf, 0xaf, 0x87), QColor(0xaf, 0xaf, 0xaf), QColor(0xaf, 0xaf, 0xd7), QColor(0xaf, 0xaf, 0xff), QColor(0xaf, 0xd7, 0x00), QColor(0xaf, 0xd7, 0x5f), QColor(0xaf, 0xd7, 0x87), QColor(0xaf, 0xd7, 0xaf), QColor(0xaf, 0xd7, 0xd7), QColor(0xaf, 0xd7, 0xff), QColor(0xaf, 0xff, 0x00), QColor(0xaf, 0xff, 0x5f), QColor(0xaf, 0xff, 0x87), QColor(0xaf, 0xff, 0xaf), QColor(0xaf, 0xff, 0xd7), QColor(0xaf, 0xff, 0xff), QColor(0xd7, 0x00, 0x00), QColor(0xd7, 0x00, 0x5f), QColor(0xd7, 0x00, 0x87), QColor(0xd7, 0x00, 0xaf), QColor(0xd7, 0x00, 0xd7), QColor(0xd7, 0x00, 0xff), QColor(0xd7, 0x5f, 0x00), QColor(0xd7, 0x5f, 0x5f), QColor(0xd7, 0x5f, 0x87), QColor(0xd7, 0x5f, 0xaf), QColor(0xd7, 0x5f, 0xd7), QColor(0xd7, 0x5f, 0xff), QColor(0xd7, 0x87, 0x00), QColor(0xd7, 0x87, 0x5f), QColor(0xd7, 0x87, 0x87), QColor(0xd7, 0x87, 0xaf), QColor(0xd7, 0x87, 0xd7), QColor(0xd7, 0x87, 0xff), QColor(0xd7, 0xaf, 0x00), QColor(0xd7, 0xaf, 0x5f), QColor(0xd7, 0xaf, 0x87), QColor(0xd7, 0xaf, 0xaf), QColor(0xd7, 0xaf, 0xd7), QColor(0xd7, 0xaf, 0xff), QColor(0xd7, 0xd7, 0x00), QColor(0xd7, 0xd7, 0x5f), QColor(0xd7, 0xd7, 0x87), QColor(0xd7, 0xd7, 0xaf), QColor(0xd7, 0xd7, 0xd7), QColor(0xd7, 0xd7, 0xff), QColor(0xd7, 0xff, 0x00), QColor(0xd7, 0xff, 0x5f), QColor(0xd7, 0xff, 0x87), QColor(0xd7, 0xff, 0xaf), QColor(0xd7, 0xff, 0xd7), QColor(0xd7, 0xff, 0xff), QColor(0xff, 0x00, 0x00), QColor(0xff, 0x00, 0x5f), QColor(0xff, 0x00, 0x87), QColor(0xff, 0x00, 0xaf), QColor(0xff, 0x00, 0xd7), QColor(0xff, 0x00, 0xff), QColor(0xff, 0x5f, 0x00), QColor(0xff, 0x5f, 0x5f), QColor(0xff, 0x5f, 0x87), QColor(0xff, 0x5f, 0xaf), QColor(0xff, 0x5f, 0xd7), QColor(0xff, 0x5f, 0xff), QColor(0xff, 0x87, 0x00), QColor(0xff, 0x87, 0x5f), QColor(0xff, 0x87, 0x87), QColor(0xff, 0x87, 0xaf), QColor(0xff, 0x87, 0xd7), QColor(0xff, 0x87, 0xff), QColor(0xff, 0xaf, 0x00), QColor(0xff, 0xaf, 0x5f), QColor(0xff, 0xaf, 0x87), QColor(0xff, 0xaf, 0xaf), QColor(0xff, 0xaf, 0xd7), QColor(0xff, 0xaf, 0xff), QColor(0xff, 0xd7, 0x00), QColor(0xff, 0xd7, 0x5f), QColor(0xff, 0xd7, 0x87), QColor(0xff, 0xd7, 0xaf), QColor(0xff, 0xd7, 0xd7), QColor(0xff, 0xd7, 0xff), QColor(0xff, 0xff, 0x00), QColor(0xff, 0xff, 0x5f), QColor(0xff, 0xff, 0x87), QColor(0xff, 0xff, 0xaf), QColor(0xff, 0xff, 0xd7), QColor(0xff, 0xff, 0xff), QColor(0x08, 0x08, 0x08), QColor(0x12, 0x12, 0x12), QColor(0x1c, 0x1c, 0x1c), QColor(0x26, 0x26, 0x26), QColor(0x30, 0x30, 0x30), QColor(0x3a, 0x3a, 0x3a), QColor(0x44, 0x44, 0x44), QColor(0x4e, 0x4e, 0x4e), QColor(0x58, 0x58, 0x58), QColor(0x62, 0x62, 0x62), QColor(0x6c, 0x6c, 0x6c), QColor(0x76, 0x76, 0x76), QColor(0x80, 0x80, 0x80), QColor(0x8a, 0x8a, 0x8a), QColor(0x94, 0x94, 0x94), QColor(0x9e, 0x9e, 0x9e), QColor(0xa8, 0xa8, 0xa8), QColor(0xb2, 0xb2, 0xb2), QColor(0xbc, 0xbc, 0xbc), QColor(0xc6, 0xc6, 0xc6), QColor(0xd0, 0xd0, 0xd0), QColor(0xda, 0xda, 0xda), QColor(0xe4, 0xe4, 0xe4), QColor(0xee, 0xee, 0xee), ] def qcolor(c): return QColor(*[int(i) for i in c]) def hsi2rgb(c): h, s, i = c pi = math.pi * 2 if h <= pi / 3: b = (1 - s) / 3 r = (1 + s * math.cos(h) / math.cos(pi / 6 - h)) / 3 g = 1 - (r + b) elif h <= pi / 3 * 2: h -= pi / 3 r = (1 - s) / 3 g = (1 + s * math.cos(h) / math.cos(pi / 6 - h)) / 3 b = 1 - (r + g) else: h -= pi / 3 * 2 g = (1 - s) / 3 b = (1 + s * math.cos(h) / math.cos(pi / 6 - h)) / 3 r = 1 - (g + b) r = 3 * i * r g = 3 * i * g b = 3 * i * b return [r, g, b] def rgb2hsi(c): r, g, b = c rg = r - g rb = r - b gb = g - b h = math.acos((rg + rb) / (2 * math.sqrt(rg ** 2 + rb * gb))) if b > g: h = 2 * math.pi - h i = (r + g + b) / 3 s = 1 - min(r, g, b) / i return [h, s, i] def hsv2rgb(c): h, s, v = c y = v * s x = y * (1 - abs(h / 60 % 2 - 1)) m = v - y h %= 360 if h < 0: h += 360 if h <= 60: r, g, b = y, x, 0 elif h <= 120: r, g, b = x, y, 0 elif h <= 180: r, g, b = 0, y, x elif h <= 240: r, g, b = 0, x, y elif h <= 300: r, g, b = x, 0, y else: r, g, b = y, 0, x r = (r + m) * 255 g = (g + m) * 255 b = (b + m) * 255 return [r, g, b] black = "\033[0;30m" dark_gray = "\033[1;30m" red = "\033[0;31m" light_red = "\033[1;31m" green = "\033[0;32m" light_green = "\033[1;32m" orange = "\033[0;33m" yellow = "\033[1;33m" blue = "\033[0;34m" light_blue = "\033[1;34m" purple = "\033[0;35m" light_purple = "\033[1;35m" cyan = "\033[0;36m" light_cyan = "\033[1;36m" light_gray = "\033[0;37m" white = "\033[1;37m" nc = "\033[0m"