AColor Class Reference
 
 
 
AColor Class Reference

#include <acolor.h>

Inheritance diagram for AColor:
MaxHeapOperators

Class Description

See also:
Class Color, 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 four floating point values: r, g, b, and an alpha channel a. Also note the following typedef: typedef AColor RGBA;

Public Member Functions

  AColor ()
  AColor (float R, float G, float B, float A=1.0f)
  AColor (double R, double G, double B, double A=1.0)
  AColor (int R, int G, int B, int A=0)
  AColor (const AColor &c)
  AColor (const Color &c, float alph=1.0f)
  AColor (DWORD rgb, float alph=1.0f)
  AColor (Point4 p)
  AColor (float af[4])
  AColor (const BMM_Color_24 &c)
  AColor (const BMM_Color_32 &c)
  AColor (const BMM_Color_48 &c)
  AColor (const BMM_Color_64 &c)
  AColor (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 Color ()
  operator BMM_Color_24 ()
  operator BMM_Color_32 ()
  operator BMM_Color_48 ()
  operator BMM_Color_64 ()
  operator BMM_Color_fl ()
DWORD  toRGB ()
  operator Point3 ()
  operator Point4 ()
AColor  operator- () const
AColor  operator+ () const
AColor operator-= (const AColor &)
AColor operator+= (const AColor &)
AColor operator*= (float)
AColor operator/= (float)
AColor operator*= (const AColor &)
int  operator== (const AColor &p) const
int  operator!= (const AColor &p) const
AColor  operator- (const AColor &) const
AColor  operator+ (const AColor &) const
AColor  operator/ (const AColor &) const
AColor  operator* (const AColor &) const
AColor  operator^ (const AColor &) const

Public Attributes

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

Constructor & Destructor Documentation

AColor ( ) [inline]
Remarks:
Constructor. The resulting object should be initialized with one of the initialization methods.
{}
AColor ( float  R,
float  G,
float  B,
float  A = 1.0f 
) [inline]
Remarks:
Constructor. Initializes the AColor to the RGBA color values passed.
{ r = R; g = G; b = B; a = A; }
AColor ( double  R,
double  G,
double  B,
double  A = 1.0 
) [inline]
Remarks:
Constructor. Initializes the AColor to the RGBA color values passed (cast to float).
                                                           {
                 r = (float)R; g = (float)G; b = (float)B; a = (float)A; }
AColor ( int  R,
int  G,
int  B,
int  A = 0 
) [inline]
Remarks:
Constructor. Initializes the AColor to the RGBA color values passed (cast to float).
                                             { 
                r = (float)R; g = (float)G; b = (float)B; a = (float)A; }
AColor ( const AColor c ) [inline]
Remarks:
Constructor. Initializes the AColor to the AColor passed.
{ r = c.r; g = c.g; b = c.b; a = c.a; } 
AColor ( const Color c,
float  alph = 1.0f 
) [inline]
Remarks:
Constructor. Initializes the AColor to the Color passed, optionally specifying an alpha value.
{ r = c.r; g = c.g; b = c.b; a = alph; } 
AColor ( DWORD  rgb,
float  alph = 1.0f 
) [explicit]
Remarks:
Constructor. Initializes the color to the Windows RGB value, optionally specifying an alpha value.
AColor ( Point4  p ) [inline]
{ r = p.x; g = p.y; b = p.z; a = p.w; }
AColor ( float  af[4] ) [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], a=af[3].
{ r = af[0]; g = af[1]; b = af[2];a = af[3]; }
AColor ( const BMM_Color_24 c ) [inline]
Remarks:
Constructor. Initializes this AColor 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; a = 1.0f; 
                }
AColor ( const BMM_Color_32 c ) [inline]
Remarks:
Constructor. Initializes this AColor 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; a = float(c.a)/255.0f; 
                }
AColor ( const BMM_Color_48 c ) [inline]
Remarks:
Constructor. Initializes this AColor 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; a = 1.0f; 
                }
AColor ( const BMM_Color_64 c ) [inline]
Remarks:
Constructor. Initializes this AColor 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; a = float(c.a)/65535.0f; 
                }
AColor ( const BMM_Color_fl c ) [inline]
Remarks:
Constructor. Initializes this AColor 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; a = c.a; 
                }

Member Function Documentation

void Black ( ) [inline]
Remarks:
Sets this AColor to black. r = g = b = 0.0f; a= 1.0f
{ r = g = b = 0.0f; a = 1.0f; }
void White ( ) [inline]
Remarks:
Sets the AColor to white. r = g = b = a = 1.0f
{ r = g = b = 1.0f; a = 1.0f; }
void ClampMax ( )
Remarks:
Makes all the components of the AColor <= 1.0
void ClampMin ( )
Remarks:
Makes all the components of the AColor >= 0.0
void ClampMinMax ( )
Remarks:
Makes all the components of the AColor fall in the range 0.0 to 1.0.
float& operator[] ( int  i ) [inline]
Remarks:
Access operators.
Parameters:
int i

The index of the component to return.
Returns:
0=r, 1=g, 2=b, 3=a.
{ return (&r)[i]; }     
const float& operator[] ( int  i ) const [inline]
Remarks:
Access operators.
Parameters:
int i

The index of the component to return.
Returns:
0=r, 1=g, 2=b, 3=a.
{ return (&r)[i]; }  
operator float * ( ) [inline]
Remarks:
Conversion function.

Returns a pointer to the AColor.
{ return(&r); }
operator Color ( ) [inline]
{ return Color(r,g,b); }
operator BMM_Color_24 ( ) [inline]
Remarks:
Converts this AColor 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 AColor 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); c.a = (BYTE)int(a*255.0f);
                return c;
                }
operator BMM_Color_48 ( ) [inline]
Remarks:
Converts this AColor 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 AColor 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); c.a = (WORD)int(a*65535.0f);
                return c;
                }
operator BMM_Color_fl ( ) [inline]
Remarks:
Converts this AColor to the BMM_Color_fl format.
                                { 
                BMM_Color_fl c; 
                c.r = r;        c.g = g;        c.b = b;        c.a = a;
                return c;
                }
DWORD toRGB ( ) [inline]
Remarks:
Convert the AColor to a Windows RGB color. See COLORREF.
Returns:
A Windows RGB color.
{ return RGB(FLto255(r),FLto255(g), FLto255(b)); };
operator Point3 ( ) [inline]
Remarks:
Convert the AColor to a Point3.
Returns:
A Point3. x=r, y=g, z=b.
{ return Point3(r,g,b); }
operator Point4 ( ) [inline]
{ return Point4(r,g,b,a); }
AColor operator- ( ) const [inline]
Remarks:
Unary - operator.
Returns:
The Color with the components negated, i.e.

{ return(AColor(-r,-g,-b, -a)); }
{ return (AColor(-r,-g,-b, -a)); } 
AColor operator+ ( ) const [inline]
Remarks:
Unary + operator.
Returns:
The AColor itself.
{ return *this; } 
AColor & operator-= ( const AColor c ) [inline]
Remarks:
Subtracts an AColor from this AColor.
Returns:
A Color that is the difference between two Colors.
                                                 {      
        r -= c.r;       g -= c.g;       b -= c.b;  a -= c.a;
        return *this;
        }
AColor & operator+= ( const AColor c ) [inline]
Remarks:
Adds an AColor to this AColor.
Returns:
An AColor that is the sum of two AColors.
                                                 {
        r += c.r;       g += c.g;       b += c.b; a += c.a;
        return *this;
        }
AColor & operator*= ( float  f ) [inline]
Remarks:
Multiplies the components of this AColor by a float.
Returns:
An AColor multiplied by a float.
                                         {
        r *= f;   g *= f;       b *= f;  a *= f;
        return *this;
        }
AColor & operator/= ( float  f ) [inline]
Remarks:
Divides the components of this AColor by a float.
Returns:
An AColor divided by a float.
                                         { 
        r /= f; g /= f; b /= f; a /= f;
        return *this; 
        }
AColor & operator*= ( const AColor c ) [inline]
Remarks:
Performs element-by-element multiplying between two AColors.
Returns:
This AColor element-by-element multiplied by another AColor.
                                                 { 
        r *= c.r;       g *= c.g;       b *= c.b;       a *= c.a;
        return *this; 
        }
int operator== ( const AColor p ) const [inline]
Remarks:
Test for equality between two AColors.
Returns:
Nonzero if the AColors are equal; otherwise 0.
{ return ((p.r==r)&&(p.g==g)&&(p.b==b)&&(p.a==a)); }
int operator!= ( const AColor p ) const [inline]
Remarks:
Tests for inequality between two AColors.
Returns:
Nonzero if the AColors are not equal; otherwise 0.
{ return ((p.r!=r)||(p.g!=g)||(p.b!=b)||(p.a!=a)); }
AColor operator- ( const AColor c ) const [inline]
Remarks:
Subtracts an AColor from an AColor.
Returns:
An AColor that is the difference between two AColors.
                                                     {
        return(AColor(r-c.r,g-c.g,b-c.b,a-c.a));
        }
AColor operator+ ( const AColor c ) const [inline]
Remarks:
Adds an AColor to an AColor.
Returns:
An AColor that is the difference between two AColors.
                                                     {
        return(AColor(r+c.r,g+c.g,b+c.b,a+c.a));
        }
AColor operator/ ( const AColor c ) const [inline]
Remarks:
Divides an AColor by an AColor.
Returns:
An AColor divided by an AColor. r/r, g/g, b/b, a/a.
                                                     {
        return AColor(r/c.r,g/c.g,b/c.b,a/c.a);
        }
AColor operator* ( const AColor c ) const [inline]
Remarks:
Multiplies an AColor by an AColor.
Returns:
An AColor multiplied by an AColor. r*r, g*g, b*b, a*a.
                                                     {  
        return AColor(r*c.r, g*c.g, b*c.b, a*c.a);      
        }
AColor operator^ ( const AColor c ) const [inline]
Remarks:
Cross product of two AColors. The alpha component is not affected by the cross product.
Returns:
An AColor that is the cross product of two AColors.
                                                     {
        return AColor(g * c.b - b * c.g, b * c.r - r * c.b, r * c.g - g * c.r, c.a);
        }

Member Data Documentation

float r

These values are in the range 0.0 to 1.0.