With this function you can get the inverse of a color passed into as a hex value.
Contextual Ads
More Ruby Resources
Advertisement
def InvertColor(hexColor)
hexColor.gsub!(/^#/, '')
sprintf("%X", hexColor.hex ^ 0xFFFFFF) # Hex operation to get the inverse
end
# Sample use: InvertColor('#FFFFFF')