mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
Add helper functions to pack colors into integers.
This removes the need to create an instance of the Color3 or Color4 classes just to obtain a packed color integer.
This commit is contained in:
parent
a71b45567a
commit
4327eaf72c
@ -813,6 +813,38 @@ Color3 GetColor(CSStr name)
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static SQInteger SqPackRGB(SQInteger r, SQInteger g, SQInteger b)
|
||||
{
|
||||
return static_cast< Int32 >(SQMOD_PACK_RGB(
|
||||
ConvTo< Uint8 >::From(r),
|
||||
ConvTo< Uint8 >::From(g),
|
||||
ConvTo< Uint8 >::From(b)
|
||||
));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static SQInteger SqPackRGBA(SQInteger r, SQInteger g, SQInteger b, SQInteger a)
|
||||
{
|
||||
return static_cast< Int32 >(SQMOD_PACK_RGBA(
|
||||
ConvTo< Uint8 >::From(r),
|
||||
ConvTo< Uint8 >::From(g),
|
||||
ConvTo< Uint8 >::From(b),
|
||||
ConvTo< Uint8 >::From(a)
|
||||
));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static SQInteger SqPackARGB(SQInteger r, SQInteger g, SQInteger b, SQInteger a)
|
||||
{
|
||||
return static_cast< Int32 >(SQMOD_PACK_ARGB(
|
||||
ConvTo< Uint8 >::From(a),
|
||||
ConvTo< Uint8 >::From(r),
|
||||
ConvTo< Uint8 >::From(g),
|
||||
ConvTo< Uint8 >::From(b)
|
||||
));
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_Base(HSQUIRRELVM vm)
|
||||
{
|
||||
@ -830,7 +862,9 @@ void Register_Base(HSQUIRRELVM vm)
|
||||
.Func(_SC("ClampMaxF"), &ClampMax< SQFloat >)
|
||||
.Func(_SC("NextPow2"), &NextPow2)
|
||||
.Func(_SC("SToB"), &SToB)
|
||||
.Func(_SC("GetColor"), &GetColor);
|
||||
.Func(_SC("PackRGB"), &SqPackRGB)
|
||||
.Func(_SC("PackRGBA"), &SqPackRGBA)
|
||||
.Func(_SC("PackARGB"), &SqPackARGB);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
Loading…
Reference in New Issue
Block a user