Skip to content
This repository was archived by the owner on Apr 17, 2026. It is now read-only.

The color contrast check should use the most contrasting pixel instead of the average#11

Open
nanwng wants to merge 2 commits into
google:masterfrom
nanwng:colorContrastFix
Open

The color contrast check should use the most contrasting pixel instead of the average#11
nanwng wants to merge 2 commits into
google:masterfrom
nanwng:colorContrastFix

Conversation

@nanwng

@nanwng nanwng commented Apr 17, 2019

Copy link
Copy Markdown

The current behavior to average foreground color to check for contrast seems wrong.

  • correct behavior is to determine most contrasting pixel value
  • fix is to find foreground darkest and lightest pixel and compute ratio w/ background, then take the larger ratio value

@j-sid

j-sid commented Apr 18, 2019

Copy link
Copy Markdown
Contributor

Hi Nan, thanks for the PR.
A couple of comments: taking the most contrasting pixel values has its own disadvantages since most contrasting pixels may be fewer in number (especially when text is anti aliased), I suggest creating a new contrast check that uses your algorithm leaving the existing check as is.

@nanwng

nanwng commented Apr 18, 2019

Copy link
Copy Markdown
Author

Hi Nan, thanks for the PR.
A couple of comments: taking the most contrasting pixel values has its own disadvantages since most contrasting pixels may be fewer in number (especially when text is anti aliased), I suggest creating a new contrast check that uses your algorithm leaving the existing check as is.

Thanks for your response. I'll update it with a new rule.

@nanwng

nanwng commented Apr 22, 2019

Copy link
Copy Markdown
Author

@j-sid Can you take another look? Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants