DEFCOLOR

Purpose:

Creates or redefines a color.

Syntax:

DEFCOLOR("name", r, g, b, index)

"name"

-

Optional. A string, the name of the color.

r

-

A real. The value of the red component for the color (0.0 <= r <= 1.0).

g

-

A real. The value of the green component for the color (0.0 <= g <= 1.0).

b

-

A real. The value of the blue component for the color (0.0 <= b <= 1.0).

index

-

Optional. An integer, the index of the color. Defaults to the index of the next available color.

Returns:

An integer, the color index if successful, else -1.

Example:

defcolor("Money", 0.753, 0.863, 0.750)

wincolor(colorstr("Money"))

 

Defines a new color named Money and sets the background color of the current Window to this color. Because DEFCOLOR automatically defines a macro with the same name as the color,

 

wincolor(money)

 

produces the same result.

Example:

defcolor(0.0, 0.5, 1.0, lblue)

 

Redefines the existing color LBLUE.

Remarks:

DEFCOLOR automatically defines an integer macro with the same name as the color if the definition is successful. Spaces in the color name are replaced by _ in the macro name. For example:

 

defcolor("Dull Red", 1.0, 0.5, 0.5)

 

Defines the macro DULL_RED that can be used in any function accepting a color index. However, the string Dull Red automatically appears in the color selection dialog box.

 

DEFCOLOR also accepts RGB integer values between 0 and 255. For example:

 

defcolor("DodgerBlue", 30, 144, 255)

 

To use this form, each RGB value must be an integer between 0 and 255.

 

The COLORSTR function converts a color name into a color index.

 

See WEBCOLORS to define a set of website compatible colors.

 

Colors can also be define in the system file palette.mac.

 

See SETPMAP to create a colormap from a list of colors.

See Also:

COLORSTR

COLORTORGB

GETWCOLOR

RGBTOCOLOR

SERCOLOR

SETCOLOR

SETCOLORMAP

SETGCOLOR

SETPMAP

STRCOLOR

WEBCOLORS

WINCOLOR