Sleipnir
|
Simple representation of a color triple in RGB space. More...
#include <color.h>
Public Member Functions | |
CColor (const unsigned char *abRGB) | |
Construct a new color with the given red, green, and blue values. | |
CColor (unsigned char bRed, unsigned char bGreen, unsigned char bBlue) | |
Construct a new color with the given red, green, and blue values. | |
CColor | operator+ (const CColor &Color) const |
Blend two colors equally. | |
CColor | operator* (float dValue) const |
Scale the current color by the requested amount. | |
CColor & | operator= (const CColor &Color) |
Copies the given color into the current color. | |
std::string | ToRGB () const |
Constructs a standard hexadecimal string encoding the current color. | |
bool | IsDark () const |
Returns true if the current color is dark enough to warrant a light foreground. | |
Static Public Member Functions | |
static CColor | Interpolate (float dValue, const CColor &ColorMinimum, const CColor &ColorMedium, const CColor &ColorMaximum) |
Given a fractional value, interpolate between three colors. | |
Static Public Attributes | |
static const CColor | c_Black = CColor( 0x00, 0x00, 0x00 ) |
Black. | |
static const CColor | c_Cyan = CColor( 0x00, 0xFF, 0xFF ) |
Cyan. | |
static const CColor | c_Green = CColor( 0x00, 0xFF, 0x00 ) |
Green. | |
static const CColor | c_Red = CColor( 0xFF, 0x00, 0x00 ) |
Red. | |
static const CColor | c_White = CColor( 0xFF, 0xFF, 0xFF ) |
White. | |
static const CColor | c_Yellow = CColor( 0xFF, 0xFF, 0x00 ) |
Yellow. | |
static const CColor | c_Blue = CColor( 0x00, 0x00, 0xFF ) |
static const CColor | c_DarkGreen = CColor( 0x00, 0x64, 0x00 ) |
static const CColor | c_Orange = CColor( 0xFF, 0xA5, 0x00 ) |
Sleipnir::CColor::CColor | ( | const unsigned char * | abRGB | ) |
Construct a new color with the given red, green, and blue values.
abRGB | Array of three bytes representing red, green, and blue values between 0 and 255. |
Definition at line 89 of file color.cpp.
Referenced by operator*(), and operator+().
Sleipnir::CColor::CColor | ( | unsigned char | bRed, |
unsigned char | bGreen, | ||
unsigned char | bBlue | ||
) |
CColor Sleipnir::CColor::Interpolate | ( | float | dValue, |
const CColor & | ColorMinimum, | ||
const CColor & | ColorMedium, | ||
const CColor & | ColorMaximum | ||
) | [static] |
Given a fractional value, interpolate between three colors.
dValue | Fractional value between 0 and 1. |
ColorMinimum | Minimum color (corresponding to value zero). |
ColorMedium | Midpoint color (corresponding to value 0.5). |
ColorMaximum | Maximum color (corresponding to value one). |
Blend continuously between three colors given a value between 0 and 1. Given 0, the minimum color is returned. Given 0.5, the midpoint color is returned. Between 0 and 0.5, the minimum and midpoint colors are mixed; between 0.5 and 1, the midpoint and maximum colors are mixed. Given 1, the maximum color is returned.
Definition at line 63 of file color.cpp.
Referenced by Sleipnir::CDat::SaveDOT().
bool Sleipnir::CColor::IsDark | ( | ) | const |
Returns true if the current color is dark enough to warrant a light foreground.
If this method returns true, it is generally safe to assume that the current color is dark enough to warrant a white foreground; if it returns false, a black foreground is appropriate. This calculation is performed heuristically by testing whether the color's value is low or its hue is extreme in HSV space.
CColor Sleipnir::CColor::operator* | ( | float | dValue | ) | const |
Scale the current color by the requested amount.
dValue | Scalar by which the channels of the current color are multiplied. |
Definition at line 146 of file color.cpp.
References CColor(), and Sleipnir::CMath::Round().
string Sleipnir::CColor::ToRGB | ( | ) | const |
Constructs a standard hexadecimal string encoding the current color.
Definition at line 186 of file color.cpp.
Referenced by Sleipnir::CDat::SaveDOT().