mixinmax / jquery.swatches

A jQuery plugin that turns a one-line div into a sweet color swatch
http://maxmackie.github.io/jquery.swatches/
243 stars 26 forks source link

Color codes on dark colors #10

Open macik opened 11 years ago

macik commented 11 years ago

Text color of codes for dark colors should be inverted or highlighted to be normally viewed. (Now it's very dark and not readable.)

mixinmax commented 11 years ago

Yeah I agree. Someone would have to test to find out what the threshold for a "dark" colour is, then we could just invert the color in the css if its below that.

macik commented 11 years ago

The basic formula to calculate brightness from RGB is:

Y(brightness) = 0.299 * R + 0.587 * G + 0.114 * B;

So you get 0-255 range of color brightness. Then just select any threshold (for example 64 or less).

mixinmax commented 11 years ago

Oh cool, I didn't know that. I'll implement this in the coming days, thanks.