You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered: