Clean up case statement in trucolor.cr

This commit is contained in:
Donovan Glover 2017-11-13 12:09:32 -05:00
parent 5517a31687
commit 8995a60167
No known key found for this signature in database
GPG Key ID: 8FC5F7D90A5D8F4D

View File

@ -34,24 +34,15 @@ module Trucolor
f = n - 43 * h
t = f * 255 / 43
q = 255 - t
case h
when 0
return {255, t, 0}
when 1
return {q, 255, 0}
when 2
return {0, 255, t}
when 3
return {0, q, 255}
when 4
return {t, 0, 255}
when 5
return {255, 0, q}
else
return {0, 0, 0}
when 0; return {255, t, 0}
when 1; return {q, 255, 0}
when 2; return {0, 255, t}
when 3; return {0, q, 255}
when 4; return {t, 0, 255}
when 5; return {255, 0, q}
end
return {0, 0, 0}
end
# Tests the format method by printing a rainbow of colors