C4 Engine Terathon Software C4 Engine API Documentation

• Math Library

API Links
Developer Links

class ColorRGB

Defined in:  C4ColorRGBA.h
The ColoRGB class encapsulates an 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. 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.

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 [](long k); Returns a reference to the k-th component of a color. The value of k must be 0, 1, or 2.
const floatoperator [](long 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 f); Sets all three components to the value f.
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 t); Multiplies all three components by t.
ColorRGB& operator /=(float t); Divides all three components by t.
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 t); Returns the product of the color c and the scalar t.
ColorRGB operator *(float t, const ColorRGB& c); Returns the product of the color c and the scalar t.
ColorRGB operator /(const ColorRGB& c, float t); Returns the product of the color c and the inverse of the scalar t.
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