forked from LiveCarta/BookConverter
Delete unused vars & rows
This commit is contained in:
@@ -30,7 +30,6 @@ def rgb2hsv(r, g, b):
|
||||
else:
|
||||
hue = 4.0 + gc - rc
|
||||
|
||||
hue0 = (hue / 6.0) % 1.0
|
||||
hue2 = ((hue + 6) / 6.0) if (hue < 0) else (hue / 6.0)
|
||||
|
||||
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):
|
||||
"""
|
||||
|
||||
|
||||
- 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
|
||||
|
||||
@@ -84,18 +82,13 @@ def rgb2closest_html_color_name(color):
|
||||
pass
|
||||
|
||||
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]]
|
||||
dist_prev_color = (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()
|
||||
dist_prev_color = (hue_request - hue_prev) ** 2 + (s_request - s_prev) ** 2 + (v_request - v_prev) ** 2
|
||||
if dist_cur_color < dist_prev_color:
|
||||
diff2base_color_dict[hue_diff] = name
|
||||
else:
|
||||
diff2base_color_dict[hue_diff] = name
|
||||
|
||||
# print(diff2base_color_dict)
|
||||
return diff2base_color_dict[min(diff2base_color_dict.keys())]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user