2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Base/Color3.hpp"
|
|
|
|
#include "Base/Color4.hpp"
|
|
|
|
#include "Base/Shared.hpp"
|
2016-08-24 22:17:09 +02:00
|
|
|
#include "Base/DynArg.hpp"
|
2020-09-03 19:33:51 +02:00
|
|
|
#include "Base/Buffer.hpp"
|
2016-06-05 03:15:23 +02:00
|
|
|
#include "Library/Numeric/Random.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
2016-03-21 21:37:58 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include <limits>
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
2016-11-15 20:20:10 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQMODE_DECL_TYPENAME(Typename, _SC("Color3"))
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const Color3 Color3::NIL = Color3();
|
2016-03-22 01:05:50 +01:00
|
|
|
const Color3 Color3::MIN = Color3(std::numeric_limits< Color3::Value >::min());
|
|
|
|
const Color3 Color3::MAX = Color3(std::numeric_limits< Color3::Value >::max());
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQChar Color3::Delim = ',';
|
2020-09-03 20:05:38 +02:00
|
|
|
bool Color3::UpperCaseHex = false;
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2020-03-22 08:16:40 +01:00
|
|
|
Color3::Color3() noexcept
|
2015-09-30 02:56:11 +02:00
|
|
|
: r(0), g(0), b(0)
|
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2020-03-22 08:16:40 +01:00
|
|
|
Color3::Color3(Value sv) noexcept
|
2016-02-20 23:25:00 +01:00
|
|
|
: r(sv), g(sv), b(sv)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2020-03-22 08:16:40 +01:00
|
|
|
Color3::Color3(Value rv, Value gv, Value bv) noexcept
|
2016-02-20 23:25:00 +01:00
|
|
|
: r(rv), g(gv), b(bv)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2020-03-22 08:16:40 +01:00
|
|
|
Color3::Color3(Value rv, Value gv, Value bv, Value /*av*/) noexcept
|
2016-07-24 22:17:56 +02:00
|
|
|
: r(rv), g(gv), b(bv)
|
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator = (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r = s;
|
|
|
|
g = s;
|
|
|
|
b = s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator = (const Color4 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r = c.r;
|
|
|
|
g = c.g;
|
|
|
|
b = c.b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator += (const Color3 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r += c.r;
|
|
|
|
g += c.g;
|
|
|
|
b += c.b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator -= (const Color3 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r -= c.r;
|
|
|
|
g -= c.g;
|
|
|
|
b -= c.b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator *= (const Color3 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r *= c.r;
|
|
|
|
g *= c.g;
|
|
|
|
b *= c.b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator /= (const Color3 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r /= c.r;
|
|
|
|
g /= c.g;
|
|
|
|
b /= c.b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator %= (const Color3 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r %= c.r;
|
|
|
|
g %= c.g;
|
|
|
|
b %= c.b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator &= (const Color3 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r &= c.r;
|
|
|
|
g &= c.g;
|
|
|
|
b &= c.b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator |= (const Color3 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r |= c.r;
|
|
|
|
g |= c.g;
|
|
|
|
b |= c.b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator ^= (const Color3 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r ^= c.r;
|
|
|
|
g ^= c.g;
|
|
|
|
b ^= c.b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator <<= (const Color3 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r <<= c.r;
|
|
|
|
g <<= c.g;
|
|
|
|
b <<= c.b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator >>= (const Color3 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r >>= c.r;
|
|
|
|
g >>= c.g;
|
|
|
|
b >>= c.b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator += (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r += s;
|
|
|
|
g += s;
|
|
|
|
b += s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator -= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r -= s;
|
|
|
|
g -= s;
|
|
|
|
b -= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator *= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r *= s;
|
|
|
|
g *= s;
|
|
|
|
b *= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator /= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r /= s;
|
|
|
|
g /= s;
|
|
|
|
b /= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator %= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r %= s;
|
|
|
|
g %= s;
|
|
|
|
b %= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator &= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r &= s;
|
|
|
|
g &= s;
|
|
|
|
b &= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator |= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r |= s;
|
|
|
|
g |= s;
|
|
|
|
b |= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator ^= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r ^= s;
|
|
|
|
g ^= s;
|
|
|
|
b ^= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator <<= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r <<= s;
|
|
|
|
g <<= s;
|
|
|
|
b <<= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator >>= (Value s)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r >>= s;
|
|
|
|
g >>= s;
|
|
|
|
b >>= s;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator ++ ()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
++r;
|
|
|
|
++g;
|
|
|
|
++b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 & Color3::operator -- ()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
--r;
|
|
|
|
--g;
|
|
|
|
--b;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2020-03-22 08:16:40 +01:00
|
|
|
Color3 Color3::operator ++ (int) // NOLINT(cert-dcl21-cpp)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
Color3 state(*this);
|
|
|
|
++r;
|
|
|
|
++g;
|
|
|
|
++b;
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2020-03-22 08:16:40 +01:00
|
|
|
Color3 Color3::operator -- (int) // NOLINT(cert-dcl21-cpp)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
Color3 state(*this);
|
|
|
|
--r;
|
|
|
|
--g;
|
|
|
|
--b;
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator + (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r + c.r), static_cast<Value>(g + c.g), static_cast<Value>(b + c.b)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator - (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r - c.r), static_cast<Value>(g - c.g), static_cast<Value>(b - c.b)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator * (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r * c.r), static_cast<Value>(g * c.g), static_cast<Value>(b * c.b)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator / (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r / c.r), static_cast<Value>(g / c.g), static_cast<Value>(b / c.b)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator % (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r % c.r), static_cast<Value>(g % c.g), static_cast<Value>(b % c.b)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator & (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r & c.r), static_cast<Value>(g & c.g), static_cast<Value>(b & c.b)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator | (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r | c.r), static_cast<Value>(g | c.g), static_cast<Value>(b | c.b)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator ^ (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r ^ c.r), static_cast<Value>(g ^ c.g), static_cast<Value>(b ^ c.b)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator << (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r << c.r), static_cast<Value>(g << c.g), static_cast<Value>(b << c.b)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator >> (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r >> c.r), static_cast<Value>(g >> c.g), static_cast<Value>(b >> c.b)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator + (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r + s), static_cast<Value>(g + s), static_cast<Value>(b + s)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator - (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r - s), static_cast<Value>(g - s), static_cast<Value>(b - s)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator * (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r * s), static_cast<Value>(g * s), static_cast<Value>(b * s)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator / (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r / s), static_cast<Value>(g / s), static_cast<Value>(b / s)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator % (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r % s), static_cast<Value>(g % s), static_cast<Value>(b % s)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator & (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r & s), static_cast<Value>(g & s), static_cast<Value>(b & s)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator | (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r | s), static_cast<Value>(g | s), static_cast<Value>(b | s)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator ^ (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r ^ s), static_cast<Value>(g ^ s), static_cast<Value>(b ^ s)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator << (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r << s), static_cast<Value>(g << s), static_cast<Value>(b << s)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator >> (Value s) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(r >> s), static_cast<Value>(g >> s), static_cast<Value>(b >> s)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator + () const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {r, g, b};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator - () const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {0, 0, 0};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
Color3 Color3::operator ~ () const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {static_cast<Value>(~r), static_cast<Value>(~g), static_cast<Value>(~b)};
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Color3::operator == (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return (r == c.r) && (g == c.g) && (b == c.b);
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Color3::operator != (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-07-29 17:00:10 +02:00
|
|
|
return (r != c.r) || (g != c.g) || (b != c.b);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Color3::operator < (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return (r < c.r) && (g < c.g) && (b < c.b);
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Color3::operator > (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return (r > c.r) && (g > c.g) && (b > c.b);
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Color3::operator <= (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return (r <= c.r) && (g <= c.g) && (b <= c.b);
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool Color3::operator >= (const Color3 & c) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
return (r >= c.r) && (g >= c.g) && (b >= c.b);
|
|
|
|
}
|
|
|
|
|
2015-11-09 00:35:39 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Color3::operator Color4 () const
|
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return {r, g, b};
|
2015-11-09 00:35:39 +01:00
|
|
|
}
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 Color3::Cmp(const Color3 & o) const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
if (*this == o)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return 0;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
else if (*this > o)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return 1;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
else
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return -1;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr Color3::ToString() const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return ToStrF("%u,%u,%u", r, g, b);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-07-24 22:17:56 +02:00
|
|
|
void Color3::SetScalar(Value ns)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r = ns;
|
|
|
|
g = ns;
|
|
|
|
b = ns;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-07-24 23:10:17 +02:00
|
|
|
void Color3::SetColor3(const Color3 & c)
|
2016-07-24 22:17:56 +02:00
|
|
|
{
|
2016-07-24 23:10:17 +02:00
|
|
|
r = c.r;
|
|
|
|
g = c.g;
|
|
|
|
b = c.b;
|
2016-07-24 22:17:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-07-24 23:10:17 +02:00
|
|
|
void Color3::SetColor3Ex(Value nr, Value ng, Value nb)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r = nr;
|
|
|
|
g = ng;
|
|
|
|
b = nb;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-07-24 23:10:17 +02:00
|
|
|
void Color3::SetColor4(const Color4 & c)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
r = c.r;
|
|
|
|
g = c.g;
|
|
|
|
b = c.b;
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-07-24 23:10:17 +02:00
|
|
|
void Color3::SetColor4Ex(Value nr, Value ng, Value nb, Value /*na*/)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-07-24 23:10:17 +02:00
|
|
|
r = nr;
|
|
|
|
g = ng;
|
|
|
|
b = nb;
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
void Color3::SetStr(SQChar delim, StackStrF & values)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-11-16 15:19:02 +01:00
|
|
|
SetColor3(Color3::GetEx(delim, values));
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
void Color3::SetName(StackStrF & name)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-07-24 22:17:56 +02:00
|
|
|
SetColor3(GetColor(name));
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint32 Color3::GetRGB() const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return Uint32(r << 16u | g << 8u | b); // NOLINT(hicpp-signed-bitwise)
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void Color3::SetRGB(Uint32 p)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
r = static_cast< Value >((p >> 16u) & 0xFFu);
|
|
|
|
g = static_cast< Value >((p >> 8u) & 0xFFu);
|
|
|
|
b = static_cast< Value >((p) & 0xFFu);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint32 Color3::GetRGBA() const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return Uint32(r << 24u | g << 16u | b << 8u | 0u); // NOLINT(hicpp-signed-bitwise)
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void Color3::SetRGBA(Uint32 p)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
r = static_cast< Value >((p >> 24u) & 0xFFu);
|
|
|
|
g = static_cast< Value >((p >> 16u) & 0xFFu);
|
|
|
|
b = static_cast< Value >((p >> 8u) & 0xFFu);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint32 Color3::GetARGB() const
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
return Uint32(0u << 24u | r << 16u | g << 8u | b); // NOLINT(hicpp-signed-bitwise)
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void Color3::SetARGB(Uint32 p)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
r = static_cast< Value >((p >> 16u) & 0xFFu);
|
|
|
|
g = static_cast< Value >((p >> 8u) & 0xFFu);
|
|
|
|
b = static_cast< Value >((p) & 0xFFu);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Color3::Generate()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
r = GetRandomUint8();
|
|
|
|
g = GetRandomUint8();
|
|
|
|
b = GetRandomUint8();
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Color3::Generate(Value min, Value max)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
if (max < min)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("max value is lower than min value");
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
r = GetRandomUint8(min, max);
|
|
|
|
g = GetRandomUint8(min, max);
|
|
|
|
b = GetRandomUint8(min, max);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-24 22:17:56 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Color3::Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
if (rmax < rmin || gmax < gmin || bmax < bmin)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("max value is lower than min value");
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
r = GetRandomUint8(rmin, rmax);
|
|
|
|
g = GetRandomUint8(gmin, gmax);
|
|
|
|
b = GetRandomUint8(bmin, bmax);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Color3::Random()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-07-24 22:17:56 +02:00
|
|
|
SetColor3(GetRandomColor());
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void Color3::Inverse()
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
r = static_cast< Value >(~r);
|
|
|
|
g = static_cast< Value >(~g);
|
|
|
|
b = static_cast< Value >(~b);
|
2015-09-30 02:56:11 +02:00
|
|
|
}
|
|
|
|
|
2020-09-03 19:52:46 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
LightObj Color3::ToHex() const
|
|
|
|
{
|
|
|
|
SQChar buff[16]; // 7 should be enough
|
|
|
|
// Attempt to perform the format in the local buffer
|
2020-09-03 20:05:38 +02:00
|
|
|
if (std::snprintf(buff, 16, UpperCaseHex ? "%02X%02X%02X" : "%02x%02x%02x", r, g, b) <= 0)
|
2020-09-03 19:52:46 +02:00
|
|
|
{
|
|
|
|
STHROWF("Format failed (somehow)");
|
|
|
|
}
|
|
|
|
// Return the resulted string
|
|
|
|
return LightObj{buff, -1};
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
LightObj Color3::ToHex4() const
|
|
|
|
{
|
|
|
|
SQChar buff[16]; // 9 should be enough
|
|
|
|
// Attempt to perform the format in the local buffer
|
2020-09-03 20:05:38 +02:00
|
|
|
if (std::snprintf(buff, 16, UpperCaseHex ? "%02X%02X%02X%02X" : "%02x%02x%02x%02x", r, g, b, 0) <= 0)
|
2020-09-03 19:52:46 +02:00
|
|
|
{
|
|
|
|
STHROWF("Format failed (somehow)");
|
|
|
|
}
|
|
|
|
// Return the resulted string
|
|
|
|
return LightObj{buff, -1};
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:33:51 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
LightObj Color3::Format(const String & spec, StackStrF & fmt) const
|
|
|
|
{
|
|
|
|
String out;
|
|
|
|
// Attempt to build the format string
|
|
|
|
if (!BuildFormatString(out, fmt, 3, spec))
|
|
|
|
{
|
|
|
|
return LightObj{}; // Default to null
|
|
|
|
}
|
|
|
|
// Empty string is unacceptable
|
|
|
|
else if (out.empty())
|
|
|
|
{
|
|
|
|
STHROWF("Unable to build a valid format string.");
|
|
|
|
}
|
|
|
|
// Grab a temporary buffer
|
|
|
|
Buffer buff(out.size());
|
|
|
|
// Generate the string
|
|
|
|
Buffer::SzType n = buff.WriteF(0, out.c_str(), r, g, b);
|
|
|
|
// Did the format failed?
|
|
|
|
if (!n && !out.empty())
|
|
|
|
{
|
|
|
|
STHROWF("Format failed. Please check format specifier and parameter count.");
|
|
|
|
}
|
|
|
|
// Return the resulted string
|
|
|
|
return LightObj{buff.Begin< SQChar >(), static_cast< SQInteger >(n)};
|
|
|
|
}
|
|
|
|
|
2016-03-21 21:37:58 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
const Color3 & Color3::Get(StackStrF & str)
|
2016-03-21 21:37:58 +01:00
|
|
|
{
|
2016-11-16 15:19:02 +01:00
|
|
|
return Color3::GetEx(Color3::Delim, str);
|
2016-03-21 21:37:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
const Color3 & Color3::GetEx(SQChar delim, StackStrF & str)
|
2016-03-21 21:37:58 +01:00
|
|
|
{
|
|
|
|
static Color3 col;
|
|
|
|
// The minimum and maximum values supported by the Color3 type
|
2020-09-03 17:26:24 +02:00
|
|
|
static constexpr Uint32 min = std::numeric_limits< Color3::Value >::min();
|
|
|
|
static constexpr Uint32 max = std::numeric_limits< Color3::Value >::max();
|
2016-03-21 21:37:58 +01:00
|
|
|
// Clear previous values, if any
|
|
|
|
col.Clear();
|
|
|
|
// Is the specified string empty?
|
2016-11-16 15:19:02 +01:00
|
|
|
if (str.mLen <= 0)
|
2016-03-21 21:37:58 +01:00
|
|
|
{
|
|
|
|
return col; // Return the value as is!
|
|
|
|
}
|
2020-09-03 17:26:24 +02:00
|
|
|
// The format specifications that will be used to scan the string
|
|
|
|
SQChar fs[] = _SC(" %u , %u , %u ");
|
2016-03-21 21:37:58 +01:00
|
|
|
// Assign the specified delimiter
|
|
|
|
fs[4] = delim;
|
|
|
|
fs[9] = delim;
|
|
|
|
// The sscanf function requires at least 32 bit integers
|
|
|
|
Uint32 r = 0, g = 0, b = 0;
|
|
|
|
// Attempt to extract the component values from the specified string
|
2016-11-16 15:19:02 +01:00
|
|
|
std::sscanf(str.mPtr, fs, &r, &g, &b);
|
2016-03-21 21:37:58 +01:00
|
|
|
// Cast the extracted integers to the value used by the Color3 type
|
|
|
|
col.r = static_cast< Color3::Value >(Clamp(r, min, max));
|
|
|
|
col.g = static_cast< Color3::Value >(Clamp(g, min, max));
|
|
|
|
col.b = static_cast< Color3::Value >(Clamp(b, min, max));
|
|
|
|
// Return the resulted value
|
|
|
|
return col;
|
|
|
|
}
|
|
|
|
|
2020-09-03 20:05:38 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the hex case preference of the Color3 type.
|
|
|
|
*/
|
|
|
|
static bool SqGetColor3UpperCaseHex()
|
|
|
|
{
|
|
|
|
return Color3::UpperCaseHex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Modify the hex case preference of the Color3 type.
|
|
|
|
*/
|
|
|
|
static void SqSetColor3UpperCaseHex(bool t)
|
|
|
|
{
|
|
|
|
Color3::UpperCaseHex = t;
|
|
|
|
}
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ================================================================================================
|
2020-03-22 08:16:40 +01:00
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wunused-parameter"
|
2016-02-20 23:25:00 +01:00
|
|
|
void Register_Color3(HSQUIRRELVM vm)
|
2020-03-22 08:16:40 +01:00
|
|
|
#pragma clang diagnostic pop
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
typedef Color3::Value Val;
|
|
|
|
|
2016-11-15 20:55:03 +01:00
|
|
|
RootTable(vm).Bind(Typename::Str,
|
|
|
|
Class< Color3 >(vm, Typename::Str)
|
2016-05-22 05:20:38 +02:00
|
|
|
// Constructors
|
2015-09-30 02:56:11 +02:00
|
|
|
.Ctor()
|
2016-02-20 23:25:00 +01:00
|
|
|
.Ctor< Val >()
|
|
|
|
.Ctor< Val, Val, Val >()
|
2016-07-24 22:17:56 +02:00
|
|
|
.Ctor< Val, Val, Val, Val >()
|
2016-05-22 05:20:38 +02:00
|
|
|
// Member Variables
|
2016-07-17 14:39:59 +02:00
|
|
|
.Var(_SC("r"), &Color3::r)
|
|
|
|
.Var(_SC("g"), &Color3::g)
|
|
|
|
.Var(_SC("b"), &Color3::b)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Var(_SC("R"), &Color3::r)
|
|
|
|
.Var(_SC("G"), &Color3::g)
|
|
|
|
.Var(_SC("B"), &Color3::b)
|
2016-06-03 20:26:19 +02:00
|
|
|
// Core Meta-methods
|
2016-08-24 22:17:09 +02:00
|
|
|
.SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< Color3 >, SQFloat, SQInteger, bool, std::nullptr_t, Color3 >)
|
2016-11-15 20:20:10 +01:00
|
|
|
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
|
|
|
.Func(_SC("_tostring"), &Color3::ToString)
|
2016-06-03 20:26:19 +02:00
|
|
|
// Meta-methods
|
2016-08-24 22:17:09 +02:00
|
|
|
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< Color3 >, SQFloat, SQInteger, bool, std::nullptr_t, Color3 >)
|
|
|
|
.SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< Color3 >, SQFloat, SQInteger, bool, std::nullptr_t, Color3 >)
|
|
|
|
.SquirrelFunc(_SC("_mul"), &SqDynArgFwd< SqDynArgMulFn< Color3 >, SQFloat, SQInteger, bool, std::nullptr_t, Color3 >)
|
|
|
|
.SquirrelFunc(_SC("_div"), &SqDynArgFwd< SqDynArgDivFn< Color3 >, SQFloat, SQInteger, bool, std::nullptr_t, Color3 >)
|
|
|
|
.SquirrelFunc(_SC("_modulo"), &SqDynArgFwd< SqDynArgModFn< Color3 >, SQFloat, SQInteger, bool, std::nullptr_t, Color3 >)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Func< Color3 (Color3::*)(void) const >(_SC("_unm"), &Color3::operator -)
|
2016-07-24 22:17:56 +02:00
|
|
|
// Properties
|
|
|
|
.Prop(_SC("RGB"), &Color3::GetRGB, &Color3::SetRGB)
|
|
|
|
.Prop(_SC("RGBA"), &Color3::GetRGBA, &Color3::SetRGBA)
|
|
|
|
.Prop(_SC("ARGB"), &Color3::GetARGB, &Color3::SetARGB)
|
2020-09-03 19:52:46 +02:00
|
|
|
.Prop(_SC("Hex"), &Color3::ToHex)
|
|
|
|
.Prop(_SC("Hex4"), &Color3::ToHex4)
|
2016-07-24 22:17:56 +02:00
|
|
|
// Member Methods
|
|
|
|
.Func(_SC("SetScalar"), &Color3::SetScalar)
|
|
|
|
.Func(_SC("SetColor3"), &Color3::SetColor3)
|
2016-07-24 23:10:17 +02:00
|
|
|
.Func(_SC("SetColor3Ex"), &Color3::SetColor3Ex)
|
2016-07-24 22:17:56 +02:00
|
|
|
.Func(_SC("SetColor4"), &Color3::SetColor4)
|
2016-07-24 23:10:17 +02:00
|
|
|
.Func(_SC("SetColor4Ex"), &Color3::SetColor4Ex)
|
2016-11-16 15:19:02 +01:00
|
|
|
.FmtFunc(_SC("SetStr"), &Color3::SetStr)
|
|
|
|
.FmtFunc(_SC("SetName"), &Color3::SetName)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Clear"), &Color3::Clear)
|
2020-09-03 19:33:51 +02:00
|
|
|
.FmtFunc(_SC("Format"), &Color3::Format)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Random"), &Color3::Random)
|
|
|
|
.Func(_SC("Inverse"), &Color3::Inverse)
|
2016-07-24 22:17:56 +02:00
|
|
|
// Member Overloads
|
|
|
|
.Overload< void (Color3::*)(void) >(_SC("Generate"), &Color3::Generate)
|
|
|
|
.Overload< void (Color3::*)(Val, Val) >(_SC("Generate"), &Color3::Generate)
|
|
|
|
.Overload< void (Color3::*)(Val, Val, Val, Val, Val, Val) >(_SC("Generate"), &Color3::Generate)
|
2016-07-24 20:29:37 +02:00
|
|
|
// Static Functions
|
|
|
|
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Color3 >)
|
|
|
|
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Color3 >)
|
2020-09-03 20:05:38 +02:00
|
|
|
.StaticFunc(_SC("GetUpperCaseHex"), &SqGetColor3UpperCaseHex)
|
|
|
|
.StaticFunc(_SC("SetUpperCaseHex"), &SqSetColor3UpperCaseHex)
|
2016-11-16 15:19:02 +01:00
|
|
|
.StaticFmtFunc(_SC("FromStr"), &Color3::Get)
|
|
|
|
.StaticFmtFunc(_SC("FromStrEx"), &Color3::GetEx)
|
2016-05-22 05:20:38 +02:00
|
|
|
// Operator Exposure
|
|
|
|
.Func< Color3 & (Color3::*)(const Color3 &) >(_SC("opAddAssign"), &Color3::operator +=)
|
|
|
|
.Func< Color3 & (Color3::*)(const Color3 &) >(_SC("opSubAssign"), &Color3::operator -=)
|
|
|
|
.Func< Color3 & (Color3::*)(const Color3 &) >(_SC("opMulAssign"), &Color3::operator *=)
|
|
|
|
.Func< Color3 & (Color3::*)(const Color3 &) >(_SC("opDivAssign"), &Color3::operator /=)
|
|
|
|
.Func< Color3 & (Color3::*)(const Color3 &) >(_SC("opModAssign"), &Color3::operator %=)
|
|
|
|
.Func< Color3 & (Color3::*)(const Color3 &) >(_SC("opAndAssign"), &Color3::operator &=)
|
|
|
|
.Func< Color3 & (Color3::*)(const Color3 &) >(_SC("opOrAssign"), &Color3::operator |=)
|
|
|
|
.Func< Color3 & (Color3::*)(const Color3 &) >(_SC("opXorAssign"), &Color3::operator ^=)
|
|
|
|
.Func< Color3 & (Color3::*)(const Color3 &) >(_SC("opShlAssign"), &Color3::operator <<=)
|
|
|
|
.Func< Color3 & (Color3::*)(const Color3 &) >(_SC("opShrAssign"), &Color3::operator >>=)
|
|
|
|
.Func< Color3 & (Color3::*)(Color3::Value) >(_SC("opAddAssignS"), &Color3::operator +=)
|
|
|
|
.Func< Color3 & (Color3::*)(Color3::Value) >(_SC("opSubAssignS"), &Color3::operator -=)
|
|
|
|
.Func< Color3 & (Color3::*)(Color3::Value) >(_SC("opMulAssignS"), &Color3::operator *=)
|
|
|
|
.Func< Color3 & (Color3::*)(Color3::Value) >(_SC("opDivAssignS"), &Color3::operator /=)
|
|
|
|
.Func< Color3 & (Color3::*)(Color3::Value) >(_SC("opModAssignS"), &Color3::operator %=)
|
|
|
|
.Func< Color3 & (Color3::*)(Color3::Value) >(_SC("opAndAssignS"), &Color3::operator &=)
|
|
|
|
.Func< Color3 & (Color3::*)(Color3::Value) >(_SC("opOrAssignS"), &Color3::operator |=)
|
|
|
|
.Func< Color3 & (Color3::*)(Color3::Value) >(_SC("opXorAssignS"), &Color3::operator ^=)
|
|
|
|
.Func< Color3 & (Color3::*)(Color3::Value) >(_SC("opShlAssignS"), &Color3::operator <<=)
|
|
|
|
.Func< Color3 & (Color3::*)(Color3::Value) >(_SC("opShrAssignS"), &Color3::operator >>=)
|
|
|
|
.Func< Color3 & (Color3::*)(void) >(_SC("opPreInc"), &Color3::operator ++)
|
|
|
|
.Func< Color3 & (Color3::*)(void) >(_SC("opPreDec"), &Color3::operator --)
|
|
|
|
.Func< Color3 (Color3::*)(int) >(_SC("opPostInc"), &Color3::operator ++)
|
|
|
|
.Func< Color3 (Color3::*)(int) >(_SC("opPostDec"), &Color3::operator --)
|
|
|
|
.Func< Color3 (Color3::*)(const Color3 &) const >(_SC("opAdd"), &Color3::operator +)
|
|
|
|
.Func< Color3 (Color3::*)(const Color3 &) const >(_SC("opSub"), &Color3::operator -)
|
|
|
|
.Func< Color3 (Color3::*)(const Color3 &) const >(_SC("opMul"), &Color3::operator *)
|
|
|
|
.Func< Color3 (Color3::*)(const Color3 &) const >(_SC("opDiv"), &Color3::operator /)
|
|
|
|
.Func< Color3 (Color3::*)(const Color3 &) const >(_SC("opMod"), &Color3::operator %)
|
|
|
|
.Func< Color3 (Color3::*)(const Color3 &) const >(_SC("opAnd"), &Color3::operator &)
|
|
|
|
.Func< Color3 (Color3::*)(const Color3 &) const >(_SC("opOr"), &Color3::operator |)
|
|
|
|
.Func< Color3 (Color3::*)(const Color3 &) const >(_SC("opShl"), &Color3::operator ^)
|
|
|
|
.Func< Color3 (Color3::*)(const Color3 &) const >(_SC("opShl"), &Color3::operator <<)
|
|
|
|
.Func< Color3 (Color3::*)(const Color3 &) const >(_SC("opShr"), &Color3::operator >>)
|
|
|
|
.Func< Color3 (Color3::*)(Color3::Value) const >(_SC("opAddS"), &Color3::operator +)
|
|
|
|
.Func< Color3 (Color3::*)(Color3::Value) const >(_SC("opSubS"), &Color3::operator -)
|
|
|
|
.Func< Color3 (Color3::*)(Color3::Value) const >(_SC("opMulS"), &Color3::operator *)
|
|
|
|
.Func< Color3 (Color3::*)(Color3::Value) const >(_SC("opDivS"), &Color3::operator /)
|
|
|
|
.Func< Color3 (Color3::*)(Color3::Value) const >(_SC("opModS"), &Color3::operator %)
|
|
|
|
.Func< Color3 (Color3::*)(Color3::Value) const >(_SC("opAndS"), &Color3::operator &)
|
|
|
|
.Func< Color3 (Color3::*)(Color3::Value) const >(_SC("opOrS"), &Color3::operator |)
|
|
|
|
.Func< Color3 (Color3::*)(Color3::Value) const >(_SC("opShlS"), &Color3::operator ^)
|
|
|
|
.Func< Color3 (Color3::*)(Color3::Value) const >(_SC("opShlS"), &Color3::operator <<)
|
|
|
|
.Func< Color3 (Color3::*)(Color3::Value) const >(_SC("opShrS"), &Color3::operator >>)
|
|
|
|
.Func< Color3 (Color3::*)(void) const >(_SC("opUnPlus"), &Color3::operator +)
|
|
|
|
.Func< Color3 (Color3::*)(void) const >(_SC("opUnMinus"), &Color3::operator -)
|
|
|
|
.Func< Color3 (Color3::*)(void) const >(_SC("opCom"), &Color3::operator ~)
|
|
|
|
.Func< bool (Color3::*)(const Color3 &) const >(_SC("opEqual"), &Color3::operator ==)
|
|
|
|
.Func< bool (Color3::*)(const Color3 &) const >(_SC("opNotEqual"), &Color3::operator !=)
|
|
|
|
.Func< bool (Color3::*)(const Color3 &) const >(_SC("opLessThan"), &Color3::operator <)
|
|
|
|
.Func< bool (Color3::*)(const Color3 &) const >(_SC("opGreaterThan"), &Color3::operator >)
|
|
|
|
.Func< bool (Color3::*)(const Color3 &) const >(_SC("opLessEqual"), &Color3::operator <=)
|
|
|
|
.Func< bool (Color3::*)(const Color3 &) const >(_SC("opGreaterEqual"), &Color3::operator >=)
|
2015-09-30 02:56:11 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|