00001 #include <grass/gis.h>
00002
00003 static int add_ryg_colors (struct Colors *, DCELL, DCELL);
00004
00005 int G_make_ryg_colors (struct Colors *colors, CELL min, CELL max)
00006 {
00007 G_init_colors (colors);
00008 return add_ryg_colors (colors, (DCELL) min, (DCELL) max);
00009 }
00010
00011 int
00012 G_make_ryg_fp_colors (struct Colors *colors, DCELL min, DCELL max)
00013 {
00014 G_init_colors (colors);
00015 return add_ryg_colors (colors, min, max);
00016 }
00017
00018 int
00019 G_make_red_yel_grn (
00020 struct Colors *colors,
00021 CELL min,
00022 CELL max
00023 )
00024 {
00025 return G_make_ryg_colors(colors,min,max);
00026 }
00027
00028 int
00029 G_add_ryg_colors (struct Colors *colors, CELL min, CELL max)
00030 {
00031 return add_ryg_colors (colors, (DCELL) min, (DCELL) max);
00032 }
00033
00034 static int add_ryg_colors (struct Colors *colors, DCELL min, DCELL max)
00035 {
00036 DCELL mid;
00037
00038 if (max < min) return -1;
00039 if (min == 1.) min = 0.;
00040 if (max == -1.) max = 0.;
00041
00042 mid = (min+max)/2.;
00043
00044 G_add_d_raster_color_rule (&min, 255, 0, 0, &mid, 255, 255, 0, colors);
00045 G_add_d_raster_color_rule (&mid, 255, 255, 0, &max, 0, 255, 0, colors);
00046
00047 return 1;
00048 }