00001 #ifndef COLORS_H_IS_INCLUDED
00002 #define COLORS_H_IS_INCLUDED
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "geom/rgba.H"
00017 #include "std/config.H"
00018 #include "color.H"
00019
00020 namespace Color {
00021
00022
00023 inline COLOR color_ub(unsigned char r, unsigned char g, unsigned char b) {
00024 return COLOR(r/255.0, g/255.0, b/255.0);
00025 }
00026
00027
00028 inline COLOR rgba_to_color(uint rgba) {
00029 return COLOR(rgba_to_r(rgba)/255.0,
00030 rgba_to_g(rgba)/255.0,
00031 rgba_to_b(rgba)/255.0);
00032 }
00033
00034
00035 inline double rgba_to_alpha(uint rgba) {
00036 return rgba_to_a(rgba)/255.0;
00037 }
00038
00039
00040 inline uint color_to_rgba(CCOLOR& col, double alpha=1) {
00041 return build_rgba(uchar(255*col[0]),
00042 uchar(255*col[1]),
00043 uchar(255*col[2]),
00044 uchar(255*alpha ));
00045 }
00046
00047
00048
00049 CCOLOR black (0.0,0.0,0.0);
00050 CCOLOR white (1.0,1.0,1.0);
00051
00052 CCOLOR grey1 (0.1,0.1,0.1);
00053 CCOLOR grey2 (0.2,0.2,0.2);
00054 CCOLOR grey3 (0.3,0.3,0.3);
00055 CCOLOR grey4 (0.4,0.4,0.4);
00056 CCOLOR grey5 (0.5,0.5,0.5);
00057 CCOLOR grey6 (0.6,0.6,0.6);
00058 CCOLOR grey7 (0.7,0.7,0.7);
00059 CCOLOR grey8 (0.8,0.8,0.8);
00060 CCOLOR grey9 (0.9,0.9,0.9);
00061
00062 inline COLOR grey(double g) { return COLOR(g,g,g); }
00063
00064 CCOLOR red (1.0,0.0,0.0);
00065 CCOLOR green (0.0,1.0,0.0);
00066 CCOLOR blue (0.0,0.0,1.0);
00067
00068 CCOLOR yellow (1.0,1.0,0.0);
00069 CCOLOR magenta (1.0,0.0,1.0);
00070 CCOLOR cyan (0.0,1.0,1.0);
00071
00072 CCOLOR pink (1.0,0.5,0.5);
00073
00074 CCOLOR orange (1.0,0.5,0.0);
00075
00076 CCOLOR brown (0.5,.37,.25);
00077 CCOLOR tan (0.9,0.8,0.7);
00078
00079 CCOLOR firebrick (0.698, 0.133, 0.133);
00080
00081 CCOLOR blue_pencil_l = color_ub(166,201,243);
00082 CCOLOR blue_pencil_m = color_ub(104,158,222);
00083 CCOLOR blue_pencil_d = color_ub( 79,135,211);
00084
00085 CCOLOR red_pencil = color_ub(215, 50, 20);
00086
00087 CCOLOR orange_pencil_l = color_ub(255, 204, 51);
00088 CCOLOR orange_pencil_m = color_ub(255, 153, 11);
00089 CCOLOR orange_pencil_d = color_ub(243, 102, 0);
00090
00091 CCOLOR blue1 = color_ub( 63, 64, 69);
00092 CCOLOR blue2 = color_ub( 6, 90, 126);
00093 CCOLOR blue3 = color_ub(100, 117, 135);
00094 CCOLOR blue4 = color_ub(133, 156, 162);
00095 CCOLOR green2 = color_ub(223, 217, 185);
00096 CCOLOR green1 = color_ub(193, 186, 118);
00097 CCOLOR orange1 = color_ub(234, 137, 33);
00098 CCOLOR orange2 = color_ub(254, 171, 69);
00099 CCOLOR orange3 = color_ub(255, 216, 178);
00100 CCOLOR red1 = color_ub(115, 0, 24);
00101 CCOLOR red2 = color_ub(149, 47, 7);
00102 CCOLOR red3 = color_ub(204, 136, 99);
00103
00104 CCOLOR brown5 = color_ub(180, 150, 98);
00105 CCOLOR brown4 = color_ub(207, 164, 101);
00106 CCOLOR brown3 = color_ub(170, 120, 63);
00107 CCOLOR brown2 = color_ub(137, 91, 46);
00108 CCOLOR brown1 = color_ub( 93, 50, 23);
00109
00110 CCOLOR gray1 = color_ub(140, 141, 146);
00111 CCOLOR gray2 = color_ub(183, 172, 166);
00112 CCOLOR gray3 = color_ub(236, 225, 219);
00113
00114 CCOLOR s_green = color_ub(177 , 217, 60);
00115
00116
00117
00118
00119 inline str_ptr color_to_str(CCOLOR& col) {
00120 return str_ptr(col[0]) + " " + col[1] + " " + col[2];
00121 }
00122
00123
00124
00125
00126 inline CCOLOR get_var_color(Cstr_ptr& var_name, CCOLOR& default_val) {
00127 str_ptr col_str = Config::get_var_str(var_name, color_to_str(default_val));
00128 double r, g, b;
00129 sscanf(**col_str, "%lf%lf%lf", &r, &g, &b);
00130 return COLOR(r,g,b);
00131 }
00132 }
00133
00134 #endif // COLORS_H_IS_INCLUDED
00135
00136