From: Jeremy Hinegardner Date: 2007-12-01T05:12:38+09:00 Subject: Re: Convert HEX to RGB On Fri, Nov 30, 2007 at 07:59:15PM +0900, Eust?quio 'TaQ' Rangel wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > Ummm... This is a really clever solution, except if you have a hex value > > that you need to convert into an rgb array, it is probably a string, not > > an integer literal. Is there an easy way to convert a hex string > > directly into an integer literal? > > Gimme a good and old blue RGB: > > >> "101aff".scan(/../).map {|color| color.to_i(16)} > => [16, 26, 255] Or use color (http://rubyforge.org/projects/color/) require 'rubygems' require 'color' c = Color::RGB.from_html("101aff") c.css_rgb # => rgb(6.27%, 10.20%, 100.00%) [c.red, c.green, c.blue] # => [16.0, 26.0, 255.0] enjoy, -jeremy -- ======================================================================== Jeremy Hinegardner jeremy@hinegardner.org