Public Member Functions | Public Attributes

Color Class Reference

This reference page is linked to from the following overview topics: Hot Check Utilities.


Search for all occurrences

Detailed 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.

#include <color.h>

Inheritance diagram for Color:
Inheritance graph
[legend]

List of all members.

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)
GEOMEXPORT  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 ()
GEOMEXPORT void  ClampMax ()
GEOMEXPORT void  ClampMin ()
GEOMEXPORT void  ClampMinMax ()
float &  operator[] (int i)
const float &  operator[] (int i) const
  operator float * ()
  operator const float * () const
DWORD  toRGB ()
  operator Point3 ()
GEOMEXPORT  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
Color operator-= (const Color &)
Color operator+= (const Color &)
Color operator*= (float)
Color operator/= (float)
Color operator*= (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.
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.

Constructor & Destructor Documentation

Color ( ) [inline]
Remarks:
Constructor. The resulting object should be initialized with one of the initialization methods.
{}
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.
{ r = R; g = G; b = B;  }
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.
{ r = (float)R; g = (float)G; b = (float)B; }
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.
{ r = (float)R; g = (float)G; b = (float)B; }
Color ( const Color a ) [inline]
Remarks:
Constructor. Initializes the Color to the Color passed.
Parameters:
Color& a

Specifies the initial color.
{ r = a.r; g = a.g; b = a.b; } 
GEOMEXPORT 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.
{ r = p.x; g = p.y; b = p.z; }
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].
{ r = af[0]; g = af[1]; b = af[2]; }
Color ( RealPixel  rp ) [inline]
Remarks:
Constructor. Initializes the color to the RealPixel structure passed.
Parameters:
RealPixel rp

Specifies the RealPixel format to convert.
{ ExpandRealPixel(rp,r,g,b); } 
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.
                                 { 
        r = float(c.r)/255.0f; g = float(c.g)/255.0f; b = float(c.b)/255.0f;  
        }
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.
                                 { 
        r = float(c.r)/255.0f; g = float(c.g)/255.0f; b = float(c.b)/255.0f;  
        }
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.
                                 { 
        r = float(c.r)/65535.0f; g = float(c.g)/65535.0f; b = float(c.b)/65535.0f;  
        }
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.
                                 { 
        r = float(c.r)/65535.0f; g = float(c.g)/65535.0f; b = float(c.b)/65535.0f;  
        }
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.
                                 { 
        r = c.r; g = c.g; b = c.b;  
        }

Member Function Documentation

void Black ( ) [inline]
Remarks:
Sets the Color to black. r = g = b = 0.0f
{ r = g = b = 0.0f; }
void White ( ) [inline]
Remarks:
Sets the Color to white. r = g = b = 1.0f
{ r = g = b = 1.0f; }
GEOMEXPORT void ClampMax ( )
Remarks:
Makes all the components of the Color <= 1.0
GEOMEXPORT void ClampMin ( )
Remarks:
Makes all the components of the Color >= 0.0
GEOMEXPORT 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.
{ return (&r)[i]; }     
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.
{ return (&r)[i]; }  
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.
{ return(&r); }
operator const float * ( ) const [inline]
{ return(&r); }
DWORD toRGB ( ) [inline]
{ return RGB(FLto255(r),FLto255(g), FLto255(b)); };
operator Point3 ( ) [inline]
Remarks:
Convert the Color to a Point3. x=r, y=g, z=b.
{ return Point3(r,g,b); }
GEOMEXPORT 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.
                            { 
        BMM_Color_24 c; 
        c.r = (BYTE) int(r*255.0f); c.g = (BYTE)int(g*255.0f); c.b = (BYTE) int(b*255.0f);
        return c;
        }
operator BMM_Color_32 ( ) [inline]
Remarks:
Converts this Color to the BMM_Color_32 format.
                            { 
        BMM_Color_32 c; 
        c.r = (BYTE)int(r*255.0f); c.g = (BYTE)int(g*255.0f); c.b = (BYTE)int(b*255.0f);
        return c;
        }
operator BMM_Color_48 ( ) [inline]
Remarks:
Converts this Color to the BMM_Color_48 format.
                            { 
        BMM_Color_48 c; 
        c.r = (WORD)int(r*65535.0f); c.g = (WORD)int(g*65535.0f); c.b = (WORD)int(b*65535.0f);
        return c;
        }
operator BMM_Color_64 ( ) [inline]
Remarks:
Converts this Color to the BMM_Color_64 format.
                            { 
        BMM_Color_64 c; 
        c.r = (WORD)int(r*65535.0f); c.g = (WORD)int(g*65535.0f); c.b = (WORD)int(b*65535.0f);
        return c;
        }
operator BMM_Color_fl ( ) [inline]
Remarks:
Converts this Color to the BMM_Color_fl format.
                            { 
        BMM_Color_fl c; 
        c.r = r; c.g = g; c.b = b;
        return c;
        }
Color operator- ( ) const [inline]
Remarks:
Unary - operator.
Returns:
The Color with the components negated, i.e.

{ return(Color(-r,-g,-b)); }
{ return(Color(-r,-g,-b)); } 
Color operator+ ( ) const [inline]
Remarks:
Unary + operator.
Returns:
The Color itself.
{ 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.
                                              { 
    r -= a.r;   g -= a.g;   b -= a.b;
    return *this;
    }
Color & operator+= ( const Color a ) [inline]
Remarks:
Adds a Color to this Color.
Returns:
A Color that is the sum of two Colors.
                                              {
    r += a.r;   g += a.g;   b += a.b;
    return *this;
    }
Color & operator*= ( float  f ) [inline]
Remarks:
Multiplies the components of this Color by a float.
Returns:
A Color multiplied by a float.
                                       {
    r *= f;   g *= f;   b *= f;
    return *this;
    }
Color & operator/= ( float  f ) [inline]
Remarks:
Divides the components of a Color by a float.
Returns:
A Color divided by a float.
                                       { 
    r /= f; g /= f; b /= f; 
    return *this; 
    }
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.
                                              { 
    r *= a.r;   g *= a.g;   b *= a.b;   
    return *this; 
    }
int operator== ( const Color p ) const [inline]
Remarks:
Test for equality between two Colors.
Returns:
Nonzero if the Colors are equal; otherwise 0.
{ return ((p.r==r)&&(p.g==g)&&(p.b==b)); }
int operator!= ( const Color p ) const [inline]
Remarks:
Tests for inequality between two Colors.
Returns:
Nonzero if the Colors are not equal; otherwise 0.
{ return ((p.r!=r)||(p.g!=g)||(p.b!=b)); }
Color operator- ( const Color c ) const [inline]
Remarks:
Subtracts a Color from a Color.
Returns:
A Color that is the difference between two Colors.
                                                  {
    return(Color(r-c.r,g-c.g,b-c.b));
    }
Color operator+ ( const Color c ) const [inline]
Remarks:
Adds a Color to a Color.
Returns:
A Color that is the difference between two Colors.
                                                  {
    return(Color(r+c.r,g+c.g,b+c.b));
    }
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.
                                                  {
    return Color(r/c.r,g/c.g,b/c.b);
    }
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.
                                                  {  
    return Color(r*c.r, g*c.g, b*c.b);
    }
Color operator^ ( const Color c ) const [inline]
                                                  {
    return Color(g * c.b - b * c.g, b * c.r - r * c.b, r * c.g - g * c.r);
    }

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.


Color Color Color Color Color Color Color Color Color Color
Color Color Color Color Color Color Color Color Color Color