enzoDs Posted March 16, 2020 Share Posted March 16, 2020 Hello, i need transform R,G,B color to alphanumeric code (EX: 255,255,255 to #FFFFFF) with a function Thanks :D! Link to comment
Addlibs Posted March 16, 2020 Share Posted March 16, 2020 (edited) function RGBToHex(red, green, blue, alpha) -- Make sure RGB values passed to this function are correct if( ( red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 ) or ( alpha and ( alpha < 0 or alpha > 255 ) ) ) then return nil end -- Alpha check if alpha then return string.format("#%.2X%.2X%.2X%.2X", red, green, blue, alpha) else return string.format("#%.2X%.2X%.2X", red, green, blue) end end From MTA wiki useful functions, by NeonBlack Edited March 16, 2020 by MrTasty 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