Created
January 6, 2014 09:41
-
-
Save emirikol/8280403 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def back_and_fore_color(color) | |
rgb = color.sub('#','').scan(/../).map {|c| c.to_i(16)} | |
fore_color = rgb.sum > 384 ? 'black' : 'white' | |
"background-color:#{color};color:#{fore_color};" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment