Urho3D
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
Urho3D::Color Class Reference

RGBA color. More...

#include </home/runner/work/urho3d-doxygen.github.io/urho3d-doxygen.github.io/urho3d_repo/Source/Urho3D/Math/Color.h>

Classes

struct  ChannelMask
 Mask describing color channels. More...
 

Public Member Functions

 Color () noexcept
 Construct with default values (opaque white).
 
 Color (const Color &color) noexcept=default
 Copy-construct from another color.
 
 Color (const Color &color, float a) noexcept
 Construct from another color and modify the alpha.
 
 Color (float r, float g, float b) noexcept
 Construct from RGB values and set alpha fully opaque.
 
 Color (float r, float g, float b, float a) noexcept
 Construct from RGBA values.
 
 Color (const float *data) noexcept
 Construct from a float array.
 
 Color (unsigned color, const ChannelMask &mask=ABGR)
 Construct from 32-bit integer. Default format is 0xAABBGGRR.
 
 Color (const Vector3 &color)
 Construct from 3-vector.
 
 Color (const Vector4 &color)
 Construct from 4-vector.
 
Coloroperator= (const Color &rhs) noexcept=default
 Assign from another color.
 
bool operator== (const Color &rhs) const
 Test for equality with another color without epsilon.
 
bool operator!= (const Color &rhs) const
 Test for inequality with another color without epsilon.
 
Color operator* (float rhs) const
 Multiply with a scalar.
 
Color operator+ (const Color &rhs) const
 Add a color.
 
Color operator- () const
 Return negation.
 
Color operator- (const Color &rhs) const
 Subtract a color.
 
Coloroperator+= (const Color &rhs)
 Add-assign a color.
 
const float * Data () const
 Return float data.
 
color32 ToU32 () const
 Return color packed to a 32-bit integer, with R component in the lowest 8 bits. Components are clamped to [0, 1] range.
 
color32 ToU32 (const ChannelMask &mask) const
 Return color packed to a 32-bit integer with arbitrary channel mask. Components are clamped to [0, 1] range.
 
Vector3 ToHSL () const
 Return HSL color-space representation as a Vector3; the RGB values are clipped before conversion but not changed in the process.
 
Vector3 ToHSV () const
 Return HSV color-space representation as a Vector3; the RGB values are clipped before conversion but not changed in the process.
 
void FromU32 (color32 color)
 Set RGBA values from packed 32-bit integer, with R component in the lowest 8 bits (format 0xAABBGGRR).
 
void FromU32 (color32 color, const ChannelMask &mask)
 Set RGBA values from packed 32-bit integer with arbitrary channel mask.
 
void FromHSL (float h, float s, float l, float a=1.0f)
 Set RGBA values from specified HSL values and alpha.
 
void FromHSV (float h, float s, float v, float a=1.0f)
 Set RGBA values from specified HSV values and alpha.
 
Vector3 ToVector3 () const
 Return RGB as a three-dimensional vector.
 
Vector4 ToVector4 () const
 Return RGBA as a four-dimensional vector.
 
float SumRGB () const
 Return sum of RGB components.
 
float Average () const
 Return average value of the RGB channels.
 
float Luma () const
 Return the 'grayscale' representation of RGB values, as used by JPEG and PAL/NTSC among others.
 
float Chroma () const
 Return the colorfulness relative to the brightness of a similarly illuminated white.
 
float Hue () const
 Return hue mapped to range [0, 1.0).
 
float SaturationHSL () const
 Return saturation as defined for HSL.
 
float SaturationHSV () const
 Return saturation as defined for HSV.
 
float Value () const
 Return value as defined for HSV: largest value of the RGB components. Equivalent to calling MinRGB().
 
Color GammaToLinear () const
 Convert color from gamma to linear space.
 
Color LinearToGamma () const
 Convert color from linear to gamma space.
 
float Lightness () const
 Return lightness as defined for HSL: average of the largest and smallest values of the RGB components.
 
void Bounds (float *min, float *max, bool clipped=false) const
 Stores the values of least and greatest RGB component at specified pointer addresses, optionally clipping those values to [0, 1] range.
 
float MaxRGB () const
 Return the largest value of the RGB components.
 
float MinRGB () const
 Return the smallest value of the RGB components.
 
float Range () const
 Return range, defined as the difference between the greatest and least RGB component.
 
void Clip (bool clipAlpha=false)
 Clip to [0, 1.0] range.
 
void Invert (bool invertAlpha=false)
 Inverts the RGB channels and optionally the alpha channel as well.
 
Color Lerp (const Color &rhs, float t) const
 Return linear interpolation of this color with another color.
 
Color Abs () const
 Return color with absolute components.
 
bool Equals (const Color &rhs) const
 Test for equality with another color with epsilon.
 
String ToString () const
 Return as string.
 
color32 ToU32Argb () const
 Return color packed to a 32-bit integer, with B component in the lowest 8 bits. Components are clamped to [0, 1] range.
 
hash32 ToHash () const
 Return hash value for HashSet & HashMap.
 

Static Public Member Functions

static float ConvertGammaToLinear (float value)
 Convert single component of the color from gamma to linear space.
 
static float ConvertLinearToGamma (float value)
 Convert single component of the color from linear to gamma space.
 

Public Attributes

float r_
 Red value.
 
float g_
 Green value.
 
float b_
 Blue value.
 
float a_
 Alpha value.
 

Static Public Attributes

static const ChannelMask ABGR { 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }
 Mask for 0xAABBGGRR layout.
 
static const ChannelMask ARGB { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }
 Mask for 0xAARRGGBB layout.
 
static const Color WHITE
 Opaque white color.
 
static const Color GRAY
 Opaque gray color.
 
static const Color BLACK
 Opaque black color.
 
static const Color RED
 Opaque red color.
 
static const Color GREEN
 Opaque green color.
 
static const Color BLUE
 Opaque blue color.
 
static const Color CYAN
 Opaque cyan color.
 
static const Color MAGENTA
 Opaque magenta color.
 
static const Color YELLOW
 Opaque yellow color.
 
static const Color TRANSPARENT_BLACK
 Transparent black color (black with no alpha).
 

Protected Member Functions

float Hue (float min, float max) const
 Return hue value given greatest and least RGB component, value-wise.
 
float SaturationHSV (float min, float max) const
 Return saturation (HSV) given greatest and least RGB component, value-wise.
 
float SaturationHSL (float min, float max) const
 Return saturation (HSL) given greatest and least RGB component, value-wise.
 
void FromHCM (float h, float c, float m)
 Calculate and set RGB values. Convenience function used by FromHSV and FromHSL to avoid code duplication.
 

Detailed Description

RGBA color.


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