CARMA C++
color_tab.h
1 #ifndef color_h
2 #define color_h
3 /*
4  * Define single-color ramp functions.
5  */
6 static float grey_l[] = {0.0,1.0};
7 static float grey_c[] = {0.0,1.0};
8 static float blank_c[] = {0.0,0.0};
9 /*
10  * Define a rainbow color table.
11  */
12 static float rain_l[] = {-0.5, 0.0, 0.17, 0.33, 0.50, 0.67, 0.83, 1.0, 1.7};
13 static float rain_r[] = { 0.0, 0.0, 0.0, 0.0, 0.6, 1.0, 1.0, 1.0, 1.0};
14 static float rain_g[] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.6, 0.0, 1.0};
15 static float rain_b[] = { 0.0, 0.3, 0.8, 1.0, 0.3, 0.0, 0.0, 0.0, 1.0};
16 
17 /*
18  * Iraf "heat" color table.
19  */
20 static float heat_l[] = {0.0, 0.2, 0.4, 0.6, 1.0};
21 static float heat_r[] = {0.0, 0.5, 1.0, 1.0, 1.0};
22 static float heat_g[] = {0.0, 0.0, 0.5, 1.0, 1.0};
23 static float heat_b[] = {0.0, 0.0, 0.0, 0.3, 1.0};
24 
25 /*
26  * Weird IRAF ramp color table.
27  */
28 static float ramp_l[] = {0.0, 0.5, 0.5, 0.7, 0.7, 0.85, 0.85, 0.95, 0.95, 1.0};
29 static float ramp_r[] = {0.0, 1.0, 0.0, 0.0, 0.3, 0.8, 0.3, 1.0, 1.0, 1.0};
30 static float ramp_g[] = {0.0, 0.5, 0.4, 1.0, 0.0, 0.0, 0.2, 0.7, 1.0, 1.0};
31 static float ramp_b[] = {0.0, 0.0, 0.0, 0.0, 0.4, 1.0, 0.0, 0.0, 0.95, 1.0};
32 
33 /*
34  * AIPS tvfiddle discrete rainbow color table.
35  */
36 static float aips_l[] = {0.0, 0.1, 0.1, 0.2, 0.2, 0.3, 0.3, 0.4, 0.4, 0.5,
37  0.5, 0.6, 0.6, 0.7, 0.7, 0.8, 0.8, 0.9, 0.9, 1.0};
38 static float aips_r[] = {0.0, 0.0, 0.3, 0.3, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0,
39  0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
40 static float aips_g[] = {0.0, 0.0, 0.3, 0.3, 0.0, 0.0, 0.0, 0.0, 0.8, 0.8,
41  0.6, 0.6, 1.0, 1.0, 1.0, 1.0, 0.8, 0.8, 0.0, 0.0};
42 static float aips_b[] = {0.0, 0.0, 0.3, 0.3, 0.7, 0.7, 0.7, 0.7, 0.9, 0.9,
43  0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
44 
45 #ifdef A_SIZE
46 #undef A_SIZE
47 #endif
48 #define A_SIZE(lev) sizeof(lev)/sizeof(lev[0])
49 
50 typedef struct {
51  const char *name;
52  int n;
53  float *l;
54  float *r;
55  float *g;
56  float *b;
57 } Cmap;
58 
59 typedef enum {
60 C_AIPS,
61 C_BLUE,
62 C_GREEN,
63 C_GREY,
64 C_HEAT,
65 C_NONE,
66 C_RAIN,
67 C_RAMP,
68 C_RED
69 } Cnum;
70 
71 
72 static Cmap std_cmaps[] = {
73  {"aips", A_SIZE(aips_l), aips_l, aips_r, aips_g, aips_b},
74  {"blue", A_SIZE(grey_l), grey_l, blank_c, blank_c, grey_c},
75  {"green", A_SIZE(grey_l), grey_l, blank_c, grey_c, blank_c},
76  {"grey", A_SIZE(grey_l), grey_l, grey_c, grey_c, grey_c},
77  {"heat", A_SIZE(heat_l), heat_l, heat_r, heat_g, heat_b},
78  {"none", 0, 0, 0, 0, 0},
79  {"rainbow", A_SIZE(rain_l), rain_l, rain_r, rain_g, rain_b},
80  {"ramp", A_SIZE(ramp_l), ramp_l, ramp_r, ramp_g, ramp_b},
81  {"red", A_SIZE(grey_l), grey_l, grey_c, blank_c, blank_c},
82 };
83 static int n_std_cmap = A_SIZE(std_cmaps);
84 /*
85  ctab->contra = 5.0 * kp.y / (kp.y < 0.0f ? mp->wya : -mp->wyb);
86  ctab->bright = 0.5 + 1.0 * (fabs(ctab->contra)+1.0) *
87  ((kp.x - mp->wxb)/(mp->wxa - mp->wxb) - 0.5);
88 
89 */
90 
91 #endif