RGBA color. More...

#include <Urho3D/Math/Color.h>

Collaboration diagram for Urho3D::Color:
[legend]

Public Member Functions

 Color ()
 Construct with default values (opaque white.)
 
 Color (const Color &color)
 Copy-construct from another color.
 
 Color (const Color &color, float a)
 Construct from another color and modify the alpha.
 
 Color (float r, float g, float b)
 Construct from RGB values and set alpha fully opaque.
 
 Color (float r, float g, float b, float a)
 Construct from RGBA values.
 
 Color (const float *data)
 Construct from a float array.
 
Coloroperator= (const Color &rhs)
 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
 Substract a color.
 
Coloroperator+= (const Color &rhs)
 Add-assign a color.
 
const float * Data () const
 Return float data.
 
unsigned ToUInt () const
 Return color packed to a 32-bit integer, with R component in the lowest 8 bits. 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 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().
 
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.
 

Public Attributes

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

Static Public Attributes

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
 Transparent 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:
  • Source/Urho3D/Math/Color.h
  • Source/Urho3D/Math/Color.cpp