OMK::Type::Color Class Reference

Color Type. More...

#include <OMKColor.h>

Collaboration diagram for OMK::Type::Color:

Collaboration graph
[legend]
List of all members.

operators

Coloroperator= (const Color &color)
Coloroperator= (float v[4])
float & operator[] (int i)
float operator[] (int i) const
OMK_API bool operator== (const Color &c0, const Color &c1)
 equality operator
OMK_API bool operator!= (const Color &c0, const Color &c1)
 inequality operator

Public Member Functions

Get accessors
float getR () const
 Get the red component of the color.
float getG () const
 Get the green component of the color.
float getB () const
 Get the blue component of the color.
float getA () const
 Get the alpha channel of the color.
Set accessors
void setR (float r)
 Set the red component of the color.
void setG (float g)
 Set the green component of the color.
void setB (float b)
 Set the blue component of the color.
void setA (float a)
 Set the alpha channel of the color.

Private Member Functions

void _copy (const Color &color)
 copy, for constructor and operator

Private Attributes

float _array [4]
 vecor of 4 float

Friends

Friend stream operators.
std::ostream & operator<< (std::ostream &out, const Color &color)
 stream operator for ostream.
std::istream & operator>> (std::istream &in, Color &color)
 stream operator for istream.
OMK::OutgoingSynchronisationMessageoperator<< (OMK::OutgoingSynchronisationMessage &out, const Color &color)
 stream operator for OutgoingSynchronisationMessage.
OMK::IncomingSynchronisationMessageoperator>> (OMK::IncomingSynchronisationMessage &in, Color &color)
 stream operator for IncomingSynchronisationMessage.

Detailed Description

Color Type.

The color is a array of Red, Green, Blue components plus Alpha channel (transparency). The set for each value is between 0 and 1.

Getting a OMKColor with OMKParameterAccessor.
The parameter accessor for OMKColor reads a color with or without the alpha channel. The RGB values could be in [0, 1] or in [0, 255]. So these following colors are valid
 black     [0 0 0] 
 white     [1 1 1]
 withAlpha [0.4 0.3 1.0 .5]
 fullGreen [255 0 0]
 darkGreen [0.5 0 0]
You can also use the "string" syntax, but in that case the four values (in [0 1] set) must be set. No test are be done, if the alpha channel is not present, the call crashes.
 withAlpha "0.4 0.3 1.0 .5"

Definition at line 82 of file OMKColor.h.


Constructor & Destructor Documentation

Color::Color (  ) 

Default cconstructor.

Definition at line 30 of file OMKColor.cpp.

References _array.

00031 {
00032   _array[0] = 0.0f ; 
00033   _array[1] = 0.0f ; 
00034   _array[2] = 0.0f ; 
00035   _array[3] = 1.0f ;
00036 }

Color::Color ( const Color color  ) 

Copy constructor.

Definition at line 38 of file OMKColor.cpp.

References _copy().

00039 {
00040   _copy( color ) ;
00041 }

Color::Color ( float  r,
float  g,
float  b,
float  a = 1.0f 
)

Constructor with setting of the color components and alpha channel (optional).

Definition at line 43 of file OMKColor.cpp.

References _array.

00044 {
00045   _array[0] = r ; 
00046   _array[1] = g ; 
00047   _array[2] = b ; 
00048   _array[3] = a ;
00049 }

Color::~Color (  )  [virtual]

Destructor.

Definition at line 51 of file OMKColor.cpp.

00052 {
00053 }

Color::Color (  ) 

Default cconstructor.

Definition at line 30 of file OMKColor.cpp.

References _array.

00031 {
00032   _array[0] = 0.0f ; 
00033   _array[1] = 0.0f ; 
00034   _array[2] = 0.0f ; 
00035   _array[3] = 1.0f ;
00036 }

Color::Color ( const Color color  ) 

Copy constructor.

Definition at line 38 of file OMKColor.cpp.

References _copy().

00039 {
00040   _copy( color ) ;
00041 }

Color::Color ( float  r,
float  g,
float  b,
float  a = 1.0f 
)

Constructor with setting of the color components and alpha channel (optional).

Definition at line 43 of file OMKColor.cpp.

References _array.

00044 {
00045   _array[0] = r ; 
00046   _array[1] = g ; 
00047   _array[2] = b ; 
00048   _array[3] = a ;
00049 }

Color::~Color (  )  [virtual]

Destructor.

Definition at line 51 of file OMKColor.cpp.

00052 {
00053 }


Member Function Documentation

float OMK::Type::Color::getR (  )  const [inline]

Get the red component of the color.

Returns:
the red component of the color in set [0, 1]

Definition at line 102 of file OMKColor.h.

Referenced by OMK::ParametersAccessor::setValue().

00102 { return _array[0] ; }

float OMK::Type::Color::getG (  )  const [inline]

Get the green component of the color.

Returns:
the green component of the color in set [0, 1]

Definition at line 105 of file OMKColor.h.

Referenced by OMK::ParametersAccessor::setValue().

00105 { return _array[1] ; }

float OMK::Type::Color::getB (  )  const [inline]

Get the blue component of the color.

Returns:
the blue component of the color in set [0, 1]

Definition at line 108 of file OMKColor.h.

Referenced by OMK::ParametersAccessor::setValue().

00108 { return _array[2] ; }

float OMK::Type::Color::getA (  )  const [inline]

Get the alpha channel of the color.

Returns:
the alpha channel of the color in set [0, 1]

Definition at line 111 of file OMKColor.h.

Referenced by OMK::ParametersAccessor::setValue().

00111 { return _array[3] ; }

void OMK::Type::Color::setR ( float  r  )  [inline]

Set the red component of the color.

Parameters:
[in] r is the red component of the color in set [0, 1]

Definition at line 118 of file OMKColor.h.

00118 { _array[0] = r ; }

void OMK::Type::Color::setG ( float  g  )  [inline]

Set the green component of the color.

Parameters:
[in] g is the green component of the color in set [0, 1]

Definition at line 121 of file OMKColor.h.

00121 { _array[1] = g ; }

void OMK::Type::Color::setB ( float  b  )  [inline]

Set the blue component of the color.

Parameters:
[in] b is the blue component of the color in set [0, 1]

Definition at line 124 of file OMKColor.h.

00124 { _array[2] = b ; }

void OMK::Type::Color::setA ( float  a  )  [inline]

Set the alpha channel of the color.

Parameters:
[in] a is the alpha channel of the color in set [0, 1]

Definition at line 127 of file OMKColor.h.

00127 { _array[3] = a ; }

Color& OMK::Type::Color::operator= ( const Color color  )  [inline]

Definition at line 135 of file OMKColor.h.

00135 { if ( this != &color ) _copy( color ) ; return *this ; }

Color & Color::operator= ( float  v[4]  ) 

Definition at line 55 of file OMKColor.cpp.

References _array.

00056 {
00057   for ( int i = 0 ; i < 4 ; i++ )
00058   {
00059     _array[i] = values[i] ;
00060   }
00061   return * this ;
00062 }  

float& OMK::Type::Color::operator[] ( int  i  )  [inline]

Definition at line 137 of file OMKColor.h.

00137 { return _array[i] ; }

float OMK::Type::Color::operator[] ( int  i  )  const [inline]

Definition at line 138 of file OMKColor.h.

00138 { return _array[i] ; }

void Color::_copy ( const Color color  )  [private]

copy, for constructor and operator

Definition at line 64 of file OMKColor.cpp.

References _array.

Referenced by Color().

00065 {
00066   for ( int i = 0 ; i < 4 ; i++ ) 
00067   {
00068     _array[i] = color._array[i] ;
00069   }
00070 }


Friends And Related Function Documentation

OMK_API bool operator== ( const Color c0,
const Color c1 
) [friend]

equality operator

Definition at line 74 of file OMKColor.cpp.

00075 {
00076   return c0._array[0] == c1._array[0]
00077       && c0._array[1] == c1._array[1]
00078       && c0._array[2] == c1._array[2]
00079       && c0._array[3] == c1._array[3] ;
00080 }

OMK_API bool operator!= ( const Color c0,
const Color c1 
) [friend]

inequality operator

Definition at line 82 of file OMKColor.cpp.

00083 {
00084   return !( c0 == c1 ) ;
00085 }

std::ostream& operator<< ( std::ostream &  out,
const Color color 
) [friend]

stream operator for ostream.

Use by OMK::Type::SimpleTypeT::insertInStream.

Definition at line 110 of file OMKColor.cpp.

00111 {
00112   for( int i = 0 ; i < 4 ; i++ ) 
00113   {
00114     out << color._array[i] << " " ;
00115   }
00116   return out ;
00117 }

std::istream& operator>> ( std::istream &  in,
Color color 
) [friend]

stream operator for istream.

Use by OMK::Type::SimpleTypeT::extract.

Definition at line 101 of file OMKColor.cpp.

00102 {
00103   for ( int i = 0 ; i < 4 ; i++ ) 
00104   {
00105     in >> color._array[i] ;
00106   }
00107   return in ;
00108 }

OMK::OutgoingSynchronisationMessage& operator<< ( OMK::OutgoingSynchronisationMessage out,
const Color color 
) [friend]

stream operator for OutgoingSynchronisationMessage.

Use by OMK::Type::SimpleTypeT::pack.

Definition at line 95 of file OMKColor.cpp.

00096 {
00097   out.pack( color._array, 4 ) ;
00098   return out ;
00099 }

OMK::IncomingSynchronisationMessage& operator>> ( OMK::IncomingSynchronisationMessage in,
Color color 
) [friend]

stream operator for IncomingSynchronisationMessage.

Use by OMK::Type::SimpleTypeT::unpack.

Definition at line 88 of file OMKColor.cpp.

00089 {
00090   in.get( color._array, 4 ) ;
00091   return in ;
00092 }


Member Data Documentation

float OMK::Type::Color::_array[4] [private]

vecor of 4 float

Definition at line 165 of file OMKColor.h.

Referenced by _copy(), Color(), operator<<(), operator=(), OMK::Type::operator==(), and operator>>().


logo OpenMask

Documentation generated on Mon Jun 9 11:46:05 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007