[GRASS5] R_color vs R_standard_color

Glynn Clements glynn at gclements.plus.com
Tue Apr 18 04:58:44 EDT 2006


Cedric Shock wrote:

> Is there any real difference between R_color and R_standard_color?

I made an attempt at documenting all of the different colour systems
in display/drivers/lib/colors.txt.

The colour table used by R_color() can be modified through
R_reset_color[s], while the one used by R_standard_color can't.

> Take this example (d.bargraph's background color):
> 
> int color1;
> const int customBGcolor = MAXCOLORS + 2;
> 
> ...
> 
> Then either
> 
> R_reset_color(customBGcolor, R, G, B);
> color1 = customBGcolor;
> 
> or (essentially)
> 
> color1 = D_translate_color (...);
> 
> happens. So now color1 is either a number on the range 1 to MAXCOLORS if the 
> color came from translate_color, or it's MAXCOLORS + 2 if a color was 
> provided and set. Later, when drawing the box, the following is done:
> 
> if(color1 > MAXCOLORS)	/* ie custom RGB color */
>     R_color(color1);
> else
>     R_standard_color(color1);
> 
> Is this because:
> 
> a.) colors and standard colors really are completely separate but both are 
> being handled using a single integer with a divided range than a struct.
> 
> b.) In the past they were different but now they are the same.
> 
> c.) Something else I'm failing to imagine.

Most of the complications arise from the fact that the display
architecture originally only supported colour-mapped displays, and
R_reset_color[s] modified the palette directly. Support for RGB
displays was added later, by providing a software palette.

The point of having a set of standard colours was to provide a common
palette so that you could overlay multiple maps in the monitor without
conflicts over palette entries.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list