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

Retain hue when contrast shifts luminance in other direction #3845

Closed
Tyriar opened this issue Jun 1, 2022 · 0 comments · Fixed by #3929
Closed

Retain hue when contrast shifts luminance in other direction #3845

Tyriar opened this issue Jun 1, 2022 · 0 comments · Fixed by #3929

Comments

@Tyriar
Copy link
Member

Tyriar commented Jun 1, 2022

Currently if contrast can't be met going the natural direction, we switch and go the other direction but this is done by using the background as the foreground:

image

Code:

if (resultARatio < ratio) {
const resultB = increaseLuminance(bgRgba, bgRgba, ratio);
const resultBRatio = contrastRatio(bgL, rgb.relativeLuminance(resultB >> 8));
return resultARatio > resultBRatio ? resultA : resultB;
}

if (resultARatio < ratio) {
const resultB = reduceLuminance(bgRgba, bgRgba, ratio);
const resultBRatio = contrastRatio(bgL, rgb.relativeLuminance(resultB >> 8));
return resultARatio > resultBRatio ? resultA : resultB;
}

More ideal would be to retain the hue of the original color, so we would continue to use fgRgba here which should make the folder above still have a blue hue and the branch still have a yellow hue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant