Skip to content

Instantly share code, notes, and snippets.

@emirikol
Created January 6, 2014 09:41
Show Gist options
  • Save emirikol/8280403 to your computer and use it in GitHub Desktop.
Save emirikol/8280403 to your computer and use it in GitHub Desktop.
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