1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +00:00

Fix colours.*RGB methods working with 8 bit values

They should have been using 0-1s instead. I'm a moron for not noting
this earlier, and not testing this.
This commit is contained in:
SquidDev 2019-02-23 23:20:46 +00:00
parent 35645b3d93
commit 1fb3d16b89

View File

@ -62,16 +62,19 @@ function packRGB( r, g, b )
error( "bad argument #3 (expected number, got " .. type( b ) .. ")", 2 )
end
return
bit32.band( r, 0xFF ) * 2^16 +
bit32.band( g, 0xFF ) * 2^8 +
bit32.band( b, 0xFF )
bit32.band( r * 255, 0xFF ) * 2^16 +
bit32.band( g * 255, 0xFF ) * 2^8 +
bit32.band( b * 255, 0xFF )
end
function unpackRGB( rgb )
if type( rgb ) ~= "number" then
error( "bad argument #1 (expected number, got " .. type( rgb ) .. ")", 2 )
end
return bit32.band( bit32.rshift( rgb, 16 ), 0xFF ), bit32.band( bit32.rshift( rgb, 8 ), 0xFF ), bit32.band( rgb, 0xFF )
return
bit32.band( bit32.rshift( rgb, 16 ), 0xFF ) / 255,
bit32.band( bit32.rshift( rgb, 8 ), 0xFF ) / 255,
bit32.band( rgb, 0xFF ) / 255
end
function rgb8( r, g, b )