Ensure bg/fg have sufficient contrast

Loved your little script, but agreed with @SyedMusaAli RE color contrast. I think this makes it a bit better - it was a toss up between performance and contrast in the end. It's based on http://www.w3.org/WAI/GL/WCAG20/WD-WCAG20-TECHS/G18 

Because the foreground now takes a number of iterations I had to put in a callback - which isn't really in keeping with the existing structure of your code. If I get time tomorrow over lunch I might take another stab at it :)

There are still some color combos coming through - almost always when they're of the same hue [but still have a higher than 4.5 contrast ratio]. A way past this could be second metric within isContrasty that tests if the hue is similar... but I think that may be too costly performance wise.