Skip to content

Retain hue when contrast shifts luminance in other direction #3845

@Tyriar

Description

@Tyriar

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions