class Color

Color represented as 4 components, each being a floating point value ranging from 0 to 1.

Color components are red, green, blue and alpha.

Public

Constructors

Color

constexpr Color(float red = 1.F, float green = 1.F, float blue = 1.F, float alpha = 1.F)

Methods

GetAsRgba

RGBA GetAsRgba() const

Returns the color as a 32-bit value in RGBA order.

GetAsArgb

ARGB GetAsArgb() const

Returns the color as a 32-bit value in ARGB order.

GetAsBgra

BGRA GetAsBgra() const

Returns the color as a 32-bit value in BGRA order.

GetAsAbgr

ABGR GetAsAbgr() const

Returns the color as a 32-bit value in ABGR order.

GetHsb

void GetHsb(float *outHue, float *outSaturation, float *outBrightness) const

Convert the current color to hue, saturation and brightness values.

outHue
Output hue value, scaled to the [0,1] range.
outSaturation
Output saturation level, [0,1].
outBrightness
Output brightness level, [0,1].

GetLinear

Color GetLinear() const

Converts the current color from gamma to linear space and returns the result.

GetGamma

Color GetGamma() const

Converts the current color from linear to gamma space and returns the result.

Saturate

void Saturate()

Clamps color value to the range [0, 1].

SaturateCopy

Color SaturateCopy() const

Clamps colour value to the range [0, 1].

Returned saturated color as a copy.

Ptr

float *Ptr()

Pointer accessor for direct copying.

Ptr

const float *Ptr() const

Pointer accessor for direct copying.

staticFromRgba

static Color FromRgba(RGBA val)

Creates a color value from a 32-bit value that encodes a RGBA color.

staticFromArgb

static Color FromArgb(ARGB val)

Creates a color value from a 32-bit value that encodes a ARGB color.

staticFromBgra

static Color FromBgra(BGRA val)

Creates a color value from a 32-bit value that encodes a BGRA color.

staticFromAbgr

static Color FromAbgr(ABGR val)

Creates a color value from a 32-bit value that encodes a ABGR color.

staticFromHSB

static Color FromHSB(float hue, float saturation, float brightness, float alpha = 1.F)

Creates a color value from hue, saturation and brightness.

hue
Hue value, scaled to the [0,1] range.
saturation
Saturation level, [0,1].
brightness
Brightness level, [0,1].
alpha
Transparency level, [0,1].

staticFromHSL

static Color FromHSL(float hue, float saturation, float lightness, float alpha = 1.F)

Creates an RGBA color from a HSL(A) color.

hue
Hue value, scaled to the [0,1] range.
saturation
Saturation level, [0,1].
lightness
Lightness level, [0,1].
alpha
Transparency level, [0,1].

staticLerp

static Color Lerp(float t, const Color &a, const Color &b)

Linearly interpolates between the two colors using . t should be in [0, 1] range, where t = 0 corresponds to the left color, while t = 1 corresponds to the right color.

staticLerp

static constexpr RGBA Lerp(u8 t, RGBA from, RGBA to)

Linearly interpolates between the two colors using . t should be in [0, 255] range, where t = 0 corresponds to the left color, while t = 1 corresponds to the right color.

Operates directly on 8-bit per channel encoded color instead of on floating point values.

Fields

R

float R

G

float G

B

float B

A

float A

Operators

operator==

bool operator==(const Color &rhs) const

operator!=

bool operator!=(const Color &rhs) const

operator[]

float operator[](const u32 i) const

operator[]

float &operator[](const u32 i)

operator+

Color operator+(const Color &rhs) const

operator-

Color operator-(const Color &rhs) const

operator*

Color operator*(float rhs) const

operator*

Color operator*(const Color &rhs) const

operator/

Color operator/(const Color &rhs) const

operator/

Color operator/(float rhs) const

operator+=

Color &operator+=(const Color &rhs)

operator-=

Color &operator-=(const Color &rhs)

operator*=

Color &operator*=(const Color &rhs)

operator*=

Color &operator*=(float rhs)

operator/=

Color &operator/=(float rhs)