Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Color Class Reference

A color class with 4 components, RGBA. More...

#include <Color.h>

Public Member Functions

 AZ_TYPE_INFO (Color, "{7894072A-9050-4F0F-901B-34B1A0D29417}")
 
 Color ()=default
 Default constructor, components are uninitialized.
 
 Color (const Vector4 &v)
 
 Color (const Vector2 &source)
 
 Color (const Vector3 &source)
 
 Color (float rgba)
 Constructs vector with all components set to the same specified value.
 
 Color (float r, float g, float b, float a)
 
 Color (u8 r, u8 g, u8 b, u8 a)
 
void StoreToFloat4 (float *values) const
 
u8 GetR8 () const
 
u8 GetG8 () const
 
u8 GetB8 () const
 
u8 GetA8 () const
 
void SetR8 (u8 r)
 
void SetG8 (u8 g)
 
void SetB8 (u8 b)
 
void SetA8 (u8 a)
 
float GetR () const
 
float GetG () const
 
float GetB () const
 
float GetA () const
 
void SetR (float r)
 
void SetG (float g)
 
void SetB (float b)
 
void SetA (float a)
 
float GetElement (int32_t index) const
 
void SetElement (int32_t index, float v)
 
Vector3 GetAsVector3 () const
 
Vector4 GetAsVector4 () const
 
void Set (float x)
 Sets all components to the same specified value.
 
void Set (float r, float g, float b, float a)
 
void Set (const float values[4])
 Sets components from an array of 4 floats, stored in rgba order.
 
void Set (const Vector3 &v)
 Sets r,g,b components from a Vector3, sets a to 1.0.
 
void Set (const Vector3 &v, float a)
 Sets r,g,b components from a Vector3, specify a separately.
 
void SetFromHSVRadians (float hueRadians, float saturation, float value)
 Sets the RGB values of this Color based on a passed in hue, saturation, and value. Alpha is unchanged.
 
bool IsClose (const Color &v, float tolerance=Constants::Tolerance) const
 Checks the color is equal to another within a floating point tolerance.
 
bool IsZero (float tolerance=Constants::FloatEpsilon) const
 
bool IsFinite () const
 Checks whether all components are finite.
 
bool operator== (const Color &rhs) const
 
bool operator!= (const Color &rhs) const
 
 operator Vector3 () const
 
 operator Vector4 () const
 
Coloroperator= (const Vector3 &rhs)
 
u32 ToU32 () const
 Color to u32 => 0xAABBGGRR.
 
u32 ToU32LinearToGamma () const
 Color to u32 => 0xAABBGGRR, RGB convert from Linear to Gamma corrected values.
 
void FromU32 (u32 c)
 Color from u32 => 0xAABBGGRR.
 
void FromU32GammaToLinear (u32 c)
 Color from u32 => 0xAABBGGRR, RGB convert from Gamma corrected to Linear values.
 
Color LinearToGamma () const
 Convert color from linear to gamma corrected space.
 
Color GammaToLinear () const
 Convert color from gamma corrected to linear space.
 
Color Lerp (const Color &dest, float t) const
 
float Dot (const Color &rhs) const
 Dot product of two colors, uses all 4 components.
 
float Dot3 (const Color &rhs) const
 Dot product of two colors, using only the r,g,b components.
 
Color operator- () const
 
Color operator+ (const Color &rhs) const
 
Color operator- (const Color &rhs) const
 
Color operator* (const Color &rhs) const
 
Color operator/ (const Color &rhs) const
 
Color operator* (float multiplier) const
 
Color operator/ (float divisor) const
 
Coloroperator+= (const Color &rhs)
 
Coloroperator-= (const Color &rhs)
 
Coloroperator*= (const Color &rhs)
 
Coloroperator/= (const Color &rhs)
 
Coloroperator*= (float multiplier)
 
Coloroperator/= (float divisor)
 
bool IsLessThan (const Color &rhs) const
 
bool IsLessEqualThan (const Color &rhs) const
 
bool IsGreaterThan (const Color &rhs) const
 
bool IsGreaterEqualThan (const Color &rhs) const
 

Static Public Member Functions

static void Reflect (ReflectContext *context)
 
static Color CreateZero ()
 Creates a vector with all components set to zero, more efficient than calling Color(0.0f).
 
static Color CreateOne ()
 Creates a vector with all components set to one.
 
static Color CreateFromRgba (u8 r, u8 g, u8 b, u8 a)
 Sets components from rgba.
 
static Color CreateFromFloat4 (const float *values)
 Sets components from an array of 4 floats, stored in xyzw order.
 
static Color CreateFromVector3 (const Vector3 &v)
 Copies r,g,b components from a Vector3, sets w to 1.0.
 
static Color CreateFromVector3AndFloat (const Vector3 &v, float w)
 Copies r,g,b components from a Vector3, specify w separately.
 
static u32 CreateU32 (u8 r, u8 g, u8 b, u8 a)
 r,g,b,a to u32 => 0xAABBGGRR (COLREF format).
 
static float ConvertSrgbGammaToLinear (float x)
 Convert SRGB gamma space to linear space.
 
static float ConvertSrgbLinearToGamma (float x)
 Convert SRGB linear space to gamma space.
 

Detailed Description

A color class with 4 components, RGBA.

Member Function Documentation

◆ IsLessThan()

AZ_MATH_INLINE bool AZ::Color::IsLessThan ( const Color rhs) const

Comparison functions, not implemented as operators since that would probably be a little dangerous. These functions return true only if all components pass the comparison test.

◆ Lerp()

AZ_MATH_INLINE Color AZ::Color::Lerp ( const Color dest,
float  t 
) const

Linear interpolation between this color and a destination.

Returns
(this)(1-t) + dest*t

◆ Reflect()

static void AZ::Color::Reflect ( ReflectContext context)
static

AzCore Reflection.

Parameters
contextreflection context

◆ StoreToFloat4()

AZ_MATH_INLINE void AZ::Color::StoreToFloat4 ( float *  values) const

Stores the vector to an array of 4 floats. The floats need only be 4 byte aligned, 16 byte alignment is not required.


The documentation for this class was generated from the following files: