Skip to content

Instantly share code, notes, and snippets.

@bastengao
Created August 28, 2014 02:02
Show Gist options
  • Save bastengao/9c540de21cae6408a789 to your computer and use it in GitHub Desktop.
Save bastengao/9c540de21cae6408a789 to your computer and use it in GitHub Desktop.
convert rgba color to hex color
require 'color'
jqplot_colors = [
"240, 192, 19, 1",
"217, 135, 20, 1",
" 16, 178, 199, 1",
" 15, 153, 168, 1",
"235, 155, 220, 1",
"247, 57, 197, 1",
"220, 237, 203, 1",
"239, 242, 143, 1",
" 72, 171, 154, 1",
" 16, 178, 199, 1",
"144, 198, 198, 1",
"117, 215, 124, 1",
"222, 203, 45, 1",
"222, 141, 45, 1",
"222, 108, 45, 1"
]
hex_colors = jqplot_colors.collect do |rgb|
rgba = rgb.split(',')
rgb = rgba[0..-1].collect { |c| c.strip.to_i }
Color::RGB.new(rgb[0], rgb[1], rgb[2]).html
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment