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

Contrast ratios should account for alpha transparency #91

Open
mirisuzanne opened this issue Aug 8, 2023 · 7 comments · May be fixed by #222
Open

Contrast ratios should account for alpha transparency #91

mirisuzanne opened this issue Aug 8, 2023 · 7 comments · May be fixed by #222
Assignees
Labels
a11y Improvements for a more accessible experience bug Something isn't working sprint: current

Comments

@mirisuzanne
Copy link
Member

mirisuzanne commented Aug 8, 2023

Scope

  • add alert beside ratio letting people know that it is an estimate

Mockups

Background Alpha Alert + Color Issue Info
https://www.figma.com/file/JtQTGIpwoaOcqcWfsoeOk1/Browser-bugs-%26-other-warnings?type=design&node-id=112-2&mode=design&t=lOyosYvXrteuMN5Z-0

Foreground Alpha Alert
https://www.figma.com/file/JtQTGIpwoaOcqcWfsoeOk1/Browser-bugs-%26-other-warnings?type=design&node-id=12%3A348&mode=design&t=4CwzTDrU2fakSiQ4-1

Mobile Alerts + Color Issue Info
https://www.figma.com/file/JtQTGIpwoaOcqcWfsoeOk1/Browser-bugs-%26-other-warnings?type=design&node-id=83%3A10&mode=design&t=4CwzTDrU2fakSiQ4-1

Mobile Alerts + Color Issue Info 2
https://www.figma.com/file/JtQTGIpwoaOcqcWfsoeOk1/Browser-bugs-%26-other-warnings?type=design&node-id=83%3A11&mode=design&t=4CwzTDrU2fakSiQ4-1

Requested on social media:

Look at contrast-ratio, originally made by Lea Verou. It handles foreground and background colors with alpha. When the background color has alpha, the contrast value has "error bars;" I think what it does is calculate what the resulting background color would be if there was black behind it, what it would be with white behind it, then calculate the contrast of those vs. the foreground color. The +- number represents those black/white extremes and the main number is the middle point between them.

@patrickhlauke
Copy link

Similarly, CCAe does alpha (but only for the foreground, since if you start doing it for background as well, you have to always make an assumption (generally, white) for what's behind that particular colour https://github.com/ThePacielloGroup/CCAe

@mirisuzanne mirisuzanne added the a11y Improvements for a more accessible experience label Aug 14, 2023
@jamesnw jamesnw self-assigned this Aug 14, 2023
@jamesnw
Copy link
Contributor

jamesnw commented Aug 16, 2023

Because #106 will handle background colors with alpha, this will just be limited to addressing alpha in the foreground color.

In essence, contrast is a measure of the difference between two displayed colors. Foreground colors with alpha are not displayed as transparent, but rather as a third color mixed with the background color. Ideally, we would want to get the contrast between the background and the mixed color, which requires us to compute a mixed color.

In practice, that mixed color is computed at display time, based on the display's settings. If we calculate the mixed color in the space that the other colors are defined in, we're not doing a similar calculation. This can lead to a range of results, even between monitors on the same computer.

Because color mixing for monitors is done in an RGB space, we'll do all the mixing in srgb. This matches the current behavior of both CCAe and contrast-ratio.

Despite the fuzziness that comes into play when alpha is involved, it is useful for designers to see an approximation of what the mixed color will be and what its contrast is, so that they can see approximately what level of transparency still passes.

@mirisuzanne
Copy link
Member Author

We may just want to mark this as approximate in some way?

@SondraE
Copy link
Contributor

SondraE commented Nov 16, 2023

@stacyk
Copy link
Member

stacyk commented Nov 16, 2023

@SondraE I think the first and last link are the same, no? Is that the intention?

@stacyk
Copy link
Member

stacyk commented Nov 16, 2023

https://www.figma.com/file/JtQTGIpwoaOcqcWfsoeOk1/Browser-bugs-%26-other-warnings?type=design&node-id=5-146&mode=design&t=fz0z6iKhkUnjtRs7-4 this might be the link for the first one

@mirisuzanne
Copy link
Member Author

This is the same set of issues and links provided in the other story, right? I guess we don't need to break out individual stories - but it might be helpful to clarify which designs are related to which issue :)

@SondraE SondraE removed their assignment Nov 22, 2023
@stacyk stacyk removed their assignment Jan 2, 2024
@jamesnw jamesnw linked a pull request Dec 10, 2024 that will close this issue
1 task
@jamesnw jamesnw linked a pull request Dec 10, 2024 that will close this issue
1 task
@jamesnw jamesnw assigned mirisuzanne and stacyk and unassigned jamesnw Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Improvements for a more accessible experience bug Something isn't working sprint: current
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants