Re: Colour Scaling Control

Hi all,

Perhaps Bill forgot to say (as it has already been pointed out in the
Tutorial ;-) that colour components vary from 0.0 to 1.0.

> 
> Map colors like this:
> 
>   int TABLE_SIZE = 256; // may be whatever you want
>   ScalarMap rgbMap = new ScalarMap(yourRealType, Display.RGB);
>   display.addMap(rgbMap):
>   rgbMap.setRange(lowValueOfRange, hiValueOfRange);
>   ColorControl rgbControl = (ColorControl) rgbMap.getControl();
>   float [][] table = new float[3][TABLE_SIZE];
>   for (int i=0; i<TABLE_SIZE; i++) {
>     table[0][i] = // red for i-th value
>     table[1][i] = // green for i-th value
>     table[2][i] = // blue for i-th value
>   }
>   rgbControl.setTable(table);
> 

So an application of the above is a colour table varying from green to
red (blue is always zero):
    
    int len = 256;
    float[][] table = new float[3][len];
    
    for (int i=0; i<len; i++) {
      float a = ((float) i) / (float) (len-1);
          table[0][i] =  a;
          table[1][i] = 1.0f - a;
          table[2][i] = 0.0f;
    }
  
Red component increases linearly and green component decreases linearly.
Hope my hint helps...

Yours,

Ugo