colors.py icon indicating copy to clipboard operation
colors.py copied to clipboard

Conventional 0-255 colors values doesn't accept floats

Open Jerakin opened this issue 6 years ago • 5 comments

Rounding the inputs for RGB as conventionally 0-255 doesn't take floats. Closes https://github.com/mattrobenolt/colors.py/issues/8

Jerakin avatar Dec 18 '18 09:12 Jerakin

Is there some reference that says this is strictly true? I feel like typically they are integers, but not sure why a float wouldn’t be allowed.

mattrobenolt avatar Dec 18 '18 18:12 mattrobenolt

If it wasn't strictly true and we did included decimals it would be a lot more than 16777216 colors (24-bit). Which is why I thought it made sense :) Also most (all I tried) software's doesn't accept floats for 0-255 color values.

Jerakin avatar Dec 18 '18 21:12 Jerakin

Oh, I guess that makes a lot of logical sense, you'd be increasing the number of colors.

I guess from my perspective, I was trying to maintain lossless conversions, but technically you can't do that.

I wonder if it makes sense to store as a floating point internally, but use the r/g/b values as integers for output only.

mattrobenolt avatar Dec 18 '18 21:12 mattrobenolt

I wonder if it makes sense to store as a floating point internally, but use the r/g/b values as integers for output only.

I think this would make a lot of sense. Wouldn't make it as "lossy" to convert to RGB.

Jerakin avatar Dec 19 '18 10:12 Jerakin

But then data loss would be expected if you go from 32 bit -> 16 bit -> 32 bit

Jerakin avatar Jul 03 '19 09:07 Jerakin