Imagine you're in a game where your opponent picks the background colour
of your webpage, in #RRGGBB format, and you have to pick the foreground
text colour that contrasts best with their choice. I realise that this
task is almost impossible given various forms of colour-blindness, but
my target audience is unlikely to be colour-blind (bomb disposal people
don't last long if they cannot tell live from neutral) so we can assume
perfect vision.
If they pick #000000 then of course your text would be #FFFFFF (and vice
versa).
If they picked #FF0000 then the choice is less obvious. #00FFFF seems to
offer the best "mathematic al" contrast, but in tests, (to my eyes)
#FFFFFF is a better contrast. See http://swiftys.org.uk/contrast.html
where I am playing with this concept.
If they pick a background of #7F7F7F then yellow (FFFF00) or cyan
(00FFFF) offer a good contrast, but magenta (FF00FF) is truly horrible.
This may be an artefact either of my display, or my use of TrueType, but
my HTML cannot possibly know about either of these facts.
Can anyone offer an algorithm that would do a reasonable job faced with
an arbitrary background colour? I'd hate to end up with a lookup table
containing 16,777,216 rows!
--
Steve Swift
of your webpage, in #RRGGBB format, and you have to pick the foreground
text colour that contrasts best with their choice. I realise that this
task is almost impossible given various forms of colour-blindness, but
my target audience is unlikely to be colour-blind (bomb disposal people
don't last long if they cannot tell live from neutral) so we can assume
perfect vision.
If they pick #000000 then of course your text would be #FFFFFF (and vice
versa).
If they picked #FF0000 then the choice is less obvious. #00FFFF seems to
offer the best "mathematic al" contrast, but in tests, (to my eyes)
#FFFFFF is a better contrast. See http://swiftys.org.uk/contrast.html
where I am playing with this concept.
If they pick a background of #7F7F7F then yellow (FFFF00) or cyan
(00FFFF) offer a good contrast, but magenta (FF00FF) is truly horrible.
This may be an artefact either of my display, or my use of TrueType, but
my HTML cannot possibly know about either of these facts.
Can anyone offer an algorithm that would do a reasonable job faced with
an arbitrary background colour? I'd hate to end up with a lookup table
containing 16,777,216 rows!
--
Steve Swift
Comment