Open tony opened 7 years ago
I second this. It would be nice to support integer RGB values from 0 to 255.
I wrote a function for accepting integer RGB values. It is not perfect, but it gets the job done for me.
from colour import Color
def check_color(in_color):
out_color = ''
if isinstance(in_color, tuple) and len(in_color) == 3:
if all(isinstance(item, int) for item in in_color):
rescaled_color = [x / 255.0 for x in in_color]
out_color = Color(rgb=tuple(rescaled_color))
return out_color
else:
print('RGB color must be a tuple with three integer values ranging from 0 to 255.')
return
else:
try:
out_color = Color(in_color)
return out_color
except Exception as e:
print('The provided color is invalid.')
print(e)
return
Is there a chance integer RGB values can be accepted? It makes compatibility with PIL's color signatures more streamlined.