Purpose
Returns an RGB color value calculated from Red, Green, Blue components. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
RGB( red, green, blue )
red is a numeric expression from 0 to 255, representing a concentration of red.
green is a numeric expression from 0 to 255, representing a concentration of green.
blue is a numeric expression from 0 to 255, representing a concentration of blue.
Return Value
Integer
Description
Some MapBasic statements allow you to specify a color as part of a pen or brush definition (for example, the Create Point statement). MapBasic pen and brush definitions require that each color be specified as a single integer value, known as an RGB value. The RGB() function lets you calculate such an RGB value.
Colors are often defined in terms of the relative concentrations of three components-the red, green and blue components. Accordingly, the RGB() function takes three parameters-red, green, and blue―each of which specifies the concentration of one of the three primary colors. Each color component should be an integer value from 0 to 255, inclusive.
The RGB value of a given color is calculated by the formula:
( red * 65536) + ( green * 256) + blue
The standard definitions file, MAPBASIC.DEF, includes Define statements for several common colors (BLACK, WHITE, RED, GREEN, BLUE, CYAN, MAGENTA, and YELLOW). If you want to specify red, you can simply use the identifier RED instead of calling RGB().
Example
The following example, the RGB value stored in the variable color will represent pure, saturated red.
Dim red,green,blue,color As Integer
red = 255
green = 0
blue = 0
color = RGB(red, green, blue)
See Also:
Brush clause, Font clause, Pen clause, Symbol clause