I've been trying to understand how Chrome calculate transparency color in whole day. And also I've seen same linear interpolation alpha * forground_color + (1 - alpha) * background_color
formula thousand times on the internet. It works if background was white. But if background is not white Chrome gives me different resulting values...
For example:
.bg {
background-color: #666; /* or rgb(102, 102, 102) */
width: 120px;
height: 120px;
padding: 10px;
}
.fg {
background-color: rgba(255, 0, 0, .87);
width: 100%;
height: 100%;
}
<div class="bg">
<div class="fg"></div>
</div>
Expecting value was rgb(235, 13, 13)
but Chrome gives me rgb(236, 31, 27)
.
Even though background is gray and foreground green and blue components are 0 resulting value is rgb(236, 31, 27)
. How come resulting value's green and blue components are different from each other? And itsn't even close resulting value 102 * (1 - .87) = 102 * .13 = 13.26
. I tried many other color combinations. Chrome doesn't linearly blending colors if background is not white. Can you tell me how Chrome calculate transparency color?