Closed joskuijpers closed 10 years ago
I'd say stick to 0-255 ranges, most game API's do that. However, I have seen like in CSS for example a setup that has RGB 0-255 but alpha at 0.0 - 1.0
Then I would agree to use 0-255 for colors. I might make a module to add Colorf class that has floating point colors to JS.
The Sphere 1.5/1.6 colors are created using
CreateColor(255,....)
. It uses ranges of 0 to 255: a char. That is very useful because 4 of those chars together form a color for the GPU. And storage of a full color is then the same size as 1 float. However, using floats ranging 0.0 to 1.0 has some advantages when doing math and has more precision. Even tho 0.5 gets converted to 127, it has purpose when doing more math.255/2*2 = 254.
What shall we do? It seems we can't have both in a reasonable way, as 1/255 and 1/1.0 overlap and we don't have types.