Open 3D Engine EMotionFX Gem 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.
MCore::RGBAColor Class Reference

#include <Color.h>

Public Member Functions

MCORE_INLINE RGBAColor ()
 
MCORE_INLINE RGBAColor (float value)
 
MCORE_INLINE RGBAColor (float cR, float cG, float cB, float cA=1.0f)
 
MCORE_INLINE RGBAColor (const RGBAColor &col)
 
 RGBAColor (uint32 col)
 
 RGBAColor (const AZ::Color &color)
 
 operator AZ::Color () const
 
MCORE_INLINE void Set (float cR, float cG, float cB, float cA)
 
MCORE_INLINE void Set (const RGBAColor &color)
 
MCORE_INLINE void Zero ()
 
MCORE_INLINE RGBAColorClamp ()
 
MCORE_INLINE float CalcLength () const
 
MCORE_INLINE float CalcIntensity () const
 
MCORE_INLINE bool CheckIfIsClose (const RGBAColor &col, float distSq=0.0001f) const
 
MCORE_INLINE uint32 ToInt () const
 
MCORE_INLINE RGBAColorExposure (float exposure=1.5f)
 
MCORE_INLINE RGBAColorNormalize ()
 
MCORE_INLINE bool operator== (const RGBAColor &col) const
 
MCORE_INLINE const RGBAColoroperator*= (const RGBAColor &col)
 
MCORE_INLINE const RGBAColoroperator+= (const RGBAColor &col)
 
MCORE_INLINE const RGBAColoroperator-= (const RGBAColor &col)
 
MCORE_INLINE const RGBAColoroperator*= (float m)
 
MCORE_INLINE const RGBAColoroperator/= (float d)
 
MCORE_INLINE const RGBAColoroperator= (const RGBAColor &col)
 
MCORE_INLINE const RGBAColoroperator= (float colorValue)
 
MCORE_INLINE float & operator[] (int32 row)
 
MCORE_INLINE operator float * ()
 
MCORE_INLINE operator const float * () const
 

Public Attributes

float m_r
 
float m_g
 
float m_b
 
float m_a
 

Detailed Description

The high precision color class. This template should be used with floats or doubles. Default predefined types are: RGBAColor, FRGBAColor, DRGBAColor. The component values go from 0 to 1, where 0 is black and 1 is white in case all components had this same value. It however is possible to go higher than 1. Color component values can also be clamped, normalized and affected by exposure control.

Constructor & Destructor Documentation

◆ RGBAColor() [1/6]

MCORE_INLINE MCore::RGBAColor::RGBAColor ( )
inline

Default constructor. Color will be set to black (0,0,0,0).

◆ RGBAColor() [2/6]

MCORE_INLINE MCore::RGBAColor::RGBAColor ( float  value)
inline

Constructor which sets all components to the same given value.

Parameters
valueThe value to put in all components (r,g,b,a).

◆ RGBAColor() [3/6]

MCORE_INLINE MCore::RGBAColor::RGBAColor ( float  cR,
float  cG,
float  cB,
float  cA = 1.0f 
)
inline

Constructor which sets each color component.

Parameters
cRThe value for red.
cGThe value for green.
cBThe value for blue.
cAThe value for alpha [default=1.0]

◆ RGBAColor() [4/6]

MCORE_INLINE MCore::RGBAColor::RGBAColor ( const RGBAColor col)
inline

Copy constructor.

Parameters
colThe color to copy the component values from.

◆ RGBAColor() [5/6]

MCore::RGBAColor::RGBAColor ( uint32  col)
inline

Constructor to convert a 32-bits DWORD to a high precision color.

Parameters
colThe 32-bits DWORD, for example constructed using the MCore::RGBA(...) function.

◆ RGBAColor() [6/6]

MCore::RGBAColor::RGBAColor ( const AZ::Color &  color)
inline

Constructor to convert from AZ::Color. This constructor is convenient until we replace the usage of this class with AZ::Color

Parameters
colorThe AZ::Color to construct from

Member Function Documentation

◆ CalcIntensity()

MCORE_INLINE float MCore::RGBAColor::CalcIntensity ( ) const
inline

Calculates and returns the intensity of the color. This gives an idea of how bright the color would be on the screen.

Returns
The intensity.

◆ CalcLength()

MCORE_INLINE float MCore::RGBAColor::CalcLength ( ) const
inline

Returns the length of the color components (r, g, b), just like you calculate the length of a vector. The higher the length value, the more bright the color will be.

Returns
The length of the vector constructed by the r, g and b components.

◆ CheckIfIsClose()

MCORE_INLINE bool MCore::RGBAColor::CheckIfIsClose ( const RGBAColor col,
float  distSq = 0.0001f 
) const
inline

Checks if this color is close to another given color.

Parameters
colThe other color to compare with.
distSqThe square distance of maximum tollerance of the difference. A value of 0 would mean the colors have to be exactly the same.
Returns
Returns true when the colors are the same (or close enough to eachother). Otherwise false is returned.

◆ Clamp()

MCORE_INLINE RGBAColor & MCore::RGBAColor::Clamp ( )
inline

Clamp all color component values in a range of 0..1 This can screw up your colors of course. Unless you just want to clamp we advise you to use the Exposure method for exposure control or the Normalize method.

Returns
The clamped color.

◆ Exposure()

MCORE_INLINE RGBAColor & MCore::RGBAColor::Exposure ( float  exposure = 1.5f)
inline

Perform exposure control on the color components. This will give much better results than just clamping the values between 0 and 1.

Parameters
exposureThe exposure value [default=1.5]
Returns
Returns itself, but now with exposure control performed on it.

◆ Normalize()

MCORE_INLINE RGBAColor & MCore::RGBAColor::Normalize ( )
inline

Smart normalizes the color. This means it will scale the values in a range of 0..1 if they are out of range. It picks the value of the component with the highest value. And makes this into a value of 1, while scaling the others down with the correct amounts. So it's not really normalizing like you normalize a vector, but it is a little bit more intelligent and will only perform it when needed, so it won't touch the colors if they are already in range of 0..1.

Returns
The normalized color.

◆ operator AZ::Color()

MCore::RGBAColor::operator AZ::Color ( ) const
inline

Automatic conversion to AZ::Color until we remove the u sage of this class with AZ::Color

◆ Set() [1/2]

MCORE_INLINE void MCore::RGBAColor::Set ( const RGBAColor color)
inline

Set the color component values.

Parameters
colorThe color to set.

◆ Set() [2/2]

MCORE_INLINE void MCore::RGBAColor::Set ( float  cR,
float  cG,
float  cB,
float  cA 
)
inline

Set the color component values.

Parameters
cRThe value for red.
cGThe value for green.
cBThe value for blue.
cAThe value for alpha.

◆ ToInt()

MCORE_INLINE uint32 MCore::RGBAColor::ToInt ( ) const
inline

Convert this high precision color to a 32-bit DWORD value. In order to work correctly, the color component values must be in range of 0..1. So they have to be clamped, normalized or exposure controlled before calling this method.

Returns
The 32-bit integer value where each byte is a color component.

◆ Zero()

MCORE_INLINE void MCore::RGBAColor::Zero ( )
inline

Clear the color component values. Set them all to zero, so the color turns into black.

Member Data Documentation

◆ m_a

float MCore::RGBAColor::m_a

Alpha component.

◆ m_b

float MCore::RGBAColor::m_b

Blue component.

◆ m_g

float MCore::RGBAColor::m_g

Green component.

◆ m_r

float MCore::RGBAColor::m_r

Red component.


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