linebender / color

Color in Rust.
Apache License 2.0
32 stars 4 forks source link

Relative luminance for `AlphaColor` and `PremulColor` #49

Open waywardmonkeys opened 3 hours ago

waywardmonkeys commented 3 hours ago

I noticed that we don't have relative_luminance for AlphaColor and I assume that's because this formulation isn't as useful when there's alpha involved. But for DynamicColor, we just discard the alpha. But we also don't have this function for PremulColor ...

Should we have it for AlphaColor and discarding the Alpha?

Should we have it for PremulColor?

I don't have good arguments in favor of having it, so I'm just asking so we can have a decision.

raphlinus commented 3 hours ago

Those are the reasons I didn't add it. My feeling is we don't add the methods unless there's specific call for them.

The motivation for it in DynamicColor is to support CSS Color 5 contrast-color adequate contrast logic. Of course, if you think about it, the idea is pretty broken when alpha is involved, so it might end up being one of those poorly thought through things the web is full of.

Not having it in the static color alpha types may encourage people to resolve to opaque color, which is sensible.

waywardmonkeys commented 3 hours ago

There was also discussion of WCAG 3 using a different algorithm, like APCA: https://github.com/Myndex/SAPC-APCA

But that looks like it went dormant (in the W3 Silver Wiki).