It looks like you're new here. If you want to get involved, click one of these buttons!
function rgb2hex1(r, g, b) local rgb, i, m, hex, hexABC = r*65536 + g*256 + b, 0, 0, "", "0123456789ABCDEF" while rgb > 0 do i = i + 1 rgb, m = math.floor(rgb/16), math.fmod(rgb, 16) + 1 hex = string.sub(hexABC, m, m) .. hex end local switch = {[4] = "00" .. hex, [5] = "0" .. hex, [6] = hex} return "0x" .. switch[#hex] end function rgb2hex2(r, g, b) return r*65536 + g*256 + b end function hex2rbg(hex) local rgb, d = {}, {65536, 256, 1} for i = 1, 3 do rgb[i] = math.floor(hex/d[i]) hex = math.fmod(hex, d[i]) end return rgb[1], rgb[2], rgb[3] end print(rgb2hex1(163, 54, 90)) application:setBackgroundColor(rgb2hex2(163, 54, 90)) print(hex2rbg(0xA3365A)) |
Likes: octotod
Comments
Additionally:
Likes: sslivka
Sorry don't remember seeing anything like that, but if someone would have such component, it would most probably be @OZApps
Likes: OZApps
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975