yiq

Returns light when a color is dark and dark when a color is light (and a little more).

hex2rgb

Converts hex color to rgb and calculates appropriate corresponding foreground.