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 &a)
 
 Color (DWORD rgb)
 
 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 Point3 ()
 
 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...
 

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 a)
inline
Remarks
Constructor. Initializes the Color to the Color passed.
Parameters:
Color& a

Specifies the initial color.
118 { r = a.r; g = a.g; b = a.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 ( 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 ( 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:55
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
float z
Definition: point3.h:55
float x
Definition: point3.h:55
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].
134 { 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.
140 { 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.
145  {
146  r = float(c.r)/255.0f; g = float(c.g)/255.0f; b = float(c.b)/255.0f;
147  }
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.
152  {
153  r = float(c.r)/255.0f; g = float(c.g)/255.0f; b = float(c.b)/255.0f;
154  }
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.
159  {
160  r = float(c.r)/65535.0f; g = float(c.g)/65535.0f; b = float(c.b)/65535.0f;
161  }
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.
166  {
167  r = float(c.r)/65535.0f; g = float(c.g)/65535.0f; b = float(c.b)/65535.0f;
168  }
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.
174  {
175  r = c.r; g = c.g; b = c.b;
176  }
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
180 { 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
182 { 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.
197 { 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.
203 { 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.
208 { return(&r); }
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
operator const float * ( ) const
inline
209 { return(&r); }
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:74
DWORD toRGB ( )
inline
213 { 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 Point3 ( )
inline
Remarks
Convert the Color to a Point3. x=r, y=g, z=b.
217 { return Point3(r,g,b); }
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:76
Definition: point3.h:51
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.
225  {
226  BMM_Color_24 c;
227  c.r = (BYTE) int(r*255.0f); c.g = (BYTE)int(g*255.0f); c.b = (BYTE) int(b*255.0f);
228  return c;
229  }
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.
231  {
232  BMM_Color_32 c;
233  c.r = (BYTE)int(r*255.0f); c.g = (BYTE)int(g*255.0f); c.b = (BYTE)int(b*255.0f);
234  return c;
235  }
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.
237  {
238  BMM_Color_48 c;
239  c.r = (WORD)int(r*65535.0f); c.g = (WORD)int(g*65535.0f); c.b = (WORD)int(b*65535.0f);
240  return c;
241  }
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.
243  {
244  BMM_Color_64 c;
245  c.r = (WORD)int(r*65535.0f); c.g = (WORD)int(g*65535.0f); c.b = (WORD)int(b*65535.0f);
246  return c;
247  }
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.
249  {
250  BMM_Color_fl c;
251  c.r = r; c.g = g; c.b = b;
252  return c;
253  }
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)); }
259 { 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.
262 { 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.
367  {
368  r -= a.r; g -= a.g; b -= a.b;
369  return *this;
370  }
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.
372  {
373  r += a.r; g += a.g; b += a.b;
374  return *this;
375  }
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.
377  {
378  r *= f; g *= f; b *= f;
379  return *this;
380  }
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.
382  {
383  r /= f; g /= f; b /= f;
384  return *this;
385  }
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.
387  {
388  r *= a.r; g *= a.g; b *= a.b;
389  return *this;
390  }
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.
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
int operator!= ( const Color p) const
inline
Remarks
Tests for inequality between two Colors.
Returns
Nonzero if the Colors are not equal; otherwise 0.
287 { 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.
392  {
393  return(Color(r-c.r,g-c.g,b-c.b));
394  }
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.
396  {
397  return(Color(r+c.r,g+c.g,b+c.b));
398  }
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.
400  {
401  return Color(r/c.r,g/c.g,b/c.b);
402  }
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.
404  {
405  return Color(r*c.r, g*c.g, b*c.b);
406  }
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
408  {
409  return Color(g * c.b - b * c.g, b * c.r - r * c.b, r * c.g - g * c.r);
410  }
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.