GenColor Class Reference

#include <GenColor.h>

Collaboration diagram for GenColor:

Collaboration graph
[legend]

Public Member Functions

virtual ~GenColor ()
 Empty destructor of GenColor.
GLubyte * getNewColor ()
 Create a new color.

Static Public Member Functions

static GenColorinstance ()
 Return the instance of GenColor (use of singleton design pattern).
static void destroy ()
 Destroy the instance of GenColor.

Protected Member Functions

 GenColor ()
 Empty constructor of GenColor.

Static Protected Attributes

static GenColor_instance = NULL
static unsigned int _nb_colors = 0
static float _factor = 1.0

Detailed Description

< Generator of new colors

Definition at line 33 of file GenColor.h.


Member Function Documentation

GenColor * GenColor::instance (  )  [static]

Return the instance of GenColor (use of singleton design pattern).

Returns:
the instance of GenColor

Definition at line 41 of file GenColor.cpp.

References _instance, and GenColor().

Referenced by Colony::Colony().

00041                              {
00042   if(_instance == NULL) {
00043     _instance = new GenColor();
00044   }
00045 
00046   return _instance;
00047 }

Here is the call graph for this function:

Here is the caller graph for this function:

GLubyte * GenColor::getNewColor (  ) 

Create a new color.

Returns:
the new color created

Definition at line 58 of file GenColor.cpp.

References _factor, _nb_colors, COLOR_LIMIT, COLOR_MAX, and COLOR_MIN.

Referenced by Colony::Colony().

00058                                {
00059   GLubyte *colors;
00060 
00061   colors = new GLubyte[3];
00062   _nb_colors++;
00063 
00064   if(_nb_colors % 8 == 0) {
00065     _factor /= 2.0;
00066   }
00067   colors[0] = ((_nb_colors + 1) % 2 == 0 ?
00068     (GLubyte) (_factor * ((float) (COLOR_MAX - COLOR_LIMIT))) :
00069     (GLubyte) COLOR_MIN);
00070   colors[1] = (((int) (_nb_colors / 2) + 1) % 2 == 0 ?
00071     (GLubyte) (_factor * ((float) (COLOR_MAX - COLOR_LIMIT))) :
00072     (GLubyte) COLOR_MIN);
00073   colors[2] = (((int) (_nb_colors / 4) + 1) % 2 == 0 ?
00074     (GLubyte) (_factor * ((float) (COLOR_MAX - COLOR_LIMIT))) :
00075     (GLubyte) COLOR_MIN);
00076 
00077   return colors;
00078 }

Here is the caller graph for this function:


Field Documentation

GenColor * GenColor::_instance = NULL [static, protected]

The instance of GenColor

Definition at line 38 of file GenColor.h.

Referenced by destroy(), and instance().

unsigned int GenColor::_nb_colors = 0 [static, protected]

The number of colors already generated

Definition at line 41 of file GenColor.h.

Referenced by destroy(), and getNewColor().

float GenColor::_factor = 1.0 [static, protected]

The factor to mutiply the color by

Definition at line 44 of file GenColor.h.

Referenced by destroy(), and getNewColor().


The documentation for this class was generated from the following files:
Generated on Sat Feb 2 22:23:14 2008 for Teapot Colony Wars by  doxygen 1.5.4