Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

# Keos::CColor Class Reference

Class manipulating colors. More...

`#include <KeosColor.h>`

List of all members.

## Public Member Functions

| CColor (ulong nColor=0xFF000000)
| Default constructor.
| CColor (uchar r, uchar g, uchar b, uchar a=0xFF)
| Constructor using 4 constituents.
ulong | ToARGB () const
| Return the color in ARGB mode.
ulong | ToABGR () const
| Return the color in ABGR mode.
ulong | ToRGBA () const
| Return the color in RGBA mode.
uchar | GetAlpha () const
| Return the Alpha canal.
uchar | GetRed () const
| Return the Red canal.
uchar | GetGreen () const
| Return the Green canal.
uchar | GetBlue () const
| Return the Blue canal.
void | SetFloats (float r, float g, float b, float a=1.0f)
| Create new color with 4 floats [0..1].
void | Set (uchar r, uchar g, uchar b, uchar a=0xFF)
| Create new color with 4 uchar [0..255].
void | ToFloat (float Dest[]) const
| Convert the color in 4 floats.
bool | operator== (const CColor &c) const
| == operator.
bool | operator!= (const CColor &c) const
| != operator.
const CColor & | operator+= (const CColor &c)
| += operator.
const CColor & | operator-= (const CColor &c)
| -= operator.
CColor | operator+ (const CColor &c) const
| + operator.
CColor | operator- (const CColor &c) const

- operator.

CColor | operator * (float v) const
| * operator.
const CColor & | operator *= (float v)
| *= operator.
CColor | operator/ (float v) const
| / operator.
const CColor & | operator/= (float v)
| /= operator.
CColor | Add (const CColor &c) const
| Add two colors.
CColor | Modulate (const CColor &c) const
| Modulate two colors.

## Static Public Attributes

static const ulong | White = 0xFFFFFFFF
| Predefined color: White.
static const ulong | Black = 0xFF000000
| Predefined color: Black.
static const ulong | Red = 0xFFFF0000
| Predefined color: Red.
static const ulong | Green = 0xFF00FF00
| Predefined color: Green.
static const ulong | Blue = 0xFF0000FF
| Predefined color: Blue.

## Private Member Functions

void | SetInt (int r, int g, int b, int a=0xFF)
| Create new color with 4 int [0..255].

## Private Attributes

ulong | m_nColor
| Current color.

## Friends

std::istream & | operator>> (std::istream &Stream, CColor &Color)
| Overload of the operator >>.
std::ostream & | operator<< (std::ostream &Stream, const CColor &Color)
| Overload of the operator <<.

## Detailed Description

Class manipulating colors.

Definition at line 32 of file KeosColor.h.

## Constructor & Destructor Documentation

Keos::CColor::CColor | ( | ulong | nColor = `0xFF000000` | ) | `[inline]`

| Default constructor.

Parameters:

  | nColor | Color (ex: 0xFF00FF00 for red).

Definition at line 39 of file KeosColor.h.

References m_nColor.

Referenced by Modulate().

Keos::CColor::CColor | ( | uchar | r,
|  | uchar | g,
|  | uchar | b,
|  | uchar | a = `0xFF`
| ) | `[inline]`

| Constructor using 4 constituents.

Parameters:

  | r | Red canal.
  | g | Green canal.
  | b | Blue canal.
  | a | Alpha canal.

Definition at line 50 of file KeosColor.h.

References Set().

## Member Function Documentation

CColor Keos::CColor::Add | ( | const CColor & | c | ) | const`[inline]`

| Add two colors.

Parameters:

  | c | Color to add.

Definition at line 268 of file KeosColor.h.

uchar Keos::CColor::GetAlpha | ( |  | ) | const`[inline]`

| Return the Alpha canal.

Returns:
  The Alpha canal.

Definition at line 83 of file KeosColor.h.

References m_nColor.

Referenced by Modulate(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), ToABGR(), ToARGB(), and ToFloat().

uchar Keos::CColor::GetBlue | ( |  | ) | const`[inline]`

| Return the Blue canal.

Returns:
  The Blue canal.

Definition at line 107 of file KeosColor.h.

References m_nColor.

Referenced by Modulate(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), ToABGR(), ToARGB(), and ToFloat().

uchar Keos::CColor::GetGreen | ( |  | ) | const`[inline]`

| Return the Green canal.

Returns:
  The Green canal.

Definition at line 99 of file KeosColor.h.

References m_nColor.

Referenced by Modulate(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), ToABGR(), ToARGB(), and ToFloat().

uchar Keos::CColor::GetRed | ( |  | ) | const`[inline]`

| Return the Red canal.

Returns:
  The Red canal.

Definition at line 91 of file KeosColor.h.

References m_nColor.

Referenced by Modulate(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), ToABGR(), ToARGB(), and ToFloat().

CColor Keos::CColor::Modulate | ( | const CColor & | c | ) | const`[inline]`

| Modulate two colors.

Parameters:

  | c | Color to modulate.

Definition at line 276 of file KeosColor.h.

References CColor(), GetAlpha(), GetBlue(), GetGreen(), and GetRed().

CColor Keos::CColor::operator * | ( | float | v | ) | const`[inline]`

| * operator. Definition at line 224 of file KeosColor.h. References GetAlpha(), GetBlue(), GetGreen(), GetRed(), and SetInt().

const CColor& Keos::CColor::operator *= | ( | float | v | ) | `[inline]`

| *= operator. Definition at line 239 of file KeosColor.h. References GetAlpha(), GetBlue(), GetGreen(), GetRed(), and SetInt().

bool Keos::CColor::operator!= | ( | const CColor & | c | ) | const`[inline]`

| != operator. Definition at line 159 of file KeosColor.h.

CColor Keos::CColor::operator+ | ( | const CColor & | c | ) | const`[inline]`

| + operator. Definition at line 194 of file KeosColor.h. References GetAlpha(), GetBlue(), GetGreen(), GetRed(), and SetInt().

const CColor& Keos::CColor::operator+= | ( | const CColor & | c | ) | `[inline]`

| += operator. Definition at line 166 of file KeosColor.h. References GetAlpha(), GetBlue(), GetGreen(), GetRed(), and SetInt().

CColor Keos::CColor::operator- | ( | const CColor & | c | ) | const`[inline]`

- operator.

Definition at line 209 of file KeosColor.h.

References GetAlpha(), GetBlue(), GetGreen(), GetRed(), and SetInt().

const CColor& Keos::CColor::operator-= | ( | const CColor & | c | ) | `[inline]`

| -= operator. Definition at line 180 of file KeosColor.h. References GetAlpha(), GetBlue(), GetGreen(), GetRed(), and SetInt().

CColor Keos::CColor::operator/ | ( | float | v | ) | const`[inline]`

| / operator. Definition at line 253 of file KeosColor.h.

const CColor& Keos::CColor::operator/= | ( | float | v | ) | `[inline]`

| /= operator. Definition at line 260 of file KeosColor.h.

bool Keos::CColor::operator== | ( | const CColor & | c | ) | const`[inline]`

| == operator. Definition at line 152 of file KeosColor.h. References m_nColor.

void Keos::CColor::Set | ( | uchar | r,
|  | uchar | g,
|  | uchar | b,
|  | uchar | a = `0xFF`
| ) | `[inline]`

| Create new color with 4 uchar [0..255].

Parameters:

  | r | Red canal.
  | g | Green canal.
  | b | Blue canal.
  | a | Alpha canal.

Definition at line 134 of file KeosColor.h.

References m_nColor.

Referenced by CColor(), and SetInt().

void Keos::CColor::SetFloats | ( | float | r,
|  | float | g,
|  | float | b,
|  | float | a = `1.0f`
| ) | `[inline]`

| Create new color with 4 floats [0..1].

Parameters:

  | r | Red canal.
  | g | Green canal.
  | b | Blue canal.
  | a | Alpha canal.

Definition at line 118 of file KeosColor.h.

References SetInt().

void Keos::CColor::SetInt | ( | int | r,
|  | int | g,
|  | int | b,
|  | int | a = `0xFF`
| ) | `[inline, private]`

| Create new color with 4 int [0..255].

Parameters:

  | r | Red canal.
  | g | Green canal.
  | b | Blue canal.
  | a | Alpha canal.

Definition at line 325 of file KeosColor.h.

References Set().

Referenced by operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), and SetFloats().

ulong Keos::CColor::ToABGR | ( |  | ) | const`[inline]`

| Return the color in ABGR mode.

Returns:
  Color in ABGR mode.

Definition at line 66 of file KeosColor.h.

References GetAlpha(), GetBlue(), GetGreen(), and GetRed().

ulong Keos::CColor::ToARGB | ( |  | ) | const`[inline]`

| Return the color in ARGB mode.

Returns:
  Color in ARGB mode.

Definition at line 58 of file KeosColor.h.

References GetAlpha(), GetBlue(), GetGreen(), and GetRed().

void Keos::CColor::ToFloat | ( | float | Dest[] | ) | const`[inline]`

| Convert the color in 4 floats.

Parameters:

  | Dest | Array which will contain the 4 floats.

Definition at line 142 of file KeosColor.h.

References GetAlpha(), GetBlue(), GetGreen(), and GetRed().

ulong Keos::CColor::ToRGBA | ( |  | ) | const`[inline]`

| Return the color in RGBA mode.

Returns:
  Color in RGBA mode.

Definition at line 74 of file KeosColor.h.

References m_nColor.

Referenced by Keos::CD3D9RenderSystem::BeginScene().

## Friends And Related Function Documentation

std::ostream& operator<< | ( | std::ostream & | Stream,
|  | const CColor & | Color
| ) | `[friend]`

| Overload of the operator <<. Definition at line 312 of file KeosColor.h.

std::istream& operator>> | ( | std::istream & | Stream,
|  | CColor & | Color
| ) | `[friend]`

| Overload of the operator >>. Definition at line 300 of file KeosColor.h.

## Member Data Documentation

const ulong Keos::CColor::Black = 0xFF000000`[static]`

| Predefined color: Black. Definition at line 289 of file KeosColor.h.

const ulong Keos::CColor::Blue = 0xFF0000FF`[static]`

| Predefined color: Blue. Definition at line 295 of file KeosColor.h.

const ulong Keos::CColor::Green = 0xFF00FF00`[static]`

| Predefined color: Green. Definition at line 293 of file KeosColor.h.

ulong Keos::CColor::m_nColor`[private]`

| Current color. Definition at line 336 of file KeosColor.h. Referenced by CColor(), GetAlpha(), GetBlue(), GetGreen(), GetRed(), operator==(), Set(), and ToRGBA().

const ulong Keos::CColor::Red = 0xFFFF0000`[static]`

| Predefined color: Red. Definition at line 291 of file KeosColor.h.

const ulong Keos::CColor::White = 0xFFFFFFFF`[static]`

| Predefined color: White. Definition at line 287 of file KeosColor.h.

The documentation for this class was generated from the following file:

- KeosEngine/KeosColor.h