Description
Calculates the long value that represents the color specified by numeric values for the red, green, and blue components of the color.
Syntax
RGB ( red, green, blue )
Argument |
Description |
---|---|
red |
The integer value of the red component of the color |
green |
The integer value of the green component of the color |
blue |
The integer value of the blue component of the color |
Return value
Long. Returns the long that represents the color created by combining the values specified in red, green, and blue. If an error occurs, RGB returns null.
Usage
The formula for combining the colors is:
Red + (256 * Green) + (65536 * Blue)
Use RGB to obtain the long value required to set the color for text and drawing objects. You can also set an object's color to the long value that represents the color. The RGB function provides an easy way to calculate that value.
Determining color components
The value of a component color is an integer between 0 and 255 that represents the amount of the component that is required to create the color you want. The lower the value, the darker the color; the higher the value, the lighter the color.
The following table lists red, green, and blue values for the 16 standard colors:
Color |
Red value |
Green value |
Blue value |
---|---|---|---|
Black |
0 |
0 |
0 |
White |
255 |
255 |
255 |
Light Gray |
192 |
192 |
192 |
Dark Gray |
128 |
128 |
128 |
Red |
255 |
0 |
0 |
Dark Red |
128 |
0 |
0 |
Green |
0 |
255 |
0 |
Dark Green |
0 |
128 |
0 |
Blue |
0 |
0 |
255 |
Dark Blue |
0 |
0 |
128 |
Magenta |
255 |
0 |
255 |
Dark Magenta |
128 |
0 |
128 |
Cyan |
0 |
255 |
255 |
Dark Cyan |
0 |
128 |
128 |
Yellow |
255 |
255 |
0 |
Brown |
128 |
128 |
0 |
Examples
This expression returns as a long 8421376, which represents dark cyan:
RGB(0,128,128)
This expression for the Background.Color property of a salary column returns a long that represents red if an employee's salary is greater than $50,000 and white if salary is less than or equal to $50,000:
If(salary>50000, RGB(255,0,0), RGB(255,255,255))
See also
Example 3: creating a row indicator
RGB in the section called “RGB” in PowerScript Reference