hex, Color.red.rgb Color.red.name, Color.red.
('red', '#ff0000', (255, 0, 0))
enum.Enum
to store color with hex, rgb, bgr format.
Color (value, names=None, module=None, qualname=None, type=None, start=1)
Use enum.Enum to store color with hex, rgb, bgr format.
Here are Color.available
:
def _get_background(color):
background = (
Back['75, 70, 75']
if sum(Color[color].rgb) / 3 > 165 else
Back['240, 250, 250']
)
return background
for i, c in enumerate(Fore.available):
background = _get_background(c)
print(background, end='')
end = '\n' if (i+1) % 4 == 0 else '\t'
print(f'{Fore[c]}{c:21s}{Fore.reset}', end=end)
print(Back.reset_all)
You can also use it with matplotlib.pyplot
:
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/fastcore/docscrape.py:225: UserWarning: Unknown section Examples
else: warn(msg)
rgb2hex (r:int, g:int, b:int)
convert rgb color to hex
hex2rgb (h:str)
convert hex color to rgb tuple