summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Wielicki <j.wielicki@sotecware.net>2017-11-12 17:13:51 +0100
committerJonas Wielicki <j.wielicki@sotecware.net>2017-11-12 17:13:51 +0100
commit6f1b7eb46ea461d15d122dba8bf4a2ab50f00179 (patch)
tree80a3e675a9a9b015920f3ef9d881b3c10417ae31
parent7e576941ca5382ca4b5737fc0b45d33ddf9fe620 (diff)
downloadpoezio-6f1b7eb46ea461d15d122dba8bf4a2ab50f00179.tar.gz
poezio-6f1b7eb46ea461d15d122dba8bf4a2ab50f00179.tar.bz2
poezio-6f1b7eb46ea461d15d122dba8bf4a2ab50f00179.tar.xz
poezio-6f1b7eb46ea461d15d122dba8bf4a2ab50f00179.zip
Fix ranges for ncurses to rgb conversion
-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):
"""