RGB

c = RGB (r, g, b)

Returns the RGB color code for the specified color values. r, g and b are the three color channels red, green and blue and take integer values from 0 to 255 for each of the color. Values outside that range will be clamped. The return value is a negative 24bit value to be used by the drawing functions.

See also Colors Tutorial.

Additionally see the CSS color names unit in the article section, to use all 140 standard CSS colors in an easy way.

Example 1

c = rgb(12, 123, 240)
rect 10, 10,  50, 50 color c filled
rect 60, 10, 100, 50 color rgb(212,123,240) filled

Example 2: Clamping of values

c1 = rgb(-12, 1023, 240.4)    ' same as rgb(0, 255, 240)
c2 = rgb(0, 255, 240)
rect 10, 10,  50, 50 color c1 filled
rect 60, 10, 100, 50 color c2 filled

Example 3: Fading colors

Def txt(t) = "     " + t + "     "
For c = 0 to 255
    Color 15, Rgb(c,     0,   0): At 10,   0: Print txt("1. RED");
    Color 15, Rgb(0,     c,   0): At 10,  30: Print txt("2. GREEN");
    Color 15, Rgb(0,     0,   c): At 10,  60: Print txt("3. BLUE");
    Color 15, Rgb(0,     c,   c): At 10,  90: Print txt("4. CYAN");
    Color 15, Rgb(c,     c,   0): At 10, 120: Print txt("5. YELLOW");
    Color 15, Rgb(c,     0,   c): At 10, 150: Print txt("6. MAGENTA");
    Color 15, Rgb(c,     c,   c): At 10, 180: Print txt("7. GRAY");
    Color 15, Rgb(c,   c\2,   0): At 10, 210: Print txt("8. ORANGE");
    Color 15, Rgb(c\2, c\2,   0): At 10, 240: Print txt("9. OLIVE");
    Color 15, Rgb(c\2, c\4,   0): At 10, 270: Print txt("A. BROWN");
    Color 15, Rgb(c,     0, c\2): At 10, 300: Print txt("B. PINK");
    Color 15, Rgb(0,     0, c\3): At 10, 330: Print txt("C. NAVY");
    Color 15, Rgb(c\3, c\2,   c): At 10, 360: Print txt("D. SKY");
    Delay 20
Next
Graphics
If there is insufficient information on this page and you wish learn more about RGB, please send an email to smallbasic@gmail.com. You can help to improve information about RGB by submitting a pull request, click View Source for details. Note, an offline language reference text file is also available - see the Download section.