Ruby method to determine if a string would look more readable on black vs. white.
def self.ideal_font_color_for(hex_str) hex_str = hex_str.split('#').last threshold = 105 r = hex_str[0..1].hex g = hex_str[2..3].hex b = hex_str[4..5].hex delta = (r*0.299) + (g*0.587) + (b*0.114) 255 - delta < threshold ? "#000000" : "#FFFFFF" end