3 #define COLOR_ARGB(a,r,g,b) Color(r,g,b,a) 4 #define COLOR_RGBA(r,g,b,a) Color(r,g,b,a) 5 #define COLOR_XRGB(r,g,b) Color(r,g,b) 21 : r(0), g(0), b(0), a(0)
23 inline LinearColor(
float InR,
float InG,
float InB,
float InA = 1.0f) : r(InR), g(InG), b(InB), a(InA) {}
30 operator D3DCOLORVALUE& ();
31 operator const D3DCOLORVALUE& ()
const;
33 operator const float*()
const;
37 inline float& Component(int32 Index)
42 inline const float& Component(int32 Index)
const 50 operator uint32()
const;
145 const float InvScalar = 1.0f / Scalar;
155 const float InvScalar = 1.0f / Scalar;
166 return this->r == ColorB.r && this->g == ColorB.g && this->b == ColorB.b && this->a == ColorB.a;
168 inline bool operator!=(
const LinearColor& Other)
const 170 return this->r != Other.r || this->g != Other.g || this->b != Other.b || this->a != Other.a;
174 inline bool Equals(
const LinearColor& ColorB,
float Tolerance = KINDA_SMALL_NUMBER)
const 176 return Math::Abs(this->r - ColorB.r) < Tolerance && Math::Abs(this->g - ColorB.g) < Tolerance && Math::Abs(this->b - ColorB.b) < Tolerance && Math::Abs(this->a - ColorB.a) < Tolerance;
182 NewCopy.a = NewOpacicty;
196 return Math::Sqrt(Math::Sqr(V2.r - V1.r) + Math::Sqr(V2.g - V1.g) + Math::Sqr(V2.b - V1.b) + Math::Sqr(V2.a - V1.a));
237 return Math::Sqr(r) < DELTA && Math::Sqr(g) < DELTA && Math::Sqr(b) < DELTA;
250 inline float GetLuminance()
const 252 return r * 0.3f + g * 0.59f + b * 0.11f;
268 return Color.operator*(Scalar);
279 #if PLATFORM_LITTLE_ENDIAN 282 union {
struct{ uint8 b, g, r, a; }; uint32 AlignmentDummy; };
287 union {
struct{ uint8 b, g, r, a; }; uint32 AlignmentDummy; };
289 #else // PLATFORM_LITTLE_ENDIAN 290 union {
struct{ uint8 a, r, g, b; }; uint32 AlignmentDummy; };
293 uint32& DWColor(
void) {
return *((uint32*)
this); }
294 const uint32& DWColor(
void)
const {
return *((uint32*)
this); }
295 operator const uint32 ()
const {
return DWColor(); };
296 void operator=(
const uint32 color);
301 inline explicit Color(EnumForceInit)
306 inline Color(uint8 InR, uint8 InG, uint8 InB, uint8 InA = 255)
320 Color(uint32 InColor);
323 std::string ToRGBString();
325 std::string ToRGBAString();
330 return DWColor() == C.DWColor();
333 inline bool operator!=(
const Color& C)
const 335 return DWColor() != C.DWColor();
338 inline void operator+=(
const Color& C)
340 r = (uint8)
Math::Min((int32)r + (int32)C.r, (int32)255);
341 g = (uint8)
Math::Min((int32)g + (int32)C.g, (int32)255);
342 b = (uint8)
Math::Min((int32)b + (int32)C.b, (int32)255);
343 a = (uint8)
Math::Min((int32)a + (int32)C.a, (int32)255);
346 inline Color MutiplyOpacity(
float fOpacity)
353 c.a = (uint8)(c.a * fOpacity);
361 static uint16 convert32_16(uint32 rgb);
364 static uint32 convert16_32(uint16 rgb);
369 static Color MakeRandomColor();
374 static Color MakeRedToGreenColorFromScalar(
float Scalar);
384 return LinearColor(r / 255.f, g / 255.f, b / 255.f, a / 255.f);
387 static Color FromString(
const char* sColor);
391 static const Color Black;
392 static const Color Red;
393 static const Color Green;
394 static const Color Blue;
395 static const Color Yellow;
396 static const Color Cyan;
397 static const Color Magenta;
400 inline uint32 GetTypeHash(
const Color& Color)
402 return Color.DWColor();
float ComputeLuminance() const
Computes the perceptually weighted luminance value of a color.
Definition: ParaColor.cpp:103
void ComputeAndFixedColorAndIntensity(const LinearColor &InLinearColor, Color &OutColor, float &OutIntensity)
Computes a brightness and a fixed point color from a floating point color.
Definition: ParaColor.cpp:343
LinearColor ReinterpretAsLinear() const
Reinterprets the color as a linear color.
Definition: ParaColor.h:382
float GetMin() const
Returns the minimum value in this color structure.
Definition: ParaColor.h:245
bool operator==(const LinearColor &ColorB) const
Comparison operators.
Definition: ParaColor.h:164
static LinearColor FGetHSV(uint8 H, uint8 S, uint8 V)
Converts byte hue-saturation-brightness to floating point red-green-blue.
Definition: ParaColor.cpp:123
different physics engine has different winding order.
Definition: EventBinding.h:32
LinearColor Desaturate(float Desaturation) const
Returns a desaturated color, with 0 meaning no desaturation and 1 == full desaturation.
Definition: ParaColor.cpp:96
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
static float PowOneOver255Table[256]
Static lookup table used for color -> LinearColor conversion.
Definition: ParaColor.h:17
LinearColor LinearRGBToHSV() const
Converts a linear space RGB color to an HSV color.
Definition: ParaColor.cpp:135
static T Min(const T A, const T B)
Returns lower value in a generic way.
Definition: ParaMath.h:468
LinearColor HSVToLinearRGB() const
Converts an HSV color to a linear space RGB color.
Definition: ParaColor.cpp:157
bool IsAlmostBlack() const
useful to detect if a light contribution needs to be rendered
Definition: ParaColor.h:235
float GetMax() const
Returns the maximum value in this color structure.
Definition: ParaColor.h:229
Color ToColor(bool bSRGB=false) const
Quantizes the linear color and returns the result as a color with optional sRGB conversion and qualit...
Definition: ParaColor.cpp:55
A linear, 32-bit/component floating point RGBA color.
Definition: ParaColor.h:12
Definition: ParaColor.h:275
static const Color White
Some pre-inited colors, useful for debug code.
Definition: ParaColor.h:390
static T Max(const T A, const T B)
Returns higher value in a generic way.
Definition: ParaMath.h:462
Color Quantize() const
Quantizes the linear color and returns the result as a color.
Definition: ParaColor.cpp:80
static float Dist(const LinearColor &V1, const LinearColor &V2)
Euclidean distance between two points.
Definition: ParaColor.h:194