1LoL1 Posted February 7, 2016 Share Posted February 7, 2016 (edited) Hello, i need help. I know what is "getColorFromString" Example: color = "#00FF00" r, g, b = getColorFromString(color) -- result: 0, 255, 0 but my question is how i can to hex of RGB? Example: color = "0, 255, 0" -- result: 00FF00 how i can to this? please can anyone help me? Edited February 7, 2016 by Guest Link to comment
SpecT Posted February 7, 2016 Share Posted February 7, 2016 local r,g,b = 0,255,130 local n1 = toHex(r) local n2 = toHex(g) local n3 = toHex(b) function toHex ( n ) local hexnums = {"0","1","2","3","4","5","6","7", "8","9","a","b","c","d","e","f"} local str,r = "",n%16 if n-r == 0 then str = hexnums[r+1] else str = toHex((n-r)/16)..hexnums[r+1] end return str end Link to comment
1LoL1 Posted February 7, 2016 Author Share Posted February 7, 2016 local r,g,b = 0,255,130 local n1 = toHex(r) local n2 = toHex(g) local n3 = toHex(b) function toHex ( n ) local hexnums = {"0","1","2","3","4","5","6","7", "8","9","a","b","c","d","e","f"} local str,r = "",n%16 if n-r == 0 then str = hexnums[r+1] else str = toHex((n-r)/16)..hexnums[r+1] end return str end oh work thanks !!!. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now