HyperspaceExplorer 0.7.1
Public Member Functions | Private Attributes

A class to represent a color value by its RGBA components. More...

#include <Color.h>

List of all members.

Public Member Functions

 Color (float, float, float, float=1.)
 construct a Color from its R, G, B and alpha values
 Color (const VecMath::Vector< 4 > &)
 construct a Color from a Vector containing its R, G, B and alpha values
 Color (const QColor &)
 construct a Color from a QColor
float & r ()
 the red component of the color
float r () const
 the red component of the color
float & g ()
 the green component of the color
float g () const
 the green component of the color
float & b ()
 the blue component of the color
float b () const
 the blue component of the color
float & a ()
 the alpha component of the color
float a () const
 the alpha component of the color
 operator float * ()
 direct access to the array of components, needed by OpenGL functions
 operator const float * () const
 direct access to the array of components, needed by OpenGL functions
Color operator*= (float)
 scale the color by a float, keeping the RGB components between 0.0 and 1.0
Color operator*= (const Color &)
 Multiply two colors, component by component.
Color operator* (float)
 scale the color by a float, keeping the RGB components between 0.0 and 1.0
Color operator* (const Color &)
 Multiply two colors, component by component.
Color operator+= (float)
 add a float to the color, keeping the RGB components between 0.0 and 1.0
Color operator+ (float)
 add a float to the color, keeping the RGB components between 0.0 and 1.0
Color operator+= (const Color &)
 add a float to the color, keeping the RGB components between 0.0 and 1.0
Color operator+ (const Color &)
 add a float to the color, keeping the RGB components between 0.0 and 1.0
void setComponentLowerLimit (float)
 make sure that none of the color components is less than the provided limit
void setComponentUpperLimit (float)
 make sure that none of the color components is more than the provided limit
 operator std::string () const
 converts the color's RGB values to a string

Private Attributes

float RGBA [4]
 the components stored as an array of floats

Detailed Description

A class to represent a color value by its RGBA components.

This class provides a single-stop interface to handle a color. It also provides some utility functions to work with colors.

The color's components are stored as an array of floats. Access to the raw array is provided, because the OpenGL functions I use to set a color need an array of floats as parameter.


Constructor & Destructor Documentation

Color::Color ( float  _r,
float  _g,
float  _b,
float  _a = 1. 
) [inline]

construct a Color from its R, G, B and alpha values

Parameters:
_rR value of the color
_gG value of the color
_bB value of the color
_aAlpha value of the color

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

Here is the call graph for this function:

Color::Color ( const VecMath::Vector< 4 > &  x) [inline]

construct a Color from a Vector containing its R, G, B and alpha values

Parameters:
xRGBA values of the color

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

Here is the call graph for this function:

Color::Color ( const QColor &  col) [inline]

construct a Color from a QColor

Parameters:
colRGBA values of the color

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

Here is the call graph for this function:


Member Function Documentation

Color Color::operator* ( float  x) [inline]

scale the color by a float, keeping the RGB components between 0.0 and 1.0

Parameters:
xscaling factor
Color Color::operator* ( const Color x) [inline]

Multiply two colors, component by component.

Parameters:
xscaling factor
Color Color::operator*= ( float  x) [inline]

scale the color by a float, keeping the RGB components between 0.0 and 1.0

Parameters:
xscaling factor

References RGBA.

Color Color::operator*= ( const Color x) [inline]

Multiply two colors, component by component.

Parameters:
xscaling factor

References RGBA.

Color Color::operator+ ( float  x) [inline]

add a float to the color, keeping the RGB components between 0.0 and 1.0

Parameters:
xadded term
Color Color::operator+ ( const Color x) [inline]

add a float to the color, keeping the RGB components between 0.0 and 1.0

Parameters:
xadded term
Color Color::operator+= ( float  x) [inline]

add a float to the color, keeping the RGB components between 0.0 and 1.0

Parameters:
xadded term

References RGBA.

Color Color::operator+= ( const Color x) [inline]

add a float to the color, keeping the RGB components between 0.0 and 1.0

Parameters:
xadded term

References RGBA.

void Color::setComponentLowerLimit ( float  l) [inline]

make sure that none of the color components is less than the provided limit

Parameters:
lthe lower limit for all color components

References RGBA.

Referenced by ColorManager::setRGB().

Here is the caller graph for this function:

void Color::setComponentUpperLimit ( float  u) [inline]

make sure that none of the color components is more than the provided limit

Parameters:
uthe upper limit for all color components

References RGBA.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:17 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo