I know this is nothing new. But when I was looking for something similar to C# color class with tons of predefined color values I found one wihich somehow matches with my requirement but that was for MFC. So I took the predefined color codes from that class and added some function for my own purpose. Code project have two of them hosted there. Here are the links:
I will not paste the entire file here, just a portion. The files can be downloaded from here. Let me discuss some of the characterstic of the class
The entire class is inside Mahbub namespace. The Color class has four color components for red, green, blue and alpha. It has a option to store a name for it as well. But the memory is never allocated if no name is specified. You can use random number generator and generate random color from it. I used Mersenne Twister random number generator with it. Also I used a Mathematics wrapper class with it. I will post the Mathematics wrapper class description later. You can download it from here or just replace with appropriate function from math.h.
Here is an example usage of it:
Color a = Color::RED;
If you find it useful or have any suggestion please don’t forget to let me know, udvranto (a) yahoo.
Powered by Qumana