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
What is the recommended way to get e.g. RGB values from a colour with a 0-255 range? Do I have to do something like [int(i * 255) for i in col.rgb]? It seems like a shortcut for this very common case would be useful.
The text was updated successfully, but these errors were encountered:
Actually, I guess it should use rgb_clamped instead of rgb to ensure the resulting values are within range. But even that is not quite right because only values exactly equal to 1.0 will map to 255, whereas it should really be values in the range 255/256 to 1.
So would this be more correct: [min(255, int(i * 256)) for i in col.rgb_clamped]?
After a bit more looking around, I found another way: col.to('rgb').color_object.get_upscaled_value_tuple(), but it doesn't clamp the values to the valid range:
In [1]: col=spectra.lab(80, -250, 80)
In [2]: col.to('rgb').color_object.get_upscaled_value_tuple()
Out[2]: (0, 261, 0)
I think a simple, documented, and correct way of doing this would be very useful.
What is the recommended way to get e.g. RGB values from a colour with a 0-255 range? Do I have to do something like
[int(i * 255) for i in col.rgb]
? It seems like a shortcut for this very common case would be useful.The text was updated successfully, but these errors were encountered: