Is it possible to check if a certain hexadecimal color is closer to FFF or 000 based on a defined ‘center-value’?
I want to check if a color lies closer to #FFF or #000 based on #888.
So if I check for #EFEFEF it should return #FFF and if I try #878787 it should return #000.
How can this be achieved? I’m not sure what to search for on Google…
Thanks in advance
The easiest way to solve your problem is to calculate the distance between colors using their greyscale values (there are other ways, but this is simple). So something like:
The output is: