troubleshooting Question

calculate contrast of two colors

Avatar of x_terminat_or_3
x_terminat_or_3 asked on
1 Comment1 Solution392 ViewsLast Modified:
Hi all

I would like to include a warning in our product when a user picks a background color that is not contrasting enough with the foreground color.  Like say, cream on white background?  Or red on maroon background?

We only work with colors by there hex values, valid color notations are: #+hex string <=6 chars, obviouslly padded with zerros for the missing values, and adhering to the standard of #rrggbb

So how would I do it?  Compare the colors based on their decimal value and define a minimum treshold?  Do so for each of the colors (r, g, b)?

Any suggestions, or real life experience?


Ramses aka x_terminat_or_3
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros