Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Bug reports ➜ colors.lua HSL->RGB conversion error

colors.lua HSL->RGB conversion error

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Hokken   USA  (18 posts)  Bio
Date Wed 24 Feb 2010 07:15 PM (UTC)
Message
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))
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 25 Feb 2010 02:17 AM (UTC)
Message
I fixed my copy. [commit ff39f81]

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hokken   USA  (18 posts)  Bio
Date Reply #2 on Fri 26 Feb 2010 04:11 AM (UTC)
Message
cheers!
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,557 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.