[csswg-drafts] [css-color-3][css-color-4] why opacity is applied on premultiplied color ? (#7640)

letochagone has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color-3][css-color-4] why opacity is applied on premultiplied color ? ==
![image](https://user-images.githubusercontent.com/7129968/186257534-975cd683-fe8e-4e57-a7ea-c5610046d7f1.png)

I'm trying to figure out how the resulting color is calculated in the above div ( the div containing the opacity style )

First of all i calculated the composition of the inner div on the first div 
I apply the simple alpha compositing : 

co = Cs * as + Cb * ab * ( 1- as)
ao = as + ab *  ( 1 - as)

here the Cs is the inner div and the Cb is the outer div (the one that contains the opacity style.
Cs = ( 0 , 77/255 , 100/255 ) 
as = 0.8
Cb = ( 155/255 , 66/255 , 200/255 ) 
ab = 0.5

after calculation : 

co = ( 0.06 , 0.27 , 0.39 )
ao  = 0.9

this color obtained after compositing is premultiplied

I multiply all RGB and A by the opacity value

**co = co * 0.6
ao = ao * 0.6**

co = ( 0.04 , 0.16 , 0.23 ) 
ao = 0.54

finally I compose this color with the color of the body ( rgb=1,1,1 alpha=1) As this color is premultiplied, I apply the formula:
 co + (1,1,1) * 1 * (1 - ao)
= 0.5 , 0.62 , 0.69

this result corresponds to the one after a screenshot and the reading of the color of a point of the displayed div

The formulas that I applied are not from my intuition, but after several tests of other forms of calculation

My question is :
why is opacity applied to premultiplied terms?

I tried to apply after premultiplication but the screenshot gives a difference.


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7640 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 23 August 2022 20:44:18 UTC