Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 14/11/2016
- --Last update: 14/11/2016
- --[[ Notes:
- color.rgb
- Does:
- Transforma uma cor hexadecimal em RGB (Red Green Blue)
- Args:
- hex --> A cor em hexadecimal
- color.hex
- Does:
- Transforma uma cor RGB (Red Green Blue) em hexadecimal (Retorna o hex e o #hex)
- Args:
- r --> A cor red
- g --> A cor green
- b --> A cor blue
- color.neg
- Does:
- Transforma em negativa uma cor hexadecimal
- Args:
- hex --> A cor em hexadecimal
- ]]--
- color = {}
- color.rgb = function(hex)
- local r = bit32.band(bit32.rshift(hex,16),0xFF)
- local g = bit32.band(bit32.rshift(hex,8),0xFF)
- local b = bit32.band(hex,0xFF)
- return r,g,b
- end
- color.hex = function(r,g,b)
- local hex = bit32.lshift(r,16) + bit32.lshift(g,8) + b
- return hex,string.format("%x",hex)
- end
- color.neg = function(hex)
- return 0xFFFFFF - hex
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement