From 38deb677529080fec63be96ded184dba4d42ca7a Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Tue, 10 Aug 2010 10:41:19 -0700 Subject: [PATCH] colours.rb now accepts floating point RGB values as input --- colours.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/colours.rb b/colours.rb index c8bc951..ec4e9f8 100755 --- a/colours.rb +++ b/colours.rb @@ -13,7 +13,12 @@ if ARGV.size == 1 elsif ARGV.size == 3 rgb = ARGV[0..2] red,green,blue = *rgb - hex = rgb.map {|n| n.to_i.to_s(16)}.join + if red.index '.' + red = (255 * red.to_f).to_i + green = (255 * green.to_f).to_i + blue = (255 * blue.to_f).to_i + end + hex = [red, green, blue].map {|n| n.to_i.to_s(16)}.join end puts '#' + hex