joscas
joscas

Reputation: 7674

Color code from name

In C#, you can get a color code from its name: Color.FromName("Red").

Is there something similar in Ruby?

Upvotes: 0

Views: 123

Answers (1)

Dave Newton
Dave Newton

Reputation: 160170

$ gem install color
$ irb
> require 'color/css'
> Color::CSS["blue"]
=> RGB [#0000ff] 
> Color::CSS["blue"].html
=> "#0000ff" 

But that's not all!

> Color::CSS["blue"].pdf_fill
=> "0.000 0.000 1.000 rg" 
> Color::CSS["blue"].to_cmyk
=> CMYK [100.00%, 100.00%, 0.00%, 0.00%] 

Upvotes: 8

Related Questions