forked from LiveCarta/BookConverter
Update rgb2closest_color.py
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from typing import Tuple
|
||||
from webcolors import hex_to_rgb
|
||||
|
||||
# 16 основных цветов, hex соответвуют hex цветам livecarta
|
||||
@@ -8,7 +9,7 @@ html4_hex_to_names = {'#00ffff': 'aqua', '#000000': 'black', '#0000ff': 'blue',
|
||||
'#ffffff': 'white', '#ffff00': 'yellow'}
|
||||
|
||||
|
||||
def rgb2hsv(r: int, g: int, b: int):
|
||||
def rgb2hsv(r: int, g: int, b: int) -> Tuple[float, float, float]:
|
||||
r /= 255
|
||||
g /= 255
|
||||
b /= 255
|
||||
@@ -42,7 +43,7 @@ for key, name in html4_hex_to_names.items():
|
||||
HTML_COLORS_HSV[name] = (h, s, v)
|
||||
|
||||
|
||||
def rgb2closest_html_color_name(color: str):
|
||||
def rgb2closest_html_color_name(color: str) -> str:
|
||||
"""
|
||||
- get color in hsv (hue, saturation, value)
|
||||
- try to match with black, grey, silver (black, darkGray, lightGray) as this colors matches badly even in hsv model
|
||||
|
||||
Reference in New Issue
Block a user