Shiny Language Reference

Language Reference > Basic Language


rgb

int rgb(int Red, int Green, int Blue);

 
 

Creates an RGB value packed into an integer

RGB takes 3 individual red, green and blue components and packs them into a single integer. Many other Shiny statements and functions require that a colour is specified as a single integer, the RGB statement is provided for ease of use.

Although mostly drawing related this statement is considered a basic language statement as it can be used for many other purposes, for example to pack up a colour value to a single integer before writing it to the registry.

This statement is equivalent to the Visual Basic RGB function, or the Visual C++ RGB macro. The resulting value is stored internally as an integer but may be converted to a DWORD for bitwise operations using implicit type conversion.

For other samples refer to SETPENCOL and DRAWRECT.

 

Parameters

Red

The amount of red in this colour, on a scale of 0 to 255 where 0 is no red and 255 is maximum red.

Green

The amount of green in this colour, on a scale of 0 to 255 where 0 is no green and 255 is maximum green.

Blue

The amount of blue in this colour, on a scale of 0 to 255 where 0 is no blue and 255 is maximum blue.

 

Return Value

The colour as specified by the Red, Green and Blue values, packed into a single integer.

 

Example Code

// Create the colour green
int iGreen = RGB(0, 255, 0);