Generic Trace Generator (GTG)  0.1
GTGColor.h
Go to the documentation of this file.
1 
9 #ifndef _GTGCOLOR_H_
10 #define _GTGCOLOR_H_
11 
12 #include <stdint.h>
13 
19 
25 struct gtg_color {
27  char* color_name;
30 };
31 typedef struct gtg_color* gtg_color_t;
32 
33 /* In a 4-byte value, the first byte corresponds to blue,
34  * the second to green, the third to red. The 4th byte is
35  * unused (for now). ie. a color is represented as follows:
36  * 0x00rrggbb
37  */
38 #define GTG_COLOR_BLUE_POS 0
39 #define GTG_COLOR_GREEN_POS 8
40 #define GTG_COLOR_RED_POS 16
41 
42 #define GTG_COLOR_BLUE_MASK (0x000000ff << GTG_COLOR_BLUE_POS)
43 #define GTG_COLOR_GREEN_MASK (0x000000ff << GTG_COLOR_GREEN_POS)
44 #define GTG_COLOR_RED_MASK (0x000000ff << GTG_COLOR_RED_POS)
45 
51 static inline uint8_t
53 {
54  return (((rgb) & GTG_COLOR_BLUE_MASK) >> GTG_COLOR_BLUE_POS );
55 }
56 
62 static inline uint8_t
64 {
65  return (((rgb) & GTG_COLOR_GREEN_MASK) >> GTG_COLOR_GREEN_POS);
66 }
67 
73 static inline uint8_t
75 {
76  return (((rgb) & GTG_COLOR_RED_MASK) >> GTG_COLOR_RED_POS );
77 }
78 
79 
85 static inline gtg_rgb_color_t
86 GTG_COLOR_SET_COLOR(uint8_t r, uint8_t g, uint8_t b)
87 {
88  return ((r << GTG_COLOR_RED_POS) |
89  (g << GTG_COLOR_GREEN_POS) |
90  (b << GTG_COLOR_BLUE_POS));
91 }
92 
93 
99 extern gtg_color_t GTG_BLACK;
100 
106 extern gtg_color_t GTG_RED;
107 
113 extern gtg_color_t GTG_GREEN;
114 
120 extern gtg_color_t GTG_BLUE;
121 
127 extern gtg_color_t GTG_WHITE;
128 
134 extern gtg_color_t GTG_TEAL;
135 
141 extern gtg_color_t GTG_DARKGREY;
142 
148 extern gtg_color_t GTG_YELLOW;
149 
155 extern gtg_color_t GTG_PURPLE;
156 
162 extern gtg_color_t GTG_LIGHTBROWN;
163 
169 extern gtg_color_t GTG_LIGHTGREY;
170 
176 extern gtg_color_t GTG_DARKBLUE;
177 
183 extern gtg_color_t GTG_PINK;
184 
190 extern gtg_color_t GTG_DARKPINK;
191 
197 extern gtg_color_t GTG_SEABLUE;
198 
204 extern gtg_color_t GTG_KAKI;
205 
211 extern gtg_color_t GTG_REDBLOOD;
212 
218 extern gtg_color_t GTG_BROWN;
219 
225 extern gtg_color_t GTG_GRENAT;
226 
232 extern gtg_color_t GTG_ORANGE;
233 
239 extern gtg_color_t GTG_MAUVE;
240 
246 extern gtg_color_t GTG_LIGHTPINK;
247 
248 void gtg_color_init();
249 void gtg_color_exit();
250 
251 gtg_color_t gtg_color_create( const char *name, uint8_t r, uint8_t g, uint8_t b);
252 void gtg_color_free(gtg_color_t color);
253 
254 #endif /* _GTGCOLOR_H_ */
gtg_color_t GTG_BROWN
Default brown color. (R,G,B) = (100, 25, 25)
gtg_color_t GTG_DARKBLUE
Default dark blue color. (R,G,B) = (0, 0, 80)
otf2_id_t uint32_t
Definition: GTGOTF2_Structs.h:32
gtg_color_t GTG_PURPLE
Default purple color. (R,G,B) = (153, 25, 230)
void gtg_color_free(gtg_color_t color)
gtg_color_t GTG_BLUE
Default blue color. (R,G,B) = (0, 0, 255)
gtg_color_t GTG_LIGHTGREY
Default light grey color. (R,G,B) = (200, 200, 200)
gtg_color_t GTG_DARKPINK
Default dark pink color. (R,G,B) = (180, 80, 180)
char * color_name
Definition: GTGColor.h:27
static gtg_rgb_color_t GTG_COLOR_SET_COLOR(uint8_t r, uint8_t g, uint8_t b)
Return the 4-bytes RGB color from 3 1-byte components.
Definition: GTGColor.h:86
gtg_color_t GTG_DARKGREY
Default dark grey color. (R,G,B) = (85, 85, 85)
gtg_color_t GTG_BLACK
Default black color. (R,G,B) = (0, 0, 0)
gtg_color_t GTG_TEAL
Default teal color. (R,G,B) = (0, 255, 255)
gtg_color_t GTG_KAKI
Default kaki color. (R,G,B) = (80, 100, 25)
struct gtg_color * gtg_color_t
Definition: GTGColor.h:31
static uint8_t GTG_COLOR_GET_BLUE(gtg_rgb_color_t rgb)
Return the 1-byte value of the blue component of a rgb color.
Definition: GTGColor.h:52
gtg_color_t GTG_ORANGE
Default orange color. (R,G,B) = (255, 160, 0)
#define GTG_COLOR_GREEN_MASK
Definition: GTGColor.h:43
gtg_color_t GTG_PINK
Default pink color. (R,G,B) = (255, 0, 255)
gtg_color_t GTG_RED
Default red color. (R,G,B) = (255, 0, 0)
#define GTG_COLOR_GREEN_POS
Definition: GTGColor.h:39
gtg_color_t GTG_MAUVE
Default mauve color. (R,G,B) = (128, 0, 255)
gtg_color_t GTG_GREEN
Default green color. (R,G,B) = (0, 255, 0)
static uint8_t GTG_COLOR_GET_GREEN(gtg_rgb_color_t rgb)
Return the 1-byte value of the green component of a rgb color.
Definition: GTGColor.h:63
gtg_color_t gtg_color_create(const char *name, uint8_t r, uint8_t g, uint8_t b)
gtg_color_t GTG_YELLOW
Default yellow color. (R,G,B) = (255, 255, 0)
gtg_color_t GTG_GRENAT
Default grenat color. (R,G,B) = (100, 0, 80)
#define GTG_COLOR_RED_MASK
Definition: GTGColor.h:44
#define GTG_COLOR_BLUE_POS
Definition: GTGColor.h:38
This structure defines a color that can be used by GTG.
Definition: GTGColor.h:25
uint32_t gtg_rgb_color_t
Definition: GTGColor.h:18
#define GTG_COLOR_RED_POS
Definition: GTGColor.h:40
void gtg_color_init()
gtg_color_t GTG_REDBLOOD
Default red blood color. (R,G,B) = (200, 25, 25)
gtg_color_t GTG_WHITE
Default white color. (R,G,B) = (255, 255, 255)
static uint8_t GTG_COLOR_GET_RED(gtg_rgb_color_t rgb)
Return the 1-byte value of the red component of a rgb color.
Definition: GTGColor.h:74
void gtg_color_exit()
gtg_color_t GTG_LIGHTPINK
Default light pink color. (R,G,B) = (255, 128, 255)
gtg_color_t GTG_SEABLUE
Default sea blue color. (R,G,B) = (25, 128, 200)
#define GTG_COLOR_BLUE_MASK
Definition: GTGColor.h:42
gtg_rgb_color_t rgb
Definition: GTGColor.h:28
gtg_color_t GTG_LIGHTBROWN
Default light brown color. (R,G,B) = (170, 130, 130)