Advertisement
Bolodefchoco_LUAXML

[Biblioteca] Color

Nov 14th, 2016
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 14/11/2016
  3. --Last update: 14/11/2016
  4. --[[ Notes:
  5.     color.rgb
  6.         Does:
  7.             Transforma uma cor hexadecimal em RGB (Red Green Blue)
  8.         Args:
  9.             hex --> A cor em hexadecimal
  10.     color.hex
  11.         Does:
  12.             Transforma uma cor RGB (Red Green Blue) em hexadecimal (Retorna o hex e o #hex)
  13.         Args:
  14.             r --> A cor red
  15.             g --> A cor green
  16.             b --> A cor blue
  17.     color.neg
  18.         Does:
  19.             Transforma em negativa uma cor hexadecimal
  20.         Args:
  21.             hex --> A cor em hexadecimal
  22. ]]--
  23.  
  24. color = {}
  25.  
  26. color.rgb = function(hex)
  27.     local r = bit32.band(bit32.rshift(hex,16),0xFF)
  28.     local g = bit32.band(bit32.rshift(hex,8),0xFF)
  29.     local b = bit32.band(hex,0xFF)
  30.     return r,g,b
  31. end
  32.  
  33. color.hex = function(r,g,b)
  34.     local hex = bit32.lshift(r,16) + bit32.lshift(g,8) + b
  35.     return hex,string.format("%x",hex)
  36. end
  37.  
  38. color.neg = function(hex)
  39.     return 0xFFFFFF - hex
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement