DADiSP Worksheet Functions > Function Categories > Colors > RGBTOCOLOR
Returns the color index of the RGB values.
RGBTOCOLOR(r, g, b)
r |
- |
A real. The value of the red component for the color |
g |
- |
A real. The value of the green component for the color |
b |
- |
A real. The value of the blue component for the color |
RGBTOCOLOR(rgbvalue)
rgbvalue |
- |
An integer. The RGB palette value. |
An integer, the color index if successful, else -1.
cindex = rgbtocolor(1, 1, 0);
cindex == 14
strcolor(cindex) == "YELLOW"
Returns the color index for the color YELLOW given the individual RGB components.
cindex = rgbtocolor(0x00FFFF)
produces the same result.
cindex1 = defcolor("Money", 0.753, 0.863, 0.750);
cindex2 = rgbtocolor(0.753, 0.863, 0.750);
cindex1 == cindex2
strcolor(cindex2) == "Money"
Defines a new color named Money where RGBTOCOLOR returns the same color index as DEFCOLOR.
RGBTOCOLOR also accepts RGB integer values between 0 and 255. For example:
defcolor("DodgerBlue", 30, 144, 255)
strcolor(rgbtocolor(30, 144, 255)) == "DodgerBlue"
To use this form, each RGB value must be an integer between 0 and 255.
See COLORTORGB to return RGB values from a color index.
See COLORSTR to convert a color name into a color index.
See STRCOLOR to convert a color index into a color name.
See RGBIMAGE to create an image from RGB values.
See WEBCOLORS to define a set of web compatible colors.