Facebook Twitter YouTube

class ColorRGB

Defined in:  TSColorRGBA.h
The ColorRGB class encapsulates a floating-point RGB color.
Definition

class ColorRGB

Member Functions
ColorRGB::Set Sets all three components of a color.
Data Members
float   red; The red component.
float   green; The green component.
float   blue; The blue component.
Constructor

ColorRGB();

ColorRGB(float r, float g, float b);

Description
The ColorRGB class encapsulates a color having floating-point red, green, and blue components in the range [0.0, 1.0]. An additional alpha component is provided by the ColorRGBA class. When a ColorRGB object is converted to a ColorRGBA object, the alpha component is assumed to be 1.0.

The default constructor leaves the components of the color undefined. If the values r, g, and b are supplied, then they are assigned to the red, green, and blue components of the color, respectively.
Overloaded Operators
floatoperator [](machine k); Returns a reference to the k-th component of a color. The value of k must be 0, 1, or 2.
const floatoperator [](machine k) const; Returns a constant reference to the k-th component of a color. The value of k must be 0, 1, or 2.
ColorRGB& operator =(float s); Sets all three components to the value s.
ColorRGB& operator +=(const ColorRGB& c); Adds the color c.
ColorRGB& operator -=(const ColorRGB& c); Subtracts the color c.
ColorRGB& operator *=(const ColorRGB& c); Multiplies by the color c.
ColorRGB& operator *=(float s); Multiplies all three components by s.
ColorRGB& operator /=(float s); Divides all three components by s.
Nonmember Operations
ColorRGB operator -(const ColorRGB& c); Returns the negation of the color c.
ColorRGB operator +(const ColorRGB& c1, const ColorRGB& c2); Returns the sum of the colors c1 and c2.
ColorRGB operator -(const ColorRGB& c1, const ColorRGB& c2); Returns the difference of the colors c1 and c2.
ColorRGB operator *(const ColorRGB& c1, const ColorRGB& c2); Returns the product of the colors c1 and c2.
ColorRGB operator *(const ColorRGB& c, float s); Returns the product of the color c and the scalar s.
ColorRGB operator *(float s, const ColorRGB& c); Returns the product of the color c and the scalar s.
ColorRGB operator /(const ColorRGB& c, float s); Returns the product of the color c and the inverse of the scalar s.
bool operator ==(const ColorRGB& c1, const ColorRGB& c2); Returns a boolean value indicating the equality of the colors c1 and c2.
bool operator !=(const ColorRGB& c1, const ColorRGB& c2); Returns a boolean value indicating the inequality of the colors c1 and c2.
See Also

ColorRGBA