C4 Engine
C4 Engine API Documentation

class ColorRGB

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

class ColorRGB

Member Functions
ColorRGB::Set Sets all three components of a color.
ColorRGB::GetLuminance Returns the luminance of an RGB 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 whether the colors c1 and c2 are equal.
bool operator !=(const ColorRGB& c1, const ColorRGB& c2); Returns a boolean value indicating whether the colors c1 and c2 are not equal.
float Luminance(const ColorRGB& c); Returns the luminance value of the color c.
See Also

ColorRGBA