Why do browsers display rgba differently on OSX?

I tried to encode some color manipulation code and lingered with alpha for a long time, then I (after 2 hours) implemented browsers displaying rgba differently.

I created this test: http://jsbin.com/adekez/2/ add / modify to view the code

Here are the results in 4 browsers in OSX Lion: http://imgur.com/g2iqu

This is an element with a rgba background (0,0,0,0,5) over white.

My hex calculator says: FF รท 2 = 7F.8, which means

Safari on # 808080 is faithful to Firefox on # 7F7F7F disabled on 1 Opera in # 7E7E7E disabled on 2 Chrome on # 929292 disabled

What happens here, is it a bug in Chrome or I just donโ€™t know about colors (true)?

+4
source share
2 answers

At first

Well, actually Safari and Firefox are correct: 0xFF = 255 , 255 / 2 = 127.5 . So 128 may be correct ( 0x80 ), but also 127 ( 0x7F ) - depending on the browser rounding agreement.

Explanation of the problem

These are rounding issues. I donโ€™t quite understand why rounding problems arise, since 0.5 is represented in binary numbers without loss of precision, but actually there are rounding problems:

Opera: Opera screenshots

Chrome: Chrome Screenshot

+1
source

When I checked chrome and safari, but I had the same rgba color # 808080 in both. Let us know which version of browser you are using.

rgba alpha value issue

0
source

Source: https://habr.com/ru/post/1397159/


All Articles