Commit 6f1b7eb4 authored by Jonas Schäfer's avatar Jonas Schäfer

Fix ranges for ncurses to rgb conversion

parent 7e576941
......@@ -13,20 +13,20 @@ def ncurses_color_to_rgb(color):
(r, g, b) = curses.color_content(color)
except: # fallback in faulty terminals (e.g. xterm)
(r, g, b) = curses.color_content(color%8)
r = r / 1000 * 6 - 0.01
g = g / 1000 * 6 - 0.01
b = b / 1000 * 6 - 0.01
r = r / 1000 * 5
g = g / 1000 * 5
b = b / 1000 * 5
elif color <= 231:
color = color - 16
r = color % 6
color = color / 6
color = color // 6
g = color % 6
color = color / 6
color = color // 6
b = color % 6
else:
color -= 232
r = g = b = color / 24 * 6
return r / 6, g / 6, b / 6
r = g = b = color / 24 * 5
return r / 5, g / 5, b / 5
def rgb_to_ycbcr(r, g, b):
y = K_R * r + K_G * g + K_B * b
......
......@@ -215,7 +215,7 @@ def get_body_from_message_stanza(message,
def rgb_to_html(rgb):
r, g, b = rgb
return '#%02X%02X%02X' % (int(r*256), int(g*256), int(b*256))
return '#%02X%02X%02X' % (round(r*255), round(g*255), round(b*255))
def ncurses_color_to_html(color):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment