RGB
 
Computes a valid color value for hi/truecolor modes

Syntax

#define RGB(r,g,b) ((CUInt(r) Shl 16) Or (CUInt(g) Shl 8) Or CUInt(b) Or &hFF000000)

Usage

result = RGB(red, green, blue)

Parameters

red
red color component value
green
green color component value
blue
blue color component value

Return Value

The combined color.

Description

red, green and blue are components ranging 0-255.

The RGB function can be used to compute a valid color value for use while in hi/truecolor modes. It returns an unsigned integer in the format &hAARRGGBB, where RR, GG and BB equal the values passed to this function, in hexadecimal format. AA is the implicit alpha value and is automatically set to &hFF (opaque).

Note for Windows API programmers: The macro named RGB in the Windows references has been renamed BGR in the FB headers for Windows to avoid collisions.

Example

See Put (Graphics) example in addition.

ScreenRes 640,480,32  '32 bit color
Line(0,0)-(319,479), RGB(255,0,0) 'draws a bright red box on the left side of the window
Line(639,0)-(320,479), RGB(0,0,255) 'draws a bright blue box on the right side of the window

Sleep 'wait before exiting


Dialect Differences

  • Not available in the -lang qb dialect.

Differences from QB

  • New to FreeBASIC

See also