#include <GenColor.h>
Public Member Functions | |
virtual | ~GenColor () |
Empty destructor of GenColor. | |
GLubyte * | getNewColor () |
Create a new color. | |
Static Public Member Functions | |
static GenColor * | instance () |
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 |
Definition at line 33 of file GenColor.h.
GenColor * GenColor::instance | ( | ) | [static] |
Return the instance of GenColor (use of singleton design pattern).
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 }
GLubyte * GenColor::getNewColor | ( | ) |
Create a new color.
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 }
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().