mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Mark ColorRGBA
/ColorHSLA
functions as const
This commit is contained in:
parent
931ea6d828
commit
f5221caf50
|
@ -109,14 +109,14 @@ public:
|
||||||
bool operator==(const color4_base &col) const { return x == col.x && y == col.y && z == col.z && a == col.a; }
|
bool operator==(const color4_base &col) const { return x == col.x && y == col.y && z == col.z && a == col.a; }
|
||||||
bool operator!=(const color4_base &col) const { return x != col.x || y != col.y || z != col.z || a != col.a; }
|
bool operator!=(const color4_base &col) const { return x != col.x || y != col.y || z != col.z || a != col.a; }
|
||||||
|
|
||||||
unsigned Pack(bool Alpha = true)
|
unsigned Pack(bool Alpha = true) const
|
||||||
{
|
{
|
||||||
return (Alpha ? ((unsigned)round_to_int(a * 255.0f) << 24) : 0) + ((unsigned)round_to_int(x * 255.0f) << 16) + ((unsigned)round_to_int(y * 255.0f) << 8) + (unsigned)round_to_int(z * 255.0f);
|
return (Alpha ? ((unsigned)round_to_int(a * 255.0f) << 24) : 0) + ((unsigned)round_to_int(x * 255.0f) << 16) + ((unsigned)round_to_int(y * 255.0f) << 8) + (unsigned)round_to_int(z * 255.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
DerivedT WithAlpha(float alpha)
|
DerivedT WithAlpha(float alpha) const
|
||||||
{
|
{
|
||||||
DerivedT col(static_cast<DerivedT &>(*this));
|
DerivedT col(static_cast<const DerivedT &>(*this));
|
||||||
col.a = alpha;
|
col.a = alpha;
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
@ -130,19 +130,19 @@ public:
|
||||||
|
|
||||||
constexpr static const float DARKEST_LGT = 0.5f;
|
constexpr static const float DARKEST_LGT = 0.5f;
|
||||||
|
|
||||||
ColorHSLA UnclampLighting(float Darkest = DARKEST_LGT)
|
ColorHSLA UnclampLighting(float Darkest = DARKEST_LGT) const
|
||||||
{
|
{
|
||||||
ColorHSLA col = *this;
|
ColorHSLA col = *this;
|
||||||
col.l = Darkest + col.l * (1.0f - Darkest);
|
col.l = Darkest + col.l * (1.0f - Darkest);
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Pack(bool Alpha = true)
|
unsigned Pack(bool Alpha = true) const
|
||||||
{
|
{
|
||||||
return color4_base::Pack(Alpha);
|
return color4_base::Pack(Alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Pack(float Darkest, bool Alpha = false)
|
unsigned Pack(float Darkest, bool Alpha = false) const
|
||||||
{
|
{
|
||||||
ColorHSLA col = *this;
|
ColorHSLA col = *this;
|
||||||
col.l = (l - Darkest) / (1 - Darkest);
|
col.l = (l - Darkest) / (1 - Darkest);
|
||||||
|
|
Loading…
Reference in a new issue