RGB PowerScript function
Description
Calculates the long value that represents the color specified
by numeric values for the red, green, and blue components of the
color.
Syntax
1 |
<span>RGB</span> ( <span>red</span>, <span>green</span>, <span>blue</span> ) |
Argument |
Description |
---|---|
red |
The integer value of the red component |
green |
The integer value of the green component |
blue |
The integer value of the blue component |
Return Values
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 -1.
If any argument’s value is null, RGB returns null.
Usage
The formula for combining the colors is:
1 |
65536 * <span>Blue</span>+ 256 * <span>Green</span>+ <span>Red</span> |
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.
The value of a component of a color is an integer between
0 and 255 that represents the amount of the color 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.
To determine the values for the components of a color (known
as the RGB values), use the Edit Color Entry window. To access the
Edit Color Entry window, select a color in the color bar at the
bottom of the workspace and then double-click the selected color
when it displays in the first box of the color bar.
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 statement returns a long that represents black:
1 |
<span>RGB</span>(0, 0, 0) |
This statement returns a long that represents white:
1 |
<span>RGB</span>(255, 255, 255) |
These statements set the color properties of the
StaticText st_title to be green letters
on a dark magenta background:
1 |
st_title.TextColor = <span>RGB</span>(0, 255, 0) |
1 |
st_title.BackColor = <span>RGB</span>(128, 0, 128) |
See Also
-
RGB method
for DataWindows in the DataWindow Reference or the online Help