Generic Trace Generator (GTG)  0.1
GTGColor.h
Go to the documentation of this file.
00001 
00009 #ifndef _GTGCOLOR_H_
00010 #define _GTGCOLOR_H_
00011 
00012 #include <stdint.h>
00013 
00018 typedef uint32_t gtg_rgb_color_t;
00019 
00025 struct gtg_color {
00027         char* color_name; 
00028         gtg_rgb_color_t rgb; 
00030 };
00031 typedef struct gtg_color* gtg_color_t;
00032 
00033 /* In a 4-byte value, the first byte corresponds to blue,
00034  * the second to green, the third to red. The 4th byte is 
00035  * unused (for now). ie. a color is represented as follows:
00036  * 0x00rrggbb
00037  */
00038 #define GTG_COLOR_BLUE_POS  0
00039 #define GTG_COLOR_GREEN_POS 8
00040 #define GTG_COLOR_RED_POS   16
00041 
00042 #define GTG_COLOR_BLUE_MASK  (0x000000ff << GTG_COLOR_BLUE_POS)
00043 #define GTG_COLOR_GREEN_MASK (0x000000ff << GTG_COLOR_GREEN_POS)
00044 #define GTG_COLOR_RED_MASK   (0x000000ff << GTG_COLOR_RED_POS)
00045 
00051 static inline uint8_t
00052 GTG_COLOR_GET_BLUE(gtg_rgb_color_t rgb)
00053 {
00054         return (((rgb) & GTG_COLOR_BLUE_MASK)  >> GTG_COLOR_BLUE_POS );
00055 }
00056 
00062 static inline uint8_t
00063 GTG_COLOR_GET_GREEN(gtg_rgb_color_t rgb)
00064 {
00065         return (((rgb) & GTG_COLOR_GREEN_MASK) >> GTG_COLOR_GREEN_POS);
00066 }
00067 
00073 static inline uint8_t
00074 GTG_COLOR_GET_RED(gtg_rgb_color_t rgb)
00075 {
00076         return (((rgb) & GTG_COLOR_RED_MASK)   >> GTG_COLOR_RED_POS  );
00077 }
00078 
00079 
00085 static inline gtg_rgb_color_t
00086 GTG_COLOR_SET_COLOR(uint8_t r, uint8_t g, uint8_t b)
00087 {
00088         return ((r << GTG_COLOR_RED_POS) |
00089                 (g << GTG_COLOR_GREEN_POS) |
00090                 (b << GTG_COLOR_BLUE_POS));
00091 }
00092 
00093 
00099 extern gtg_color_t GTG_BLACK;
00100 
00106 extern gtg_color_t GTG_RED;
00107 
00113 extern gtg_color_t GTG_GREEN;
00114 
00120 extern gtg_color_t GTG_BLUE;
00121 
00127 extern gtg_color_t GTG_WHITE;
00128 
00134 extern gtg_color_t GTG_TEAL;
00135 
00141 extern gtg_color_t GTG_DARKGREY;
00142 
00148 extern gtg_color_t GTG_YELLOW;
00149 
00155 extern gtg_color_t GTG_PURPLE;
00156 
00162 extern gtg_color_t GTG_LIGHTBROWN;
00163 
00169 extern gtg_color_t GTG_LIGHTGREY;
00170 
00176 extern gtg_color_t GTG_DARKBLUE;
00177 
00183 extern gtg_color_t GTG_PINK;
00184 
00190 extern gtg_color_t GTG_DARKPINK;
00191 
00197 extern gtg_color_t GTG_SEABLUE;
00198 
00204 extern gtg_color_t GTG_KAKI;
00205 
00211 extern gtg_color_t GTG_REDBLOOD;
00212 
00218 extern gtg_color_t GTG_BROWN;
00219 
00225 extern gtg_color_t GTG_GRENAT;
00226 
00232 extern gtg_color_t GTG_ORANGE;
00233 
00239 extern gtg_color_t GTG_MAUVE;
00240 
00246 extern gtg_color_t GTG_LIGHTPINK;
00247 
00248 void gtg_color_init();
00249 void gtg_color_exit();
00250 
00251 gtg_color_t gtg_color_create( const char *name, uint8_t r, uint8_t g, uint8_t b);
00252 void        gtg_color_free(gtg_color_t color);
00253 
00254 #endif /* _GTGCOLOR_H_ */