You.i Engine
CYIColor Class Reference

Detailed Description

A class used to represent a color value.

This class stores colors as a glm::vec4 (e.g. as four floating-point values). Setters and accessors are provided to set/get color components both as floating point values (between 0.0f and 1.0f), and as byte values (between 0 and 255).

The application of a CYIColor is determined by the containing class as well as the shader program in effect.

For platforms that support C++/CX, the CYIColorCXUtilities class contains utilities for converting to and from WinRT color classes.

See also
CYIMaterial
CYIAssetManager::YI_PROGRAM_3D_EFFECT_COLOR_REPLACE
Warning
While floating-point color components below 0.0f and above 1.0f are allowed, their use can result in undefined behaviour in functions that take CYIColor objects as input.

When dealing with colors packed into 32-bit integers, a byte ordering can be specified for the individual color components. By default, the ABGR ordering is used.

Pre-defined colors are available both as static objects and by name (through the FromString function).

#include <utility/YiColor.h>

Public Types

enum  ByteOrder {
  ByteOrder::RGBA = 0,
  ByteOrder::ARGB,
  ByteOrder::BGRA,
  ByteOrder::ABGR
}
 

Public Member Functions

 CYIColor ()
 Default constructor. More...
 
 CYIColor (const CYIColor &other)
 Copy constructor. More...
 
 CYIColor (CYIColor &&other) noexcept
 Move constructor. More...
 
 CYIColor (const CYIColor &color, float alpha)
 Constructs a new color from color, while using the transparency value alpha. More...
 
 CYIColor (double red, double green, double blue, double alpha=1.0)
 Double-precision floating-point Constructor. More...
 
 CYIColor (float red, float green, float blue, float alpha=1.0f)
 Floating-point Constructor. More...
 
 CYIColor (const glm::vec3 &rgb)
 GLM Vector3D Constructor. More...
 
 CYIColor (const glm::vec4 &rgba)
 GLM Vector4D Constructor. More...
 
 CYIColor (uint32_t packed, ByteOrder byteOrder=ByteOrder::ABGR)
 Packed 4x8-bit Constructor. More...
 
 CYIColor (CYIStringView name)
 Named color constructor. More...
 
CYIColoroperator= (const CYIColor &color)
 Copy assignment operator. More...
 
CYIColoroperator= (CYIColor &&color)
 Move assignment operator. More...
 
CYIColoroperator= (const glm::vec3 &rgb)
 GLM Vector3D assignment operator. More...
 
CYIColoroperator= (const glm::vec4 &rgba)
 GLM Vector4D assignment operator. More...
 
void SetColor (const CYIColor &color)
 Sets the color to the same color of another RGB instance. More...
 
void SetColor (float red, float green, float blue, float alpha=1.0f)
 Sets the color to a given set floating-point values. More...
 
void SetColorInteger (int32_t red, int32_t green, int32_t blue, int32_t alpha=255)
 Sets the color to a given set of signed integer values. More...
 
void SetColor (const glm::vec3 &rgb)
 Sets the color to a given GLM Vector3D. More...
 
void SetColor (const glm::vec4 &rgba)
 Sets the color to a given GLM Vector4D. More...
 
void SetColor (uint32_t packed, ByteOrder byteOrder=ByteOrder::ABGR)
 Sets the color to a given packed 4x8-bit value. More...
 
void SetRed (double red)
 
void SetRed (float red)
 
void SetRedInteger (int32_t red)
 
void SetGreen (double green)
 
void SetGreen (float green)
 
void SetGreenInteger (int32_t green)
 
void SetBlue (double blue)
 
void SetBlue (float blue)
 
void SetBlueInteger (int32_t blue)
 
void SetAlpha (double alpha)
 
void SetAlpha (float alpha)
 
void SetAlphaInteger (int32_t alpha)
 
void SetHSLHue (float hue)
 
void SetHSLHueInteger (int32_t hue)
 
void SetHSLSaturation (float saturation)
 
void SetHSLSaturationInteger (int32_t saturation)
 
void SetHSLLightness (float lightness)
 
void SetHSLLightnessInteger (int32_t lightness)
 
float GetRed () const
 
float GetGreen () const
 
float GetBlue () const
 
float GetAlpha () const
 
float GetHSLHue () const
 
float GetHSLSaturation () const
 
float GetHSLLightness () const
 
bool IsVisible () const
 
uint8_t GetRedByte () const
 
uint8_t GetGreenByte () const
 
uint8_t GetBlueByte () const
 
uint8_t GetAlphaByte () const
 
uint32_t GetPackedColor (ByteOrder byteOrder=ByteOrder::ABGR) const
 
CYIColor GetInverted () const
 
CYIColor GetPremultiplied () const
 
CYIColor GetClamped () const
 
CYIString ToHexString (ByteOrder byteOrder=ByteOrder::RGBA) const
 
const glm::vec4 & GetColorVector () const
 
glm::vec4 GetHSLAColorVector () const
 
template<typename T = bool>
 CYIColor (int32_t r, int32_t g, int32_t b, int32_t a=255)
 
template<typename T = bool>
 CYIColor (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
 
template<typename T = bool>
void SetColor (int32_t r, int32_t g, int32_t b, int32_t a=255)
 
template<typename T = bool>
void SetRed (int32_t r)
 
template<typename T = bool>
void SetRed (uint8_t r)
 
template<typename T = bool>
void SetGreen (int32_t g)
 
template<typename T = bool>
void SetGreen (uint8_t g)
 
template<typename T = bool>
void SetBlue (int32_t b)
 
template<typename T = bool>
void SetBlue (uint8_t b)
 
template<typename T = bool>
void SetAlpha (int32_t a)
 
template<typename T = bool>
void SetAlpha (uint8_t a)
 

Static Public Member Functions

static const CYINamedColorsNamed ()
 
static const CYINamedColorsGetNamedColors ()
 
static CYIColor GetColorByName (CYIStringView colorName, bool *pError=nullptr)
 
static CYIColor FromString (CYIStringView colorName, bool *pError=nullptr)
 
static CYIColor FromColor (const CYIColor &color, float alpha)
 
static CYIColor FromRGB (float red, float green, float blue, float alpha=1.0f)
 
static CYIColor FromRGBInteger (int32_t red, int32_t green, int32_t blue, int32_t alpha=255)
 
static CYIColor FromRGB (const glm::vec3 &rgbVector)
 
static CYIColor FromRGBA (const glm::vec4 &rgbaVector)
 
static CYIColor FromPackedRGBA (uint32_t packed, ByteOrder byteOrder=ByteOrder::ABGR)
 
static CYIColor FromHSL (float hue, float saturation, float luminance, float alpha=1.0f)
 
static CYIColor FromHSL (const glm::vec3 &hslVector)
 
static CYIColor FromHSLA (const glm::vec4 &hslaVector)
 
static uint32_t GetPackedColor (uint8_t red, uint32_t green, uint32_t blue, uint32_t alpha, ByteOrder byteOrder=ByteOrder::ABGR)
 

Friends

bool operator== (const CYIColor &lhs, const CYIColor &rhs)
 
bool operator!= (const CYIColor &lhs, const CYIColor &rhs)
 
bool operator< (const CYIColor &lhs, const CYIColor &rhs)
 
bool operator<= (const CYIColor &lhs, const CYIColor &rhs)
 
bool operator> (const CYIColor &lhs, const CYIColor &rhs)
 
bool operator>= (const CYIColor &lhs, const CYIColor &rhs)
 

Member Enumeration Documentation

◆ ByteOrder

enum CYIColor::ByteOrder
strong

An enum listing the possible byte orders for colors packed in a 32bit integer.

Enumerator
RGBA 

Represent a color with the format 0xRRGGBBAA.

ARGB 

Represent a color with the format 0xAARRGGBB.

BGRA 

Represent a color with the format 0xBBGGRRAA.

ABGR 

Represent a color with the format 0xAABBGGRR.

Constructor & Destructor Documentation

◆ CYIColor() [1/12]

CYIColor::CYIColor ( )

Default constructor.

Initializes the color to Transparent.

◆ CYIColor() [2/12]

CYIColor::CYIColor ( const CYIColor other)

Copy constructor.

◆ CYIColor() [3/12]

CYIColor::CYIColor ( CYIColor &&  other)
noexcept

Move constructor.

◆ CYIColor() [4/12]

CYIColor::CYIColor ( const CYIColor color,
float  alpha 
)

Constructs a new color from color, while using the transparency value alpha.

Parameters
colorthe color to copy.
alphathe opacity to use

◆ CYIColor() [5/12]

CYIColor::CYIColor ( double  red,
double  green,
double  blue,
double  alpha = 1.0 
)

Double-precision floating-point Constructor.

Warning
Because color components are represented internally as floats, calling this constructor may result in loss of precision.
Parameters
redthe red component. Value should be between 0.0 to 1.0.
greenthe green component. Value should be between 0.0 to 1.0.
bluethe blue component. Value should be between 0.0 to 1.0.
alphathe alpha component. Value should be between 0.0 to 1.0.
Deprecated:
This function has been deprecated and may be removed in a future release. CYIColor(float, float, float, float) should be used instead.

◆ CYIColor() [6/12]

CYIColor::CYIColor ( float  red,
float  green,
float  blue,
float  alpha = 1.0f 
)

Floating-point Constructor.

Parameters
redthe red component. Value should be between 0.0f to 1.0f.
greenthe green component. Value should be between 0.0f to 1.0f.
bluethe blue component. Value should be between 0.0f to 1.0f.
alphathe alpha component. Value should be between 0.0f to 1.0f.

◆ CYIColor() [7/12]

CYIColor::CYIColor ( const glm::vec3 &  rgb)

GLM Vector3D Constructor.

Parameters
rgbthe red, blue and green components. Values should be between glm::vec3(0.0f) and glm::vec3(1.0f).
Note
the alpha component will automatically set to 1.0.

◆ CYIColor() [8/12]

CYIColor::CYIColor ( const glm::vec4 &  rgba)

GLM Vector4D Constructor.

Parameters
rgbathe red, blue, green and alpha components. Values should be between glm::vec4(0.0f) and glm::vec4(1.0f).

◆ CYIColor() [9/12]

CYIColor::CYIColor ( uint32_t  packed,
ByteOrder  byteOrder = ByteOrder::ABGR 
)
explicit

Packed 4x8-bit Constructor.

Parameters
packedpacked 4x8-bit values between the range of 0 and 255.
byteOrderdefines the order in which bytes are read from the packed parameter. The default order is CYIColor::ByteOrder::ABGR.
See also
CYIColor::ByteOrder

◆ CYIColor() [10/12]

CYIColor::CYIColor ( CYIStringView  name)
explicit

Named color constructor.

Parameters
namethe name of the color
See also
FromString

◆ CYIColor() [11/12]

template<typename T = bool>
CYIColor::CYIColor ( int32_t  r,
int32_t  g,
int32_t  b,
int32_t  a = 255 
)
Deprecated:
This constructor has been removed. FromRGBInteger should be used instead.

◆ CYIColor() [12/12]

template<typename T = bool>
CYIColor::CYIColor ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
Deprecated:
This constructor has been removed. FromRGBInteger should be used instead.

Member Function Documentation

◆ FromColor()

static CYIColor CYIColor::FromColor ( const CYIColor color,
float  alpha 
)
static

Returns a new color created from color, while using the transparency value alpha.

◆ FromHSL() [1/2]

static CYIColor CYIColor::FromHSL ( float  hue,
float  saturation,
float  luminance,
float  alpha = 1.0f 
)
static

Creates a color object from HSLA (Hue/Saturation/Lightness/Alpha) color information. All values must be normalized between 0.0 and 1.0.

See also
GetHSLAColorVector

◆ FromHSL() [2/2]

static CYIColor CYIColor::FromHSL ( const glm::vec3 &  hslVector)
static

Creates a color object from HSL (Hue/Saturation/Lightness) color information. All values must be normalized between 0.0 and 1.0.

The first component of the vector is expected to be the hue, the second component is expected to be the saturation, and the third component is expected to the lightness.

See also
GetHSLAColorVector

◆ FromHSLA()

static CYIColor CYIColor::FromHSLA ( const glm::vec4 &  hslaVector)
static

Creates a color object from a glm::vec4 containing a HSLA (Hue/Saturation/Lightness/Alpha) color information.

The first component of the vector is expected to be the hue, the second component is expected to be the saturation, the third component is expected to the lightness, and the last component is expected to be the alpha. All values must be normalized between 0.0 and 1.0.

See also
GetHSLAColorVector

◆ FromPackedRGBA()

static CYIColor CYIColor::FromPackedRGBA ( uint32_t  packed,
ByteOrder  byteOrder = ByteOrder::ABGR 
)
static

Returns a new color created from the provided packed integer. A byte order can be provided – if absent, CYIColor::ByteOrder::ABGR is assumed.

See also
GetPackedColor 

◆ FromRGB() [1/2]

static CYIColor CYIColor::FromRGB ( float  red,
float  green,
float  blue,
float  alpha = 1.0f 
)
static

Returns a new color created from the provided red, green and blue components. A transparency value can optionally be provided. All values should be between 0.0 and 1.0.

◆ FromRGB() [2/2]

static CYIColor CYIColor::FromRGB ( const glm::vec3 &  rgbVector)
static

Returns a new color created from the provided red, green and blue components. A transparency value of 1.0 will be assumed. All values should be between 0.0 and 1.0.

◆ FromRGBA()

static CYIColor CYIColor::FromRGBA ( const glm::vec4 &  rgbaVector)
static

Returns a new color created from the provided red, green, blue and alpha components. All values should be between 0.0 and 1.0.

◆ FromRGBInteger()

static CYIColor CYIColor::FromRGBInteger ( int32_t  red,
int32_t  green,
int32_t  blue,
int32_t  alpha = 255 
)
static

Returns a new color created from the provided red, green and blue components. A transparency value can optionally be provided. All values should be between 0 and 255 inclusively.

◆ FromString()

static CYIColor CYIColor::FromString ( CYIStringView  colorName,
bool *  pError = nullptr 
)
static

This function returns a color instance by name. CSS 3 named colors, hexadecimal values, rgb expressions and hsla expressions are supported. The following string types are supported:

  • Named colors (e.g. lightsalmon). Named colors, with the exception of transparent, have an alpha value of 1.0. CSS 3 and W3C color names are supported.
  • RGB hexadecimal values (e.g. #0A2 or #00AA2B ). This assumes an alpha value of 1.0.
  • RGBA hexadecimal values (e.g. #0A28 or #00AA2B80 ).
  • rgb() expressions (e.g. rgb(0, 255, 128) ). This assumes an alpha value of 1.0.
  • rgba() expressions (e.g. rgba(0, 255, 128, 0.5) ).
  • hsl() expressions (e.g. hsl(210, 50%, 25%) ).
  • hsla() expressions (e.g. hsla(210, 50%, 25%, 0.5) ).
Note
Named colors are case insensitive. For example, both CYIColor::FromString("Crimson") and CYIColor::FromString("crimson") will return same color.
Warning
CSS 2 system color names are not supported.
Note
The string must be trimmed before this function is called. Leading or trailing spaces will cause parsing to fail.

If pError is non-null, its pointed-to variable will be set to true if an error is encountered (and no warning will be logged).

See also
https://www.w3.org/TR/css-color-3/#colorunits

◆ GetAlpha()

float CYIColor::GetAlpha ( ) const

Returns the value of the alpha channel. The value should be between 0.0f and 1.0f

◆ GetAlphaByte()

uint8_t CYIColor::GetAlphaByte ( ) const

Returns the value of the alpha channel. The value is clamped between 0 and 255

◆ GetBlue()

float CYIColor::GetBlue ( ) const

Returns the value of the blue channel. The value should be between 0.0f and 1.0f

◆ GetBlueByte()

uint8_t CYIColor::GetBlueByte ( ) const

Returns the value of the blue channel. The value is clamped between 0 and 255

◆ GetClamped()

CYIColor CYIColor::GetClamped ( ) const

Returns this color with all components clamped between 0.0f and 1.0f.

◆ GetColorByName()

static CYIColor CYIColor::GetColorByName ( CYIStringView  colorName,
bool *  pError = nullptr 
)
static

Returns a color instance by name.

Deprecated:
This function has been deprecated and may be removed in a future release. FromString should be used instead.

◆ GetColorVector()

const glm::vec4& CYIColor::GetColorVector ( ) const

Returns a glm::vec4 containing the RGBA color data.

◆ GetGreen()

float CYIColor::GetGreen ( ) const

Returns the value of the green channel. The value should be between 0.0f and 1.0f

◆ GetGreenByte()

uint8_t CYIColor::GetGreenByte ( ) const

Returns the value of the green channel. The value is clamped between 0 and 255

◆ GetHSLAColorVector()

glm::vec4 CYIColor::GetHSLAColorVector ( ) const

Returns a glm::vec4 containing the HSLA (Hue/Saturation/Lightness/Alpha) representation of the color data. All values are normalized between 0.0 and 1.0.

Note
The first component of the vec4 contains the hue, the second component contains the saturation, the third component contains the lightness and the fourth component contains the alpha.
See also
FromHSLA

◆ GetHSLHue()

float CYIColor::GetHSLHue ( ) const

Returns the hue of this color (as represented in the HSL color space). The value will be normalized between 0.0f and 1.0f.

See also
GetHSLAColorVector

◆ GetHSLLightness()

float CYIColor::GetHSLLightness ( ) const

Returns the lightness of this color (as represented in the HSL color space). The value will be normalized between 0.0f and 1.0f.

See also
GetHSLAColorVector

◆ GetHSLSaturation()

float CYIColor::GetHSLSaturation ( ) const

Returns the saturation of this color (as represented in the HSL color space). The value will be normalized between 0.0f and 1.0f.

See also
GetHSLAColorVector

◆ GetInverted()

CYIColor CYIColor::GetInverted ( ) const

Returns the inverse of this color. Only the red, green and blue channels are inverted – not the transparency.

◆ GetNamedColors()

static const CYINamedColors& CYIColor::GetNamedColors ( )
static

◆ GetPackedColor() [1/2]

uint32_t CYIColor::GetPackedColor ( ByteOrder  byteOrder = ByteOrder::ABGR) const

Returns the packed 4x8-bit representation of this color. The order of the bytes in the returned integer will depend on the value of byteOrder. By default, an order of CYIColor::ByteOrder::ABGR is used.

Note
Color components should be between 0 and 255.

◆ GetPackedColor() [2/2]

static uint32_t CYIColor::GetPackedColor ( uint8_t  red,
uint32_t  green,
uint32_t  blue,
uint32_t  alpha,
ByteOrder  byteOrder = ByteOrder::ABGR 
)
inlinestatic

This function 'packs' a color, represented as four byte components, into a single 32-bit word. The order of the bytes is specified through the byteOrder parameter. By default, the color is packed as 0xAABBGGRR.

◆ GetPremultiplied()

CYIColor CYIColor::GetPremultiplied ( ) const

Returns this color with the alpha premultiplied onto each of its color channels.

Warning
Do not call this function on a CYIColor object that is already pre-multiplied. Doing so will return a CYIColor object with incorrect color channels.

◆ GetRed()

float CYIColor::GetRed ( ) const

Returns the value of the red channel. The value should be between 0.0f and 1.0f

◆ GetRedByte()

uint8_t CYIColor::GetRedByte ( ) const

Returns the value of the red channel. The value is clamped between 0 and 255

◆ IsVisible()

bool CYIColor::IsVisible ( ) const

Returns true if this color has a non-0 alpha value.

◆ Named()

static const CYINamedColors& CYIColor::Named ( )
static

Returns a struct containing predefined named colors. Predefined named colors are accessed like this: const CYIColor &red = CYIColor::Named().Red;

Predefined named colors can safely be stored as references in static const variables without risking static initialization order issues.

◆ operator=() [1/4]

CYIColor& CYIColor::operator= ( const CYIColor color)

Copy assignment operator.

Parameters
colorthe color to copy.

◆ operator=() [2/4]

CYIColor& CYIColor::operator= ( CYIColor &&  color)

Move assignment operator.

Parameters
colorthe color to move.

◆ operator=() [3/4]

CYIColor& CYIColor::operator= ( const glm::vec3 &  rgb)

GLM Vector3D assignment operator.

Parameters
rgbthe red, blue and green components. Values should be between glm::vec3(0.0f) and glm::vec3(1.0f).
Note
the alpha component will automatically set to 1.0.

◆ operator=() [4/4]

CYIColor& CYIColor::operator= ( const glm::vec4 &  rgba)

GLM Vector4D assignment operator.

Parameters
rgbathe red, blue, green and alpha components. Values should be between glm::vec4(0.0f) and glm::vec4(1.0f).

◆ SetAlpha() [1/4]

void CYIColor::SetAlpha ( double  alpha)

Sets the alpha color channel. Value should be between 0.0f and 1.0f

Warning
Because color components are represented internally as floats, calling this setter may result in loss of precision.
Deprecated:
This function has been deprecated and may be removed in a future release. SetAlpha(float) should be used instead.

◆ SetAlpha() [2/4]

void CYIColor::SetAlpha ( float  alpha)

Sets the red color channel. Value should be between 0.0f and 1.0f

◆ SetAlpha() [3/4]

template<typename T = bool>
void CYIColor::SetAlpha ( int32_t  a)
Deprecated:
This setter has been removed. SetAlphaInteger should be used instead.

◆ SetAlpha() [4/4]

template<typename T = bool>
void CYIColor::SetAlpha ( uint8_t  a)
Deprecated:
This setter has been removed. SetAlphaInteger should be used instead.

◆ SetAlphaInteger()

void CYIColor::SetAlphaInteger ( int32_t  alpha)

Sets the alpha color channel. Value should be between 0 and 255.

◆ SetBlue() [1/4]

void CYIColor::SetBlue ( double  blue)

Sets the blue color channel. Value should be between 0.0f and 1.0f

Warning
Because color components are represented internally as floats, calling this setter may result in loss of precision.
Deprecated:
This function has been deprecated and may be removed in a future release. SetBlue(float) should be used instead.

◆ SetBlue() [2/4]

void CYIColor::SetBlue ( float  blue)

Sets the blue color channel. Value should be between 0.0f and 1.0f

◆ SetBlue() [3/4]

template<typename T = bool>
void CYIColor::SetBlue ( int32_t  b)
Deprecated:
This setter has been removed. SetBlueInteger should be used instead.

◆ SetBlue() [4/4]

template<typename T = bool>
void CYIColor::SetBlue ( uint8_t  b)
Deprecated:
This setter has been removed. SetBlueInteger should be used instead.

◆ SetBlueInteger()

void CYIColor::SetBlueInteger ( int32_t  blue)

Sets the blue color channel. Value should be between 0 and 255.

◆ SetColor() [1/6]

void CYIColor::SetColor ( const CYIColor color)

Sets the color to the same color of another RGB instance.

Parameters
colorthe color to copy.

◆ SetColor() [2/6]

void CYIColor::SetColor ( float  red,
float  green,
float  blue,
float  alpha = 1.0f 
)

Sets the color to a given set floating-point values.

Parameters
redthe red component. Value should be between 0.0f to 1.0f.
greenthe green component. Value should be between 0.0f to 1.0f.
bluethe blue component. Value should be between 0.0f to 1.0f.
alphathe alpha component. Value should be between 0.0f to 1.0f.

◆ SetColor() [3/6]

void CYIColor::SetColor ( const glm::vec3 &  rgb)

Sets the color to a given GLM Vector3D.

Parameters
rgbthe red, blue and green components. Values should be between glm::vec3(0.0f) and glm::vec3(1.0f).
Note
the alpha component will automatically set to 1.0f.

◆ SetColor() [4/6]

void CYIColor::SetColor ( const glm::vec4 &  rgba)

Sets the color to a given GLM Vector4D.

Parameters
rgbathe red, blue, green and alpha components. Values should be between glm::vec4(0.0f) and glm::vec4(1.0f).

◆ SetColor() [5/6]

void CYIColor::SetColor ( uint32_t  packed,
ByteOrder  byteOrder = ByteOrder::ABGR 
)

Sets the color to a given packed 4x8-bit value.

Parameters
packedpacked 4x8-bit values between the range of 0 and 255.
byteOrderdefines the order in which bytes are read from the packed parameter. The default order is CYIColor::ByteOrder::ABGR.
See also
CYIColor::ByteOrder

◆ SetColor() [6/6]

template<typename T = bool>
void CYIColor::SetColor ( int32_t  r,
int32_t  g,
int32_t  b,
int32_t  a = 255 
)
Deprecated:
This setter has been removed. SetColorInteger should be used instead.

◆ SetColorInteger()

void CYIColor::SetColorInteger ( int32_t  red,
int32_t  green,
int32_t  blue,
int32_t  alpha = 255 
)

Sets the color to a given set of signed integer values.

Parameters
redthe red component. Value should be between 0 to 255.
greenthe green component. Value should be between 0 to 255.
bluethe blue component. Value should be between 0 to 255.
alphathe alpha component. Value should be between 0 to 255.

◆ SetGreen() [1/4]

void CYIColor::SetGreen ( double  green)

Sets the green color channel. Value should be between 0.0f and 1.0f

Warning
Because color components are represented internally as floats, calling this setter may result in loss of precision.
Deprecated:
This function has been deprecated and may be removed in a future release. SetGreen(float) should be used instead.

◆ SetGreen() [2/4]

void CYIColor::SetGreen ( float  green)

Sets the green color channel. Value should be between 0.0f and 1.0f

◆ SetGreen() [3/4]

template<typename T = bool>
void CYIColor::SetGreen ( int32_t  g)
Deprecated:
This setter has been removed. SetGreenInteger should be used instead.

◆ SetGreen() [4/4]

template<typename T = bool>
void CYIColor::SetGreen ( uint8_t  g)
Deprecated:
This setter has been removed. SetGreenInteger should be used instead.

◆ SetGreenInteger()

void CYIColor::SetGreenInteger ( int32_t  green)

Sets the green color channel. Value should be between 0 and 255.

◆ SetHSLHue()

void CYIColor::SetHSLHue ( float  hue)

Sets the hue of this color to hue. The value should be between 0.0f and 1.0f.

◆ SetHSLHueInteger()

void CYIColor::SetHSLHueInteger ( int32_t  hue)

Sets the hue of this color to hue. Value should be between 0 and 255.

◆ SetHSLLightness()

void CYIColor::SetHSLLightness ( float  lightness)

Sets the lightness of this color to l. The value should be between 0.0f and 1.0f.

◆ SetHSLLightnessInteger()

void CYIColor::SetHSLLightnessInteger ( int32_t  lightness)

Sets the lightness of this color to lightness. Value should be between 0 and 255.

◆ SetHSLSaturation()

void CYIColor::SetHSLSaturation ( float  saturation)

Sets the saturation of this color to saturation. The value should be between 0.0f and 1.0f.

◆ SetHSLSaturationInteger()

void CYIColor::SetHSLSaturationInteger ( int32_t  saturation)

Sets the saturation of this color to saturation. Value should be between 0 and 255.

◆ SetRed() [1/4]

void CYIColor::SetRed ( double  red)

Sets the red color channel. Value should be between 0.0f and 1.0f

Warning
Because color components are represented internally as floats, calling this setter may result in loss of precision.
Deprecated:
This function has been deprecated and may be removed in a future release. SetRed(float) should be used instead.

◆ SetRed() [2/4]

void CYIColor::SetRed ( float  red)

Sets the red color channel. Value should be between 0.0f and 1.0f

◆ SetRed() [3/4]

template<typename T = bool>
void CYIColor::SetRed ( int32_t  r)
Deprecated:
This setter has been removed. SetRedInteger should be used instead.

◆ SetRed() [4/4]

template<typename T = bool>
void CYIColor::SetRed ( uint8_t  r)
Deprecated:
This setter has been removed. SetRedInteger should be used instead.

◆ SetRedInteger()

void CYIColor::SetRedInteger ( int32_t  red)

Sets the red color channel. Value should be between 0 and 255.

◆ ToHexString()

CYIString CYIColor::ToHexString ( ByteOrder  byteOrder = ByteOrder::RGBA) const

Returns a string representation of this color, formatted as "#RRGGBBAA". The byteOrder parameter can be used to request a different byte order.

Note
Unlike the GetPackedColor and the packed color constructor, this function by default returns a string formatted as CYIColor::ByteOrder::RGBA.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const CYIColor lhs,
const CYIColor rhs 
)
friend

◆ operator<

bool operator< ( const CYIColor lhs,
const CYIColor rhs 
)
friend

◆ operator<=

bool operator<= ( const CYIColor lhs,
const CYIColor rhs 
)
friend

◆ operator==

bool operator== ( const CYIColor lhs,
const CYIColor rhs 
)
friend

◆ operator>

bool operator> ( const CYIColor lhs,
const CYIColor rhs 
)
friend

◆ operator>=

bool operator>= ( const CYIColor lhs,
const CYIColor rhs 
)
friend

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