summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/colors.py14
-rw-r--r--poezio/xhtml.py2
2 files changed, 8 insertions, 8 deletions
diff --git a/poezio/colors.py b/poezio/colors.py
index 197120ad..8f086991 100644
--- a/poezio/colors.py
+++ b/poezio/colors.py
@@ -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
diff --git a/poezio/xhtml.py b/poezio/xhtml.py
index 4f469bd7..28f50b5a 100644
--- a/poezio/xhtml.py
+++ b/poezio/xhtml.py
@@ -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):
"""