From: Jeremy Hinegardner Date: 2007-12-01T12:01:54+09:00 Subject: Re: Convert HEX to RGB On Sat, Dec 01, 2007 at 09:18:55AM +0900, Austin Ziegler wrote: > On 11/30/07, Jeremy Hinegardner wrote: > > 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] > > Why thank you, Jeremy. ;) > > What's beautiful about the Color rubygem is that it's a lot more than > just RGB, too. Much much more. > > -austin, thinking he should try to conscript Jeremy into helping out > with Color again... Yup, count me in. enjoy, -jeremy -- ======================================================================== Jeremy Hinegardner jeremy@hinegardner.org