[webkit-dev] Proposal for serializing alpha channel values; request for algorithm help

L. David Baron dbaron at dbaron.org
Fri Nov 6 15:45:21 PST 2015

On Friday 2015-11-06 07:16 -0800, Darin Adler wrote:
> > On Nov 5, 2015, at 11:24 PM, L. David Baron <dbaron at dbaron.org> wrote:
> > 
> > For what it's worth, Gecko does have code to produce a
> > minimal-length alpha value.  nsStyleUtil::ColorComponentToFloat just
> > tries rounding to 2 decimal places, sees if the resulting float
> > round-trips back to the same 0-255 alpha value, and if it doesn't,
> > rounds to 3 places.
> Got it. Sounds like it does what I have in mind. Except that given what you say it sounds like it doesn’t use a single decimal place even if that round trips, so for 51 it uses 0.20 rather than 0.2.

The float -> string code handles that, though, so it does come out
as 0.2.


𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                          https://www.mozilla.org/   𝄂
             Before I built a wall I'd ask to know
             What I was walling in or walling out,
             And to whom I was like to give offense.
               - Robert Frost, Mending Wall (1914)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.webkit.org/pipermail/webkit-dev/attachments/20151107/b8c98def/attachment.sig>

More information about the webkit-dev mailing list