I found this formula to convert decimal numbers to hexadecimal color values in Lua:
http://lua-users.org/lists/lua-l/2004-09/msg00054.html
However, I have a few questions about the formula:
Thanks!!
In Lua 5.x you can use the string.format function with the %x
format specifier to convert integers to their hexadecimal representation. In your case it would look like this:
local input = 0.5
local output = string.format("%x", input * 255) -- "7F"
I don't know Lua 4.0.1 well so I can't tell you if this function is available (perhaps under a different name). That said, if its not, then you might be able to workaround by turning this into a C function that uses sscanf
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With