00001 #include <time.h>
00002 #include <stdlib.h>
00003 #include <grass/gis.h>
00004
00005 #define MAX_COLORS 1024
00006 #define DEVIATION 128
00007
00008
00021 int G_make_random_colors ( struct Colors *colors , CELL min,CELL max)
00022 {
00023 unsigned char red, grn, blu;
00024 int count;
00025 CELL n;
00026
00027 G_init_colors (colors);
00028 if (min > max) return -1;
00029
00030 srand(time ((long *)0));
00031
00032 count = MAX_COLORS-DEVIATION + rand() % DEVIATION;
00033 if (count > max-min+1)
00034 count = max-min+1;
00035
00036 for (n = 1; n <= count; n++)
00037 {
00038 red = rand() & 0377;
00039 grn = rand() & 0377;
00040 blu = rand() & 0377;
00041 G_add_modular_color_rule (n, red, grn, blu, n, red, grn, blu, colors);
00042 }
00043 G_set_color_range (min, max, colors);
00044
00045 return 1;
00046 }