# RGB()

Compatible with:
DOS Maximite CMM MM150 MM170 MM+ MMX Picromite ArmiteL4 Armite F4 ArmiteH7 Picomite CMM2

Syntax:
RGB(red, green, blue [, trans])
RGB(shortcut [, trans])

Description:
Generates an RGB true colour value.
'red', 'blue' and 'green' represent the intensity of each colour.
A value of zero represents black and 255 represents full intensity.
'shortcut' allows common colours to be specified by naming them.
The colours that can be named are white, black, blue, green, cyan, red, magenta, yellow, brown and grey or gray (USA spelling).
For example, RGB(red) or RGB(cyan).

Some later versions of MMBasic include 16 predefined colours:

    WHITE       RGB(255,  255,  255)
    YELLOW      RGB(255,  255,    0)
    LILAC       RGB(255,  128,  255)
    BROWN       RGB(255,  128,    0)
    FUCHSIA     RGB(255,  64,   255)
    RUST        RGB(255,  64,     0)
    MAGENTA     RGB(255,  0,    255)
    RED         RGB(255,  0,      0)
    CYAN        RGB(0,    255,  255)
    GREEN       RGB(0,    255,    0)
    CERULEAN    RGB(0,    128,  255)
    MIDGREEN    RGB(0,    128,    0)
    COBALT      RGB(0,    64,   255)
    MYRTLE      RGB(0,    64,     0)
    BLUE        RGB(0,    0,    255)
    BLACK       RGB(0,    0,      0)
    BROWN       RGB(255,  128,    0)
    GRAY        RGB(128,  128,  128)
    LITEGRAY    RGB(210,  210,  210)
    ORANGE      RGB(255,  165,    0)
    PINK        RGB(255,  160,  171)
    GOLD        RGB(255,  215,    0)
    SALMON      RGB(250,  128,  114)
    BEIGE       RGB(245,  245,  220)

There is also one special colour ‘notblack’, For any video mode this is the darkest colour that is not treated as black by various graphics commands.
'trans' is the level of transparency for colour depth 12. It is optional and defaults to 15 if not specified.

Note that the value returned is an integer and, if it is to be saved, the variable should be declared as an integer to retain the accuracy of the number.

MODE 1,16
CLS
BOX 100,100,300,300,5,RGB(GREEN),RGB(RED)
FOR n = 0 TO 255
LINE 105,n+120,395,n+120,1,RGB(n,n,n) ' gradient
NEXT n
DO:LOOP UNTIL INKEY$ <> ""
END

Also see COLOUR

Last edited: 03 August, 2022