mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-06-10 18:44:12 +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 )
|
error( "bad argument #3 (expected number, got " .. type( b ) .. ")", 2 )
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
bit32.band( r, 0xFF ) * 2^16 +
|
bit32.band( r * 255, 0xFF ) * 2^16 +
|
||||||
bit32.band( g, 0xFF ) * 2^8 +
|
bit32.band( g * 255, 0xFF ) * 2^8 +
|
||||||
bit32.band( b, 0xFF )
|
bit32.band( b * 255, 0xFF )
|
||||||
end
|
end
|
||||||
|
|
||||||
function unpackRGB( rgb )
|
function unpackRGB( rgb )
|
||||||
if type( rgb ) ~= "number" then
|
if type( rgb ) ~= "number" then
|
||||||
error( "bad argument #1 (expected number, got " .. type( rgb ) .. ")", 2 )
|
error( "bad argument #1 (expected number, got " .. type( rgb ) .. ")", 2 )
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function rgb8( r, g, b )
|
function rgb8( r, g, b )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user