00001 #include <grass/gis.h>
00002
00009 int G_colors_count ( struct Colors *colors )
00010 {
00011 int count = 0;
00012 struct _Color_Rule_ *rule;
00013
00014 if ( colors->fixed.rules ) {
00015 count++;
00016 rule = colors->fixed.rules;
00017
00018 while (rule->next) {
00019 count++;
00020 rule = rule->next;
00021 }
00022 }
00023 if ( colors->modular.rules ) {
00024 count++;
00025 rule = colors->modular.rules;
00026
00027 while (rule->next) {
00028 count++;
00029 rule = rule->next;
00030 }
00031 }
00032 return count;
00033 }
00034
00044 int G_get_f_color_rule ( DCELL *val1, unsigned char *r1, unsigned char *g1, unsigned char *b1,
00045 DCELL *val2, unsigned char *r2, unsigned char *g2, unsigned char *b2,
00046 struct Colors *colors, int rule )
00047 {
00048 int index = -1;
00049 int found = 0;
00050 struct _Color_Rule_ *rl;
00051
00052 *val1 = *val2 = 0.0;
00053 *r1 = *g1 = *b1 = *r2 = *g2 = *b2 = 0;
00054
00055
00056 if ( colors->fixed.rules ) {
00057 rl = colors->fixed.rules;
00058 index++;
00059 if ( index == rule ) found = 1;
00060
00061 while ( !found && rl->next) {
00062 rl = rl->next;
00063 index++;
00064 if ( index == rule ) found = 1;
00065 }
00066 }
00067 if ( !found && colors->modular.rules ) {
00068 rl = colors->modular.rules;
00069 index++;
00070 if ( index == rule ) found = 1;
00071
00072 while ( !found && rl->next) {
00073 rl = rl->next;
00074 index++;
00075 if ( index == rule ) found = 1;
00076 }
00077 }
00078
00079 if ( !found ) return 1;
00080
00081
00082 *val1 = rl->low.value;
00083 *val2 = rl->high.value;
00084
00085 *r1 = rl->low.red;
00086 *g1 = rl->low.grn;
00087 *b1 = rl->low.blu;
00088
00089 *r2 = rl->high.red;
00090 *g2 = rl->high.grn;
00091 *b2 = rl->high.blu;
00092
00093 return 0;
00094 }
00095