1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-13 19:50:31 +00:00

Add colours.rgb8(r, g, b)/colours.rgb8(hex)

This commit is contained in:
Lignum 2017-05-07 00:13:36 +02:00
parent a9e7acbec5
commit 1cc403191f
No known key found for this signature in database
GPG Key ID: 0889206F5A8A700D

View File

@ -35,3 +35,13 @@ end
function test( colors, color ) function test( colors, color )
return ((bit32.band(colors, color)) == color) return ((bit32.band(colors, color)) == color)
end end
function rgb8( r, g, b )
if type(r) == "number" and g == nil and b == nil then
return bit32.band( bit32.rshift( r, 16 ), 0xFF ) / 255, bit32.band( bit32.rshift( r, 8 ), 0xFF ) / 255, bit32.band( r, 0xFF ) / 255
elseif type(r) == "number" and type(g) == "number" and type(b) == "number" then
return r / 255, g / 255, b / 255
else
return nil
end
end