make RGB values consistent as int. fixes #10766 (#10782)

* make RGB consitant as int. fixes #10766

* fix rounding and only change for hex convertion
This commit is contained in:
Per Osbäck 2017-11-27 11:31:35 +01:00 committed by Pascal Vizeli
parent 6cd9ca018a
commit 2daea92379
2 changed files with 2 additions and 1 deletions

View File

@ -357,7 +357,7 @@ def color_rgbw_to_rgb(r, g, b, w):
def color_rgb_to_hex(r, g, b):
"""Return a RGB color from a hex color string."""
return '{0:02x}{1:02x}{2:02x}'.format(r, g, b)
return '{0:02x}{1:02x}{2:02x}'.format(round(r), round(g), round(b))
def rgb_hex_to_rgb_list(hex_string):

View File

@ -212,6 +212,7 @@ class TestColorUtil(unittest.TestCase):
assert color_util.color_rgb_to_hex(255, 255, 255) == 'ffffff'
assert color_util.color_rgb_to_hex(0, 0, 0) == '000000'
assert color_util.color_rgb_to_hex(51, 153, 255) == '3399ff'
assert color_util.color_rgb_to_hex(255, 67.9204190, 0) == 'ff4400'
class ColorTemperatureMiredToKelvinTests(unittest.TestCase):