Public Attributes

decColor Class Reference

4 Component Color. More...

#include <decColor.h>

List of all members.

Public Member Functions

Constructors and Destructors
 decColor ()
 Creates a new color initialized to ( 0,0,0,1 ).
 decColor (float nr, float ng, float nb)
 Creates a new color with the given values.
 decColor (float nr, float ng, float nb, float na)
 Creates a new color with the given values.
 decColor (const decColor &c)
 Creates a new color with the values of another color.
Management
void Normalize ()
 Normalizes the color.
void SetZero ()
 Sets the red, green and blue components to 0 and the alpha component to 1.
void Set (float nr, float ng, float nb)
 Sets the components to the given values.
void Set (float nr, float ng, float nb, float na)
 Sets the components to the given values.
bool IsEqualTo (const decColor &c, float threshold=0.0001) const
 Determines if the components of this vector are equal to another one with respect to a threshold.
Operators
decColoroperator= (const decColor &c)
 Sets the components of this color to the values of another one.
decColoroperator+= (const decColor &c)
 Adds the components of another color to this one.
decColoroperator-= (const decColor &c)
 Subtracts the components of another color from this color.
decColoroperator*= (float k)
 Multiplies the components of this color with a value k.
decColoroperator/= (float k)
 Divides the components of this color by a value k.
decColor operator+ (const decColor &c) const
 Retrieves a new color with the sum of this color with another one.
decColor operator- (const decColor &c) const
 Retrieves a new color with the difference of this color to another one.
decColor operator* (float k) const
 Retrieves a new color with this color scaled by k.
decColor operator* (const decColor &c) const
 Retrieves a new color with this color multiplied component wise with another one.
decColor operator/ (float k) const
 Retrieves a new color with this color divided by k.

Static Public Member Functions

Predefined Colors
static decColor CreateColor (const char *name)
 Retrieves one of the predefined colors indicated by name.

Public Attributes

float a
 Alpha Component of color.
float b
 Blue Component of color.
float g
 Green Component of color.
float r
 Red Component of color.

Detailed Description

4 Component Color.

Describes an RGBA style color in decimal range. The value of 0 indicates no luminance in that color and 1 indicates full luminance. The color also contains an alpha component where 0 indicates completly transparent and 1 indicates completly opaque.

Author:
Plüss Roland
Version:
1.0
Date:
2008

Constructor & Destructor Documentation

decColor::decColor (  ) [inline]

Creates a new color initialized to ( 0,0,0,1 ).

References a, b, g, and r.

Referenced by operator*(), operator+(), operator-(), and operator/().

decColor::decColor ( float  nr,
float  ng,
float  nb 
) [inline]

Creates a new color with the given values.

References a, b, g, and r.

decColor::decColor ( float  nr,
float  ng,
float  nb,
float  na 
) [inline]

Creates a new color with the given values.

References a, b, g, and r.

decColor::decColor ( const decColor c ) [inline]

Creates a new color with the values of another color.

References a, b, g, and r.


Member Function Documentation

static decColor decColor::CreateColor ( const char *  name ) [static]

Retrieves one of the predefined colors indicated by name.

Possible values for name are 'black', 'white', 'gray', 'light_gray', 'dark_gray', 'red', 'dark_red', 'green', 'dark_green', 'blue', 'dark_blue'. In the case of a name not part of this list black is assumed.

bool decColor::IsEqualTo ( const decColor c,
float  threshold = 0.0001 
) const

Determines if the components of this vector are equal to another one with respect to a threshold.

void decColor::Normalize (  )

Normalizes the color.

Each component is clamped to the range of 0 to 1.

decColor decColor::operator* ( float  k ) const [inline]

Retrieves a new color with this color scaled by k.

References a, b, decColor(), g, and r.

decColor decColor::operator* ( const decColor c ) const [inline]

Retrieves a new color with this color multiplied component wise with another one.

References a, b, decColor(), g, and r.

decColor& decColor::operator*= ( float  k ) [inline]

Multiplies the components of this color with a value k.

References a, b, g, and r.

decColor decColor::operator+ ( const decColor c ) const [inline]

Retrieves a new color with the sum of this color with another one.

References a, b, decColor(), g, and r.

decColor& decColor::operator+= ( const decColor c ) [inline]

Adds the components of another color to this one.

References a, b, g, and r.

decColor decColor::operator- ( const decColor c ) const [inline]

Retrieves a new color with the difference of this color to another one.

References a, b, decColor(), g, and r.

decColor& decColor::operator-= ( const decColor c ) [inline]

Subtracts the components of another color from this color.

References a, b, g, and r.

decColor decColor::operator/ ( float  k ) const [inline]

Retrieves a new color with this color divided by k.

If k is 0 an exception is thrown.

References a, b, decColor(), g, r, and THROW.

decColor& decColor::operator/= ( float  k ) [inline]

Divides the components of this color by a value k.

If the value k is 0 an exception is thrown.

References a, b, g, r, and THROW.

decColor& decColor::operator= ( const decColor c ) [inline]

Sets the components of this color to the values of another one.

References a, b, g, and r.

void decColor::Set ( float  nr,
float  ng,
float  nb,
float  na 
) [inline]

Sets the components to the given values.

References a, b, g, and r.

void decColor::Set ( float  nr,
float  ng,
float  nb 
) [inline]

Sets the components to the given values.

References b, g, and r.

void decColor::SetZero (  ) [inline]

Sets the red, green and blue components to 0 and the alpha component to 1.

References a, b, g, and r.


Member Data Documentation

float decColor::a
float decColor::b
float decColor::g
float decColor::r

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