You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
629 B
Python
29 lines
629 B
Python
#!/usr/bin/env python3
|
|
from math import sqrt
|
|
|
|
|
|
def clearscreen():
|
|
print(chr(27) + "[2J", end='')
|
|
|
|
|
|
def resetcolor():
|
|
print(chr(27) + "[0m", end='')
|
|
|
|
|
|
def setbghexcolor(hex):
|
|
r = int(hex[0:2], 16)
|
|
g = int(hex[2:4], 16)
|
|
b = int(hex[4:6], 16)
|
|
print(chr(27) + "[48;2;" + str(r) + ";" + str(g) + ";" + str(b) + "m", end='')
|
|
|
|
|
|
def setfgbybghex(hex):
|
|
r = int(hex[0:2], 16)
|
|
g = int(hex[2:4], 16)
|
|
b = int(hex[4:6], 16)
|
|
contrast = sqrt(r * r * .241 + g * g * .691 + b * b * .068)
|
|
if contrast > 130:
|
|
print(chr(27) + "[38;30m", end='')
|
|
else:
|
|
print(chr(27) + "[38;97m", end='')
|