Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert html color names into RGB values in Ruby?

Tags:

ruby

colors

gem

I know there is a gem called Color. I installed it.

But for the life of me, I can't figure out how to use the thing.

I just want to convert a color name into its RGB values, if possible without copying the whole color table into my code.

I want to be able to convert something like red or Navy into three numeric values.

like image 856
bastibe Avatar asked Feb 16 '11 10:02

bastibe


1 Answers

require 'color/css'
red_code = Color::CSS["red"].html
#=> "#ff0000"
like image 126
tokland Avatar answered Oct 04 '22 04:10

tokland