[colours.rb] round instead of truncating float values for rgb
This commit is contained in:
parent
3119c30288
commit
b3bea60a8d
1 changed files with 3 additions and 3 deletions
|
|
@ -20,9 +20,9 @@ elsif ARGV.size == 3
|
||||||
red,green,blue = *rgb
|
red,green,blue = *rgb
|
||||||
if red.index('.') || green.index('.') || blue.index('.')
|
if red.index('.') || green.index('.') || blue.index('.')
|
||||||
redf, greenf, bluef = red, green, blue
|
redf, greenf, bluef = red, green, blue
|
||||||
red = (255 * red.to_f).to_i
|
red = (255 * red.to_f).round
|
||||||
green = (255 * green.to_f).to_i
|
green = (255 * green.to_f).round
|
||||||
blue = (255 * blue.to_f).to_i
|
blue = (255 * blue.to_f).round
|
||||||
end
|
end
|
||||||
hex = [red, green, blue].map {|n| to_hex(n) }.join
|
hex = [red, green, blue].map {|n| to_hex(n) }.join
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue