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:
parent
a9e7acbec5
commit
1cc403191f
@ -25,13 +25,23 @@ function combine( ... )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function subtract( colors, ... )
|
function subtract( colors, ... )
|
||||||
local r = colors
|
local r = colors
|
||||||
for n,c in ipairs( { ... } ) do
|
for n,c in ipairs( { ... } ) do
|
||||||
r = bit32.band(r, bit32.bnot(c))
|
r = bit32.band(r, bit32.bnot(c))
|
||||||
end
|
end
|
||||||
return r
|
return r
|
||||||
end
|
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
|
Loading…
Reference in New Issue
Block a user