Closed sveetch closed 6 years ago
Ok forget it i found the math to perform it and created my own helpers:
def rgbint2rgbfloat(rgb):
"""
Convert rgb integer values (0-255) to rgb float values (0.0-1.0) suitable
with colour.Color usage.
Args:
rgb (tuple): Tuple of integer values from 0 to 255
Returns:
tuple: Tuple of float values from 0.0 to 1.0
"""
return tuple([(i / 255) for i in rgb])
def rgbfloat2rgbint(rgb):
"""
Convert rgb float values (0.0-1.0) to rgb integer values (0-255).
Args:
rgb (tuple): Tuple of float values from 0.0 to 1.0
Returns:
tuple: Tuple of integer values from 0 to 255
"""
return tuple([int(255 * i) for i in rgb])
Sorry for the noise
Hi,
I searched in code, doc and issues but i didn't find a clear way to use CSS rgb values since Color rgb argument required float values.
Like for red color i have this CSS rule:
rgb(255, 0, 0)
I attempted to be able to do:
Color(rgb=(255, 0, 0))
Did i missed some helper or easy math to perform this ?
Thanks.