Jump to content

Solved


1LoL1

Recommended Posts

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 by Guest
Link to comment
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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...