forked from LiveCarta/BookConverter
Delete unused vars & rows
This commit is contained in:
@@ -30,7 +30,6 @@ def rgb2hsv(r, g, b):
|
|||||||
else:
|
else:
|
||||||
hue = 4.0 + gc - rc
|
hue = 4.0 + gc - rc
|
||||||
|
|
||||||
hue0 = (hue / 6.0) % 1.0
|
|
||||||
hue2 = ((hue + 6) / 6.0) if (hue < 0) else (hue / 6.0)
|
hue2 = ((hue + 6) / 6.0) if (hue < 0) else (hue / 6.0)
|
||||||
|
|
||||||
return hue2 * 360, saturation * 100, value * 100
|
return hue2 * 360, saturation * 100, value * 100
|
||||||
@@ -46,7 +45,6 @@ for key, name in html4_hex_to_names.items():
|
|||||||
def rgb2closest_html_color_name(color):
|
def rgb2closest_html_color_name(color):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
- get color in hsv (hue, saturation, value)
|
- 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
|
- try to match with black, grey, silver (black, darkGray, lightGray) as this colors matches badly even in hsv model
|
||||||
|
|
||||||
@@ -84,18 +82,13 @@ def rgb2closest_html_color_name(color):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if hue_diff in diff2base_color_dict:
|
if hue_diff in diff2base_color_dict:
|
||||||
dist_cur_color = (s_request - s_html) ** 2 + (v_request - v_html) ** 2
|
dist_cur_color =(hue_request - hue_html) ** 2 + (s_request - s_html) ** 2 + (v_request - v_html) ** 2
|
||||||
hue_prev, s_prev, v_prev = HTML_COLORS_HSV[diff2base_color_dict[hue_diff]]
|
hue_prev, s_prev, v_prev = HTML_COLORS_HSV[diff2base_color_dict[hue_diff]]
|
||||||
dist_prev_color = (s_request - s_prev) ** 2 + (v_request - v_prev) ** 2
|
dist_prev_color = (hue_request - hue_prev) ** 2 + (s_request - s_prev) ** 2 + (v_request - v_prev) ** 2
|
||||||
# print(name, diff2base_color_dict[hue_diff],)
|
|
||||||
# print(dist_cur_color, dist_prev_color)
|
|
||||||
# print()
|
|
||||||
if dist_cur_color < dist_prev_color:
|
if dist_cur_color < dist_prev_color:
|
||||||
diff2base_color_dict[hue_diff] = name
|
diff2base_color_dict[hue_diff] = name
|
||||||
else:
|
else:
|
||||||
diff2base_color_dict[hue_diff] = name
|
diff2base_color_dict[hue_diff] = name
|
||||||
|
|
||||||
# print(diff2base_color_dict)
|
|
||||||
return diff2base_color_dict[min(diff2base_color_dict.keys())]
|
return diff2base_color_dict[min(diff2base_color_dict.keys())]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user