mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-12 11:10:29 +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:
parent
35645b3d93
commit
1fb3d16b89
@ -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 )
|
||||
|
Loading…
Reference in New Issue
Block a user