Colour#

class Colour#

RGBA color representation with floating point components.

This class represents a color using red, green, blue, and alpha components as floating point values. It provides various constructors for different color representations and arithmetic operators for color manipulation.

Color components are typically in the range [0.0, 1.0], though values outside this range are supported for HDR operations.

Public Types

enum Preset#

Predefined color presets.

Enumeration of common colors for convenience.

Values:

enumerator kRed#

Pure red color (1.0, 0.0, 0.0, 1.0).

enumerator kGreen#

Pure green color (0.0, 1.0, 0.0, 1.0).

enumerator kBlue#

Pure blue color (0.0, 0.0, 1.0, 1.0).

enumerator kWhite#

Pure white color (1.0, 1.0, 1.0, 1.0).

enumerator kBlack#

Pure black color (0.0, 0.0, 0.0, 1.0).

Public Functions

inline Colour(
float r_ = 0.0f,
float g_ = 0.0f,
float b_ = 0.0f,
float a_ = 1.0f,
)#

Default constructor with optional RGBA values.

Parameters:
  • r_[in] Red component (default: 0.0)

  • g_[in] Green component (default: 0.0)

  • b_[in] Blue component (default: 0.0)

  • a_[in] Alpha component (default: 1.0)

inline Colour(float *p)#

Constructor from float array.

Parameters:

p[in] Array of 4 floats representing RGBA values

inline Colour(uint32_t rgba)#

Constructor from packed 32-bit RGBA value.

Parameters:

rgba[in] Packed RGBA value in format 0xRRGGBBAA

inline Colour(Preset p)#

Constructor from color preset.

Parameters:

p[in] Predefined color preset

inline operator const float*() const#

Conversion operator to const float pointer.

Returns:

Pointer to the first color component

inline operator float*()#

Conversion operator to float pointer.

Returns:

Pointer to the first color component

inline Colour operator*(float scale) const#

Scalar multiplication operator.

Parameters:

scale[in] Scalar value to multiply all components by

Returns:

New color with scaled components

inline Colour operator/(float scale) const#

Scalar division operator.

Parameters:

scale[in] Scalar value to divide all components by

Returns:

New color with divided components

inline Colour operator+(const Colour &v) const#

Color addition operator.

Parameters:

v[in] Color to add

Returns:

New color with added components

inline Colour operator-(const Colour &v) const#

Color subtraction operator.

Parameters:

v[in] Color to subtract

Returns:

New color with subtracted components

inline Colour operator*(const Colour &scale) const#

Component-wise color multiplication operator.

Parameters:

scale[in] Color to multiply with component-wise

Returns:

New color with multiplied components

inline Colour &operator*=(float scale)#

In-place scalar multiplication operator.

Parameters:

scale[in] Scalar value to multiply all components by

Returns:

Reference to this color after multiplication

inline Colour &operator/=(float scale)#

In-place scalar division operator.

Parameters:

scale[in] Scalar value to divide all components by

Returns:

Reference to this color after division

inline Colour &operator+=(const Colour &v)#

In-place color addition operator.

Parameters:

v[in] Color to add

Returns:

Reference to this color after addition

inline Colour &operator-=(const Colour &v)#

In-place color subtraction operator.

Parameters:

v[in] Color to subtract

Returns:

Reference to this color after subtraction

inline Colour &operator*=(const Colour &v)#

In-place component-wise color multiplication operator.

Parameters:

v[in] Color to multiply with component-wise

Returns:

Reference to this color after multiplication

Public Members

float r#

Red color component.

float g#

Green color component.

float b#

Blue color component.

float a#

Alpha (transparency) component.