Color Chooser

The Color Chooser is used to select any of Gsharp's 96 default colors.

You can display the Color Chooser dialog by clicking on the button after any resource that requires a color.

Select the required color by clicking on it and then click on OK. To keep the current color click on Cancel.

When the color choice is saved in a GSL Script a number is used. The 96 colours have numbers from 0 to 95. 0 is black, 1 is white, 2 is red, ... etc.

You can see the RGB values of these colors using:

echo(colortables.GeneralColorTable.XuNrgbValues)

GSL programmers should see the documentation of the colortables object

To find the nearest match to a desired color (r,g,b) you can use the following code:

function float FindColorMatch(float ct, float r, float g, float b)
  float cdiff, distance, best;
  cdiff = ct - (r,g,b);
  distance = sumx(transpose(abs(cdiff)));
  best = mask(1:sizex(ct),distance = min(distance));
  return best[1];
endfunction 
ct = colortables.GeneralColorTable.XuNrgbValues;
c = FindColorMatch(ct, 20,20,20);
echo("The best match is color number "+c+" with RGB value ("+
         ct[c,1]+","+ct[c,2]+","+ct[c,3]+")");

Return to Gsharp Reference Manual