[GRASS-dev] inverted color scales

Glynn Clements glynn at gclements.plus.com
Tue Jul 3 09:07:36 EDT 2007


Hamish wrote:


> > > What do you guys think of a flag in r.colors to apply an
> > > > _inverted_ color scale?
> > >
> > > Sounds really usefull to me.
> 
> I've wanted this for a long time too.
> 
> 
> Glynn:
> > Sounds really trivial to implement, too.
> > 
> > "struct Colors" already has an "invert" field, which can be inverted
> > with G_invert_colors().
> >
> > AFAICT, you just need e.g.:
> > 
> >     flag.n = G_define_flag();
> >     flag.n->key = 'n';  
> >     flag.n->description = _("Invert colors");
> > 
> > 	...
> > 
> >     if (flag.n->answer)
> >     {
> > 	G_invert_colors(&colors);
> [//] 	colors = colors_tmp;

Nope; unlike the other transformations, G_invert_colors() operates
"in-place" (it simply inverts the "invert" flag in the structure).

In the above, colors_tmp essentially contains garbage; it may not have
even been initialised.

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




More information about the grass-dev mailing list