[Up] [Previous] [Next] [Index]

# 6.3 Colors in XGAP

labelColor Models

Depending on the type of display you are using, there may be more or fewer colors available. You should write your programs always such that they work even on monochrome displays. In XGAP these differences can be read off from the so called ``color model''. The global variable `COLORS` contains all available information.

- `COLORS V`

  The variable `COLORS` contains a list of available colors. If an entry is `false` this color is not available on your screen. Possible colors are: `"black"`, `"white"`, `"lightGrey"`, `"dimGrey"`, `"red"`, `"blue"`, and `"green"`.

  The following example opens a new graphic sheet (see GraphicSheet), puts a black box (see Box) onto it and changes its color. Obviously you need a color display for this example.

      gap> sheet := GraphicSheet( "Nice Sheet", 300, 300 );
      <graphic sheet "Nice Sheet">
      gap> box := Box( sheet, 10, 10, 290, 290 );
      <box>
      gap> Recolor( box, COLORS.green );
      gap> Recolor( box, COLORS.blue );
      gap> Recolor( box, COLORS.red );
      gap> Recolor( box, COLORS.lightGrey );
      gap> Recolor( box, COLORS.dimGrey );
      gap> Close(sheet);

  The component `model` is always a string. It is `monochrome`, if the display does not support colors. It is `gray` if we only have gray shades and `colorX` if we have colors. The ``X'' can be either 3 or 5, depending on how many colors are available.

  [Up] [Previous] [Next] [Index]