colors.lua HSL->RGB conversion error

Posted by Hokken on Wed 24 Feb 2010 07:15 PM — 3 posts, 14,279 views.

USA #0
I know this isn't Nick's file, but maybe he can get the maintainer to fix it.

symptom:
>> require("colors")
>> print(colors.new("#123456"):tint(1))
#100100100

anything with a luminance of 1.0 get converted into 256,256,256 instead of 255,255,255

fix:
diff "colors.lua" "\temp\colors.lua"
106,108c106,108
< return rgb_to_hsl(tonumber(rgb:sub(2,3), 16)/256,
< tonumber(rgb:sub(4,5), 16)/256,
< tonumber(rgb:sub(6,7), 16)/256)
---
> return rgb_to_hsl(tonumber(rgb:sub(2,3), 16)/255,
> tonumber(rgb:sub(4,5), 16)/255,
> tonumber(rgb:sub(6,7), 16)/255)
119c119
< local r, g, b = hsl_to_rgb(self.H, self.S, self.L)
---
> -- local r, g, b = hsl_to_rgb(self.H, self.S, self.L)
123c123
< buffer = buffer..string.format("%02x",math.floor(v*256+0.5))
---
> buffer = buffer..string.format("%02x",math.floor(v*255+0.5))
Australia Forum Administrator #1
I fixed my copy. [commit ff39f81]
USA #2
cheers!