5#if PL_ENABLED(PL_MATH_CHECK_FOR_NAN)
15PL_FORCE_INLINE
constexpr plColor::plColor(
float fLinearRed,
float fLinearGreen,
float fLinearBlue,
float fLinearAlpha )
33inline void plColor::SetRGB(
float fLinearRed,
float fLinearGreen,
float fLinearBlue)
40inline void plColor::SetRGBA(
float fLinearRed,
float fLinearGreen,
float fLinearBlue,
float fLinearAlpha )
51 float kelvin =
plMath::Clamp(uiKelvin, 1000u, 40000u) / 1000.0f;
52 float kelvin2 = kelvin * kelvin;
55 finalColor.r = kelvin < 6.570f ? 1.0f :
plMath::Clamp((1.35651f + 0.216422f * kelvin + 0.000633715f * kelvin2) / (-3.24223f + 0.918711f * kelvin), 0.0f, 1.0f);
57 finalColor.g = kelvin < 6.570f ?
plMath::Clamp((-399.809f + 414.271f * kelvin + 111.543f * kelvin2) / (2779.24f + 164.143f * kelvin + 84.7356f * kelvin2), 0.0f, 1.0f) :
plMath::Clamp((1370.38f + 734.616f * kelvin + 0.689955f * kelvin2) / (-4625.69f + 1699.87f * kelvin), 0.0f, 1.0f);
59 finalColor.b = kelvin > 6.570f ? 1.0f :
plMath::Clamp((348.963f - 523.53f * kelvin + 183.62f * kelvin2) / (2848.82f - 214.52f * kelvin + 78.8614f * kelvin2), 0.0f, 1.0f);
67 return 0.2126f * r + 0.7152f * g + 0.0722f * b;
73 PL_ASSERT_DEBUG(
IsNormalized(),
"Cannot invert a color that has values outside the [0; 1] range");
75 return plColor(1.0f - r, 1.0f - g, 1.0f - b, 1.0f - a);
139 return r == rhs.r && g == rhs.g && b == rhs.b;
147 return r == rhs.r && g == rhs.g && b == rhs.b && a == rhs.a;
152 return plColor(r, g, b, fAlpha);
160 return plColor(c1.r + c2.r, c1.g + c2.g, c1.b + c2.b, c1.a + c2.a);
168 return plColor(c1.r - c2.r, c1.g - c2.g, c1.b - c2.b, c1.a - c2.a);
176 return plColor(c1.r * c2.r, c1.g * c2.g, c1.b * c2.b, c1.a * c2.a);
183 return plColor(c.r * f, c.g * f, c.b * f, c.a * f);
190 return plColor(c.r * f, c.g * f, c.b * f, c.a * f);
204 float f_inv = 1.0f / f;
205 return plColor(c.r * f_inv, c.g * f_inv, c.b * f_inv, c.a * f_inv);
208PL_ALWAYS_INLINE
bool operator==(
const plColor& c1,
const plColor& c2)
213PL_ALWAYS_INLINE
bool operator!=(
const plColor& c1,
const plColor& c2)
218PL_FORCE_INLINE
bool operator<(
const plColor& c1,
const plColor& c2)
233 return (c1.a < c2.a);
A 8bit per channel unsigned normalized (values interpreted as 0-1) color storage format that represen...
Definition Color8UNorm.h:99
plColor represents an RGBA color in linear color space. Values are stored as float,...
Definition Color.h:44
float GetLuminance() const
Computes the perceived luminance. Assumes linear color space (http://en.wikipedia....
Definition Color_inl.h:65
bool IsNaN() const
Returns true, if any of r, g, b or a is NaN.
Definition Color_inl.h:78
void operator-=(const plColor &rhs)
Subtracts rhs component-wise from this vector.
Definition Color_inl.h:103
bool IsIdenticalRGB(const plColor &rhs) const
Equality Check (bitwise). Only compares RGB, ignores Alpha.
Definition Color_inl.h:134
plColor GetInvertedColor() const
[tested]
Definition Color_inl.h:70
plColor WithAlpha(float fAlpha) const
Returns the current color but with changes the alpha value to the given value.
Definition Color_inl.h:150
void operator+=(const plColor &rhs)
Adds rhs component-wise to this color.
Definition Color_inl.h:92
void SetRGB(float fLinearRed, float fLinearGreen, float fLinearBlue)
Sets the RGB components, ignores alpha.
Definition Color_inl.h:33
bool IsIdenticalRGBA(const plColor &rhs) const
Equality Check (bitwise). Compares all four components.
Definition Color_inl.h:142
void SetRGBA(float fLinearRed, float fLinearGreen, float fLinearBlue, float fLinearAlpha=1.0f)
Sets all four RGBA components.
Definition Color_inl.h:40
void operator*=(const plColor &rhs)
Multiplies rhs component-wise with this color.
Definition Color_inl.h:114
plColor()
default-constructed color is uninitialized (for speed)
Definition Color_inl.h:3
bool IsNormalized() const
Returns if the color is in the Range [0; 1] on all 4 channels.
Definition Color.cpp:33
static plColor MakeFromKelvin(plUInt32 uiKelvin)
Returns a color created from the kelvin temperature. https://wikipedia.org/wiki/Color_temperature Ori...
Definition Color_inl.h:48
A 8bit per channel unsigned normalized (values interpreted as 0-1) color storage format that represen...
Definition Color8UNorm.h:61
constexpr PL_ALWAYS_INLINE T Clamp(T value, T min_val, T max_val)
Clamps "value" to the range [min; max]. Returns "value", if it is inside the range already.
Definition Math_inl.h:51
constexpr TYPE NaN()
Returns the value for NaN as the template type. Returns zero, if the type does not support NaN.
Definition Constants_inl.h:58