colours.rb now accepts floating point RGB values as input
This commit is contained in:
parent
739b29d9b0
commit
38deb67752
1 changed files with 6 additions and 1 deletions
|
|
@ -13,7 +13,12 @@ if ARGV.size == 1
|
||||||
elsif ARGV.size == 3
|
elsif ARGV.size == 3
|
||||||
rgb = ARGV[0..2]
|
rgb = ARGV[0..2]
|
||||||
red,green,blue = *rgb
|
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
|
end
|
||||||
|
|
||||||
puts '#' + hex
|
puts '#' + hex
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue