RGB.SetColor

OpenTuring

RGB.SetColorPart of RGB module

Syntax   RGB.SetColor (colorNumber: int,
  redComp, greenComp, blueComp : real)

Description   The RGB.SetColor function sets the red, green and blue components of the color associated with the colorNumber parameter. The red, green and blue values must normalized to be between 0 and 1. Thus to set the color associated with the colorNumber parameter to pure red, you would call:

        RGB.SetColor (colorNumber, 1.0, 0.0, 0.0)
It is wise to use Error.Last and Error.LastMsg to check to see if the color change is successful.

Example   This program sets all the available colors to shades of red

        for clr : 0 .. maxcolor
             if not RGB.SetColor (clr, clr / maxcolor, 0, 0) then
                put "Color set failed on color number ", clr
                exit
            end if
        end for
Details   RGB.SetColour is an alternate spelling for RGB.SetColor.

Details   On monitors set to 8-bit color display (256 colors), the color change will happen almost instantaneously, and only those pixels that have matching color numbers will be changed. For example, colors 7 and 255 both represent black. Changing color 255 to red will not change pixels drawn in color 7.

On monitors set to 16, 24, or 32-bit displays (thousands or millions of colors), the color change happens very slowly, and any pixel that matches the color represented by the color number will be changed. For example, setting color 255, which is initially black, to red will change all black pixels in the run window to red. After this occurs, drawing in color 7 will produce black, while drawing in color 255 will produce red.

This behaviour is caused by the fact that in 16-bit or higher color, the pixels on the screen are stored as actual colors, rather than color numbers and thus the system has no way of distinguising between pixels drawn in different color numbers that produce identical colors.

Status   Exported qualified.

This means that you can only call the function by calling RGB.SetColor, not by calling SetColor.

See also   RGB.GetColorand RGB.AddColor.