Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-color-4] Should premultiplied undefined alpha make other color components undefined? #7253

Closed
facelessuser opened this issue May 5, 2022 · 2 comments
Assignees
Labels
Closed Accepted as Obvious Bugfix Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-color-4 Current Work

Comments

@facelessuser
Copy link

Reading over the spec, it seems that if the alpha component is none, that all the associated color components will also become none. This seems unintuitive (at least to me). To me, it would seem that premultiplication should not be performed if alpha is none:

>>> Color('color(srgb 1 0 0 / 0.5)').mix('color(srgb 0 0 1 / none)', space='srgb')
color(srgb 0.5 0 0.5 / 0.5)
>>> Color('color(srgb 1 0 0 / 0.5)').mix('color(srgb 0 0 1 / none)', space='srgb', premultiplied=True)
color(srgb 1 0 0 / 0.5)

I guess, what I expected to happen was for it to behave as if premultiplied was disabled, because how can you premultiply if you don't know by what to premultiply? This would just take alpha out of the calculation.

>>> Color('color(srgb 1 0 0 / 0.5)').mix('color(srgb 0 0 1 / none)', space='srgb')
color(srgb 0.5 0 1 / 0.5)
>>> Color('color(srgb 1 0 0 / 0.5)').mix('color(srgb 0 0 1 / none)', space='srgb', premultiplied=True)
color(srgb 0.5 0 1 / 0.5)

There may be reasons for this, but I am curious if there is something driving this decision, or if maybe it just wasn't considered.

@facelessuser facelessuser changed the title Should premultiplied undefined alpha make other color components undefined? [css-color-4] Should premultiplied undefined alpha make other color components undefined? May 5, 2022
@svgeesus
Copy link
Contributor

svgeesus commented May 5, 2022

Alpha being none was forgotten about for premultiplication.

If any component value is none, the premultiplied value is also none.

That is referring to the color components only, not the alpha. However, we didn't forget for un-premultiplication, if alpha was 0:

If the alpha value is zero, the un-premultiplied value is the premultiplied value

So I propose to fix that, in premultiplication:

If the alpha value is none, the premultiplied value is the un-premultiplied value

and in un-premultiplication:

If the alpha value is zero or none, the un-premultiplied value is the premultiplied value

@svgeesus svgeesus self-assigned this May 5, 2022
@svgeesus svgeesus added the css-color-4 Current Work label May 5, 2022
@facelessuser
Copy link
Author

That sounds great to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted as Obvious Bugfix Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-color-4 Current Work
Projects
None yet
Development

No branches or pull requests

2 participants