Skip to content

Instantly share code, notes, and snippets.

@nerdEd
Created April 16, 2010 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerdEd/368983 to your computer and use it in GitHub Desktop.
Save nerdEd/368983 to your computer and use it in GitHub Desktop.
def convert(str)
x = str.to_i(base=16)
x/255.0
end
hex_value = ARGV[0].strip
alpha = ARGV[1] || 1.0
red, green, blue = convert(hex_value[0,2]), convert(hex_value[2,2]), convert(hex_value[3,2])
puts "Red: #{red}"
puts "Green: #{green}"
puts "Blue: #{blue}"
puts "Alpha: #{alpha}"
puts "[UIColor colorWithRed:#{red} green:#{green} blue:#{blue} alpha:#{alpha}]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment