1. Home
  2. Changes to Syntax for Colours

Changes to Syntax for Colours

In the 11th edition changes have been to the way that colours are specified in Genstat graphics. Unfortunately it was impossible to do this without having some effect on existing Genstat programs. Any programs that set colour attributes or used the COLOUR directive may be affected, although graphics generated by library procedures should be OK as these have all been updated. Any new programs will need to be coded differently and this will prevent them working in older versions of Genstat.

Specifying colours in Genstat 11th edition

Colour numbers are no longer references to a colour lookup table (1=black, 2=red, etc.) but are just 24-bit colour values using the generally accepted RGB encoding. For example “PEN 3; COLOUR=16711680″ will set pen 3 to red. The function RGB can be used to construct these values, for example:

PEN 4; CLINE=RGB(188;228;228)

The parameters for RGB are the red, green, and blue components in the range 0 – 255. The GRAY function generates grey values, such that GRAY(x) is equivalent to RGB(x;x;x).

Standard X11 colour names (as used in HTML) are also recognised, both as colour settings and as an argument to RGB. Thus you can set

PEN 6; CSYMBOL=’DarkOrchid’

and the function invocation RGB(‘Indigo’) returns the value 4915330. The full list of names is given in the help for the PEN directive and a visual representation of the colours can be viewed here.

In addition, the string ‘background’ will set a special value that results in a graphic item being plotted in the background colour relevant for its current position in the display.

The following benefits arise immediately from these changes:

  • Up to 16777216 colours can be used in any one plot
  • Colour specification is compatible with most other software
  • Enables display of image data using a new directive DBITMAP

Effect on existing programs

The COLOUR directive is no longer used. In other directives colour numbers between 0 and 255 are treated as RGB values, effectively all shades of blue between black and full blue.

There should be no noticeable difference in programs where graphics are drawn without reference to the colour parameters, i.e. using the defaults. Where colours are specified the effect will be to lose all or most of the colour, as the display will be drawn in very dark shades of blue that are effectively black when viewed on a PC.

Where great inconvenience results from this change you can use the SET command (option CMETHOD) to request old-style interpretation of colour numbers using a standard lookup. In this case the COLOUR directive will function as before and values in the range 0 – 255 will refer to colours defined in this way. Thus old code should run more or less as before. The new colour values and string representations will also be recognised under this setting, with the exception that values between 0 and 255 (i.e. pure shades of blue) will be treated as old-style colour numbers.

See also

  • A colour table for a list of all the available colour names
Updated on May 3, 2019

Was this article helpful?