Class AColor
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.
class Acolor
Description:
This class represents color as four floating point values: r, g, b, and an alpha channel a. All methods of this class are implemented by the system.
Also note the following typedef:
typedef AColor RGBA;
Data Members:
public:
float r,g,b,a;
These values are in the range 0.0 to 1.0.
Methods:
Prototype:
AColor()
Remarks:
Constructor. The resulting object should be initialized with one of the initialization methods.
Prototype:
AColor(float R, float G, float B, float A=1.0f)
Remarks:
Constructor. Initializes the AColor to the RGBA color values passed.
Prototype:
AColor(double R, double G, double B, double A=1.0)
Remarks:
Constructor. Initializes the AColor to the RGBA color values passed (cast to float).
Prototype:
AColor(int R, int G, int B, int A=0)
Remarks:
Constructor. Initializes the AColor to the RGBA color values passed (cast to float).
Prototype:
AColor(const AColor& c)
Remarks:
Constructor. Initializes the AColor to the AColor passed.
Prototype:
AColor(const Color& c, float alph=1.0f)
Remarks:
Constructor. Initializes the AColor to the Color passed, optionally specifying an alpha value.
Prototype:
AColor(DWORD rgb, float alph=1.0f);
Remarks:
Constructor. Initializes the color to the Windows RGB value, optionally specifying an alpha value.
Prototype:
AColor(float af[4])
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].
Prototype:
AColor(const BMM_Color_24& c);
Remarks:
This method is available in release 4.0 and later only.
Constructor. Initializes this AColor from the 24 bit color value passed.
Parameters:
const BMM_Color_24& c
The 24 bit color to initialize from.
Prototype:
AColor(const BMM_Color_32& c);
Remarks:
This method is available in release 4.0 and later only.
Constructor. Initializes this AColor from the 32 bit color value passed.
Parameters:
const BMM_Color_32& c
The 32 bit color to initialize from.
Prototype:
AColor(const BMM_Color_48& c);
Remarks:
This method is available in release 4.0 and later only.
Constructor. Initializes this AColor from the 48 bit color value passed.
Parameters:
const BMM_Color_48& c
The 48 bit color to initialize from.
Prototype:
AColor(const BMM_Color_64& c);
Remarks:
This method is available in release 4.0 and later only.
Constructor. Initializes this AColor from the 64 bit color value passed.
Parameters:
const BMM_Color_64& c
The 64 bit color to initialize from.
Prototype:
AColor(const BMM_Color_fl& c);
Remarks:
This method is available in release 4.0 and later only.
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.
Prototype:
void Black()
Remarks:
Sets this AColor to black. r = g = b = 0.0f; a= 1.0f
Prototype:
void White()
Remarks:
Sets the AColor to white. r = g = b = a = 1.0f
Prototype:
void ClampMin();
Remarks:
Makes all the components of the AColor >= 0.0
Prototype:
void ClampMax();
Remarks:
Makes all the components of the AColor <= 1.0
Prototype:
void ClampMinMax();
Remarks:
Makes all the components of the AColor fall in the range 0.0 to 1.0.
Prototype:
float& operator[](int i)
const float& operator[](int i) const
Remarks:
Access operators.
Parameters:
int i
The index of the component to return.
Return Value:
0=r, 1=g, 2=b, 3=a.
Prototype:
operator float*();
Remarks:
Conversion function.
Returns a pointer to the AColor.
Prototype:
operator DWORD()
Remarks:
Convert the AColor to a Windows RGB color. See COLORREF.
Return Value:
A Windows RGB color.
Prototype:
operator Point3();
Remarks:
Convert the AColor to a Point3.
Return Value:
A Point3. x=r, y=g, z=b.
Prototype:
operator BMM_Color_24();
Remarks:
This method is available in release 4.0 and later only.
Converts this AColor to the BMM_Color_24 format.
Prototype:
operator BMM_Color_32();
Remarks:
This method is available in release 4.0 and later only.
Converts this AColor to the BMM_Color_32 format.
Prototype:
operator BMM_Color_48();
Remarks:
This method is available in release 4.0 and later only.
Converts this AColor to the BMM_Color_48 format.
Prototype:
operator BMM_Color_64();
Remarks:
This method is available in release 4.0 and later only.
Converts this AColor to the BMM_Color_64 format.
Prototype:
operator BMM_Color_fl();
Remarks:
This method is available in release 4.0 and later only.
Converts this AColor to the BMM_Color_fl format.
Prototype:
AColor operator-() const
Remarks:
Unary - operator.
Return Value:
The Color with the components negated, i.e.
{ return(AColor(-r,-g,-b, -a)); }
Prototype:
AColor operator+() const
Remarks:
Unary + operator.
Return Value:
The AColor itself.
Prototype:
inline AColor& operator-=(const AColor&);
Remarks:
Subtracts an AColor from this AColor.
Return Value:
A Color that is the difference between two Colors.
Prototype:
inline AColor& operator+=(const AColor&);
Remarks:
Adds an AColor to this AColor.
Return Value:
An AColor that is the sum of two AColors.
Prototype:
inline AColor& operator*=(float);
Remarks:
Multiplies the components of this AColor by a float.
Return Value:
An AColor multiplied by a float.
Prototype:
inline AColor& operator/=(float);
Remarks:
Divides the components of this AColor by a float.
Return Value:
An AColor divided by a float.
Prototype:
inline AColor& operator*=(const AColor&);
Remarks:
Performs element-by-element multiplying between two AColors.
Return Value:
This AColor element-by-element multiplied by another AColor.
Prototype:
int operator==(const AColor& p) const
Remarks:
Test for equality between two AColors.
Return Value:
Nonzero if the AColors are equal; otherwise 0.
Prototype:
int operator!=(const AColor& p) const
Remarks:
Tests for inequality between two AColors.
Return Value:
Nonzero if the AColors are not equal; otherwise 0.
Prototype:
inline AColor operator-(const AColor&) const;
Remarks:
Subtracts an AColor from an AColor.
Return Value:
An AColor that is the difference between two AColors.
Prototype:
inline AColor operator+(const AColor&) const;
Remarks:
Adds an AColor to an AColor.
Return Value:
An AColor that is the difference between two AColors.
Prototype:
inline AColor operator/(const AColor&) const;
Remarks:
Divides an AColor by an AColor.
Return Value:
An AColor divided by an AColor. r/r, g/g, b/b, a/a.
Prototype:
inline AColor operator*(const AColor&) const;
Remarks:
Multiplies an AColor by an AColor.
Return Value:
An AColor multiplied by an AColor. r*r, g*g, b*b, a*a.
Prototype:
inline AColor operator^(const AColor&) const;
Remarks:
Cross product of two AColors.
Return Value:
An AColor that is the cross product of two AColors.
Prototype:
int MaxComponent(const Color&)
Remarks:
Returns the index of the component with the maximum absolute value.
Parameters:
const Color&
The color to check.
Return Value:
The index of the component with the maximum absolute value. r=0, g=1, b=2, a=3.
Prototype:
int MinComponent(const Color&)
Remarks:
Returns the index of the component with the minimum absolute value.
Parameters:
const Color&
The color to check.
Return Value:
The index of the component with the minimum absolute value. r=0, g=1, b=2, a=3.
Prototype:
inline AColor operator*(float f, const AColor& a)
inline AColor operator*(const AColor& a, float f)
Remarks:
Multiplies each component of an AColor by a float.
Return Value:
An AColor with each component multiplied by a float.
Prototype:
inline AColor CompOver(const AColor &fg, const AColor& bg)
Remarks:
Composite fg over bg, assuming associated alpha, i.e. pre-multiplied alpha for both fg and bg
This is: fg + (1.0f-fg.a)*bg
Parameters:
const AColor &fg
Specifies the foreground color to composite.
const AColor& bg
Specifies the background color to composite over.
Return Value:
The resulting AColor.