forked from LiveCarta/BookConverter
Annotations in Epub converter
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from webcolors import html4_hex_to_names, hex_to_rgb
|
||||
from webcolors import hex_to_rgb
|
||||
|
||||
# 16 основных цветов, hex соответвуют hex цветам livecarta
|
||||
# названия другие
|
||||
@@ -42,18 +42,23 @@ for key, name in html4_hex_to_names.items():
|
||||
HTML_COLORS_HSV[name] = (h, s, v)
|
||||
|
||||
|
||||
def rgb2closest_html_color_name(color):
|
||||
def rgb2closest_html_color_name(color: 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
|
||||
|
||||
- calc hue difference between color and all base colors
|
||||
- if for new base color hue diff same as for any other, try to measure saturation and value
|
||||
(it happens for similar colors like red - pink, blue - dark blue)
|
||||
Parameters
|
||||
----------
|
||||
color: str
|
||||
color in hex
|
||||
|
||||
Returns
|
||||
-------
|
||||
base color name that matches best to a given color
|
||||
|
||||
:param color: str, color in hex
|
||||
:return: base color name that matches best to a given color
|
||||
"""
|
||||
|
||||
if color == (255, 255, 255):
|
||||
|
||||
Reference in New Issue
Block a user