Color Class Reference

#include <color.h>

Class Description

See also
Class AColor, Structure BMM_Color_24, Structure BMM_Color_32, Structure BMM_Color_48, Structure BMM_Color_64, Structure BMM_Color_fl, Structure RealPixel.

Description:
This class represents color as three floating point values: r, g, and b. All methods of this class are implemented by the system.
Data Members:
float r,g,b;

These values are in the range 0.0 to 1.0.
+ Inheritance diagram for Color:

Public Member Functions

 Color ()
 
 Color (float R, float G, float B)
 
 Color (double R, double G, double B)
 
 Color (int R, int G, int B)
 
 Color (const Color &)=default
 
 Color (DWORD rgb)
 
 Color (const Point3 &p)
 
 Color (Point3 &&p)
 
 Color (float af[3])
 
 Color (RealPixel rp)
 
 Color (const BMM_Color_24 &c)
 
 Color (const BMM_Color_32 &c)
 
 Color (const BMM_Color_48 &c)
 
 Color (const BMM_Color_64 &c)
 
 Color (const BMM_Color_fl &c)
 
void Black ()
 
void White ()
 
void ClampMax ()
 
void ClampMin ()
 
void ClampMinMax ()
 
float & operator[] (int i)
 
const float & operator[] (int i) const
 
 operator float * ()
 
 operator const float * () const
 
DWORD toRGB ()
 
 operator RealPixel ()
 
 operator BMM_Color_24 ()
 
 operator BMM_Color_32 ()
 
 operator BMM_Color_48 ()
 
 operator BMM_Color_64 ()
 
 operator BMM_Color_fl ()
 
Color operator- () const
 
Color operator+ () const
 
Coloroperator-= (const Color &)
 
Coloroperator+= (const Color &)
 
Coloroperator*= (float)
 
Coloroperator/= (float)
 
Coloroperator*= (const Color &)
 
int operator== (const Color &p) const
 
int operator!= (const Color &p) const
 
Color operator- (const Color &) const
 
Color operator+ (const Color &) const
 
Color operator/ (const Color &) const
 
Color operator* (const Color &) const
 
Color operator^ (const Color &) const
 

Public Attributes

float r
 These values are in the range 0.0 to 1.0. More...
 
float g
 These values are in the range 0.0 to 1.0. More...
 
float b
 These values are in the range 0.0 to 1.0. More...
 

Kelvin temperature, black body

float FindClosestMatchingKelvinTemperature () const
 Finds the kelvin temperature which, when converted to RGB, would generate the closest possible color to the current RGB value. More...
 
static Color FromKelvinTemperature (const float kelvin_temperature, const float intensity=1.0f)
 Calculates the chromacity of a black body radiator at a given temperature in kelvins. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Constructor & Destructor Documentation

Color ( )
inline
Remarks
Constructor. The resulting object should be initialized with one of the initialization methods.
83 {}
Color ( float  R,
float  G,
float  B 
)
inline
Remarks
Constructor. Initializes the Color to the RGB color values passed.
Parameters:
float R

Specifies the red component of the color.

float G

Specifies the green component of the color.

float B

Specifies the blue component of the color.
93 { r = R; g = G; b = B; }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color ( double  R,
double  G,
double  B 
)
inline
Remarks
Constructor. Initializes the Color to the RGB color values passed.
Parameters:
double R

Specifies the red component of the color.

double G

Specifies the green component of the color.

double B

Specifies the blue component of the color.
103 { r = (float)R; g = (float)G; b = (float)B; }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color ( int  R,
int  G,
int  B 
)
inline
Remarks
Constructor. Initializes the Color to the RGB color values passed.
Parameters:
int R

Specifies the red component of the color.

int G

Specifies the green component of the color.

int B

Specifies the blue component of the color.
113 { r = (float)R; g = (float)G; b = (float)B; }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color ( const Color )
default
Remarks
Constructor. Initializes the Color to the Color passed.
Parameters:
Color& a

Specifies the initial color.
Color ( DWORD  rgb)
explicit
Remarks
Constructor. Initializes the color to the Windows RGB value.
Parameters:
DWORD rgb

Specifies the initial color via a Windows RGB value.
Color ( const Point3 p)
inline
Remarks
Constructor. Initializes the Color to the value of the Point3 passed.
Parameters:
Point3 p

Specifies the color. r=x, g=y, b=z.
129 { r = p.x; g = p.y; b = p.z; }
float y
Definition: point3.h:60
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float z
Definition: point3.h:61
float x
Definition: point3.h:59
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color ( Point3 &&  p)
inline
130 { r = p.x; g = p.y; b = p.z; }
float y
Definition: point3.h:60
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float z
Definition: point3.h:61
float x
Definition: point3.h:59
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color ( float  af[3])
inline
Remarks
Constructor. Initializes the color to the value passed.
Parameters:
float af[3]

Specifies the color. r=af[0], g=af[1], b=af[2].
135 { r = af[0]; g = af[1]; b = af[2]; }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color ( RealPixel  rp)
inline
Remarks
Constructor. Initializes the color to the RealPixel structure passed.
Parameters:
RealPixel rp

Specifies the RealPixel format to convert.
141 { ExpandRealPixel(rp,r,g,b); }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
void ExpandRealPixel(const RealPixel &rp, float &r, float &g, float &b)
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color ( const BMM_Color_24 c)
inline
Remarks
Constructor. Initializes this Color from the 24 bit color value passed.
Parameters:
const BMM_Color_24& c

The 24 bit color to initialize from.
146  {
147  r = float(c.r)/255.0f; g = float(c.g)/255.0f; b = float(c.b)/255.0f;
148  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
BYTE g
Definition: maxtypes.h:61
BYTE b
Definition: maxtypes.h:61
BYTE r
Definition: maxtypes.h:61
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color ( const BMM_Color_32 c)
inline
Remarks
Constructor. Initializes this Color from the 32 bit color value passed.
Parameters:
const BMM_Color_32& c

The 32 bit color to initialize from.
153  {
154  r = float(c.r)/255.0f; g = float(c.g)/255.0f; b = float(c.b)/255.0f;
155  }
BYTE g
Definition: maxtypes.h:68
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
BYTE b
Definition: maxtypes.h:68
BYTE r
Definition: maxtypes.h:68
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color ( const BMM_Color_48 c)
inline
Remarks
Constructor. Initializes this Color from the 48 bit color value passed.
Parameters:
const BMM_Color_48& c

The 48 bit color to initialize from.
160  {
161  r = float(c.r)/65535.0f; g = float(c.g)/65535.0f; b = float(c.b)/65535.0f;
162  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
WORD r
Definition: maxtypes.h:75
WORD g
Definition: maxtypes.h:75
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
WORD b
Definition: maxtypes.h:75
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color ( const BMM_Color_64 c)
inline
Remarks
Constructor. Initializes this Color from the 64 bit color value passed.
Parameters:
const BMM_Color_64& c

The 64 bit color to initialize from.
167  {
168  r = float(c.r)/65535.0f; g = float(c.g)/65535.0f; b = float(c.b)/65535.0f;
169  }
WORD r
Definition: maxtypes.h:82
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
WORD g
Definition: maxtypes.h:82
WORD b
Definition: maxtypes.h:82
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color ( const BMM_Color_fl c)
inline
Remarks
Constructor. Initializes this Color from the floating point color passed.
Parameters:
const BMM_Color_fl& c

The floating point color to initialize from. No conversion or scaling is done.
175  {
176  r = c.r; g = c.g; b = c.b;
177  }
float g
Definition: maxtypes.h:92
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
Definition: maxtypes.h:92
float r
Storage for the floating point color information.
Definition: maxtypes.h:92
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74

Member Function Documentation

void Black ( )
inline
Remarks
Sets the Color to black. r = g = b = 0.0f
181 { r = g = b = 0.0f; }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
void White ( )
inline
Remarks
Sets the Color to white. r = g = b = 1.0f
183 { r = g = b = 1.0f; }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
void ClampMax ( )
Remarks
Makes all the components of the Color <= 1.0
void ClampMin ( )
Remarks
Makes all the components of the Color >= 0.0
void ClampMinMax ( )
Remarks
Makes all the components fall in the range [0,1]
float& operator[] ( int  i)
inline
Remarks
Access operator.
Parameters:
int i

The index of the component to return.
Returns
0=r, 1=g, 2=b.
198 { return (&r)[i]; }
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
const float& operator[] ( int  i) const
inline
Remarks
Access operator.
Parameters:
int i

The index of the component to return.
Returns
0=r, 1=g, 2=b.
204 { return (&r)[i]; }
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
operator float * ( )
inline
Remarks
Returns a pointer to the red component of the color. This may be used to treat the Color as an array of three floats.
209 { return(&r); }
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
operator const float * ( ) const
inline
210 { return(&r); }
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
DWORD toRGB ( )
inline
214 { return RGB(FLto255(r),FLto255(g), FLto255(b)); };
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
#define FLto255(x)
Definition: color.h:24
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
operator RealPixel ( )
Remarks
Convert the Color to the RealPixel format.
operator BMM_Color_24 ( )
inline
Remarks
Converts this Color to the BMM_Color_24 format.
222  {
223  BMM_Color_24 c;
224  c.r = (BYTE) int(r*255.0f); c.g = (BYTE)int(g*255.0f); c.b = (BYTE) int(b*255.0f);
225  return c;
226  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
BYTE g
Definition: maxtypes.h:61
24 bit color: 8 bits each for Red, Green, and Blue.
Definition: maxtypes.h:59
BYTE b
Definition: maxtypes.h:61
BYTE r
Definition: maxtypes.h:61
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
operator BMM_Color_32 ( )
inline
Remarks
Converts this Color to the BMM_Color_32 format.
228  {
229  BMM_Color_32 c;
230  c.r = (BYTE)int(r*255.0f); c.g = (BYTE)int(g*255.0f); c.b = (BYTE)int(b*255.0f);
231  return c;
232  }
BYTE g
Definition: maxtypes.h:68
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
BYTE b
Definition: maxtypes.h:68
BYTE r
Definition: maxtypes.h:68
32 bit color: 8 bits each for Red, Green, Blue, and Alpha.
Definition: maxtypes.h:66
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
operator BMM_Color_48 ( )
inline
Remarks
Converts this Color to the BMM_Color_48 format.
234  {
235  BMM_Color_48 c;
236  c.r = (WORD)int(r*65535.0f); c.g = (WORD)int(g*65535.0f); c.b = (WORD)int(b*65535.0f);
237  return c;
238  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
WORD r
Definition: maxtypes.h:75
WORD g
Definition: maxtypes.h:75
48 bit color: 16 bits each for Red, Green, and Blue.
Definition: maxtypes.h:73
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
WORD b
Definition: maxtypes.h:75
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
operator BMM_Color_64 ( )
inline
Remarks
Converts this Color to the BMM_Color_64 format.
240  {
241  BMM_Color_64 c;
242  c.r = (WORD)int(r*65535.0f); c.g = (WORD)int(g*65535.0f); c.b = (WORD)int(b*65535.0f);
243  return c;
244  }
WORD r
Definition: maxtypes.h:82
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
WORD g
Definition: maxtypes.h:82
WORD b
Definition: maxtypes.h:82
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
64 bit color: 16 bits each for Red, Green, Blue, and Alpha.
Definition: maxtypes.h:80
operator BMM_Color_fl ( )
inline
Remarks
Converts this Color to the BMM_Color_fl format.
246  {
247  BMM_Color_fl c;
248  c.r = r; c.g = g; c.b = b;
249  return c;
250  }
float g
Definition: maxtypes.h:92
High Dynamic Range bitmaps make use of this class to store color information using floating point val...
Definition: maxtypes.h:87
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
Definition: maxtypes.h:92
float r
Storage for the floating point color information.
Definition: maxtypes.h:92
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color operator- ( ) const
inline
Remarks
Unary - operator.
Returns
The Color with the components negated, i.e.

{ return(Color(-r,-g,-b)); }
256 { return(Color(-r,-g,-b)); }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
Color()
Definition: color.h:83
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color operator+ ( ) const
inline
Remarks
Unary + operator.
Returns
The Color itself.
259 { return *this; }
Color & operator-= ( const Color a)
inline
Remarks
Subtracts a Color from this Color.
Returns
A Color that is the difference between two Colors.
364  {
365  r -= a.r; g -= a.g; b -= a.b;
366  return *this;
367  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color & operator+= ( const Color a)
inline
Remarks
Adds a Color to this Color.
Returns
A Color that is the sum of two Colors.
369  {
370  r += a.r; g += a.g; b += a.b;
371  return *this;
372  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color & operator*= ( float  f)
inline
Remarks
Multiplies the components of this Color by a float.
Returns
A Color multiplied by a float.
374  {
375  r *= f; g *= f; b *= f;
376  return *this;
377  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color & operator/= ( float  f)
inline
Remarks
Divides the components of a Color by a float.
Returns
A Color divided by a float.
379  {
380  r /= f; g /= f; b /= f;
381  return *this;
382  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color & operator*= ( const Color a)
inline
Remarks
Performs element-by-element multiplying between two Colors.
Returns
A Color element-by-element multiplied by another Color.
384  {
385  r *= a.r; g *= a.g; b *= a.b;
386  return *this;
387  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
int operator== ( const Color p) const
inline
Remarks
Test for equality between two Colors.
Returns
Nonzero if the Colors are equal; otherwise 0.
281 { return ((p.r==r)&&(p.g==g)&&(p.b==b)); }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
int operator!= ( const Color p) const
inline
Remarks
Tests for inequality between two Colors.
Returns
Nonzero if the Colors are not equal; otherwise 0.
284 { return ((p.r!=r)||(p.g!=g)||(p.b!=b)); }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color operator- ( const Color c) const
inline
Remarks
Subtracts a Color from a Color.
Returns
A Color that is the difference between two Colors.
389  {
390  return(Color(r-c.r,g-c.g,b-c.b));
391  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
Color()
Definition: color.h:83
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color operator+ ( const Color c) const
inline
Remarks
Adds a Color to a Color.
Returns
A Color that is the difference between two Colors.
393  {
394  return(Color(r+c.r,g+c.g,b+c.b));
395  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
Color()
Definition: color.h:83
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color operator/ ( const Color c) const
inline
Remarks
Divides a Color by a Color.
Returns
A Color divided by a Color. r/r, g/g, b/b.
397  {
398  return Color(r/c.r,g/c.g,b/c.b);
399  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
Color()
Definition: color.h:83
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color operator* ( const Color c) const
inline
Remarks
Multiplies a Color by a Color.
Returns
A Color multiplied by a Color. r*r, g*g, b*b.
401  {
402  return Color(r*c.r, g*c.g, b*c.b);
403  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
Color()
Definition: color.h:83
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
Color operator^ ( const Color c) const
inline
405  {
406  return Color(g * c.b - b * c.g, b * c.r - r * c.b, r * c.g - g * c.r);
407  }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
Color()
Definition: color.h:83
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
static Color FromKelvinTemperature ( const float  kelvin_temperature,
const float  intensity = 1.0f 
)
static

Calculates the chromacity of a black body radiator at a given temperature in kelvins.

Parameters
kelvin_temperatureThe black body temperature in kelvins.
intensityThe intensity of the color to be generated (the luminance Y of the CIE XYZ color from which the RGB color is converted).
Returns
An RGB value, converted from a CIE XYZ color with the calculated chromacity and provided intensity.
Remarks
The returned color components is guaranteed to have positive values, but may exceed 1.0.
float FindClosestMatchingKelvinTemperature ( ) const

Finds the kelvin temperature which, when converted to RGB, would generate the closest possible color to the current RGB value.

For a color that was generated from a kelvin temperature, the returned value should match that temperature exactly. But for an arbitrary color, the returned value will only be an approximation (and may vary wildly if the color is very far from the set of valid black body colors).

Returns
The temperature, in kelvins, which would generate the closest matching color to 'this'.
Remarks
This performs a search through the range of valid color temperatures, and may therefore be a bit expensive.

Member Data Documentation

float r

These values are in the range 0.0 to 1.0.

float g

These values are in the range 0.0 to 1.0.

float b

These values are in the range 0.0 to 1.0.