Re: [css3-color] #rrggbbaa annotation

Boris Zbarsky wrote:
> On 5/15/10 12:37 AM, Alan Gresley wrote:
>> 0x00 maps to 0
>> 0x80 maps to 0.5
>> 0xFF maps to 1.0
> 
> I would think that Tab's issue was that while 1.0 - 0.5 == 0.5 - 0, 0xFF 
> - 0x80 != 0x80 - 0x00.
> 
> So the real question is why 0x80 wouldn't map to 0.50196078431372548 if 
> we're going from hex to float.


0x80 would map to 0.50196078431372548. You can not have a true halfway 
value. You have two sets of hexadecimals.

0#,1#,2#,3#,4#,5#,6#,7# (127 steps and 128 values)

     _0.5 between two hexadecimals sets_

8#,9#,A#,B#,C#,D#,E#,F# (128 steps and 128 values)

This is since each color channel (rgb) has 255 steps but 256 values. 
You can not divide 255 evenly so 0x80 is the closes to 0.5.

Two questions:


1. What does the '0x' represent in 0x00?

2. What does float represent in where you write, "going from hex to 
float"?


> Or put another way, if we have a set of 256 (really, any even number 
> will do) discrete values, there is no way to place them on the closed 
> unit interval in such a way that the spacing between two adjacent values 
> is a constant and one of the values lands on 0.5.
> 
> -Boris


Correct, please see above :-)


-- 
Alan http://css-class.com/

Armies Cannot Stop An Idea Whose Time Has Come. - Victor Hugo

Received on Saturday, 15 May 2010 06:20:58 UTC