W3C home > Mailing lists > Public > www-style@w3.org > May 2010

Re: [css3-color] #rrggbbaa annotation

From: David Singer <singer@apple.com>
Date: Wed, 19 May 2010 17:01:28 -0700
Cc: Alex Meiburg <timeroot.alex@gmail.com>, www-style@w3.org
Message-Id: <19B5E0CB-EC6F-4ADC-9CAF-59A4ABCEC9B1@apple.com>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
I guess the alternative is to say that aa runs from 0 to 100, i.e. is a percentage, and values >100 are 'clamped'.  But it's not so clean, as it's read as hex.

On May 18, 2010, at 20:55 , Boris Zbarsky wrote:

> On 5/18/10 7:09 PM, Alex Meiburg wrote:
>> As for the mapping (from 0-255 to 0-1 float), this might be well based
>> in part off how UA's currently store the Alpha value. If a decimal is
>> actually rounded to a hex value and used like that.... great. I think
>> 0x80 should map to 0.50196078431372548 then.
> 
> Gecko stores alpha values as unsigned bytes (so integers in the range 0-255).
> 
> The only time this needs to be converted to decimal is for serialization.  I the alpha is 255, it's not serialized at all (that is, rgb() is used instead of rgba()).  Otherwise, the alpha value is serialized as either a two-digit decimal if that would round-trip correctly and as a three-digit decimal otherwise (though in practice it's possible that even the second digit is dropped in the two-digit case if it's 0; I didn't dig deep enough to make sure of that behavior).
> 
> So for example, for 0x80 == 128, the two-digit representation would be 0.50.  Since 0.50*255 = 127.5 and 127.5 gets rounded to 128, that means that we'll parse 0.50 as 0x80, and hence it's OK to serialize the opacity as 0.50.
> 
> -Boris
> 

David Singer
Multimedia and Software Standards, Apple Inc.
Received on Thursday, 20 May 2010 00:02:01 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:27 GMT