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
rgb(12, 123, 240)
c = rect 10, 10, 50, 50 color c filled
rect 60, 10, 100, 50 color rgb(212,123,240) filled
Example 2: Clamping of values
rgb(-12, 1023, 240.4) ' same as rgb(0, 255, 240)
c1 = rgb(0, 255, 240)
c2 = 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
Code samples using RGB
2048.bas
2048.bas
3d block lettes.bas
3d rotating cube with message.bas
A Rubens, Peter Paul Landscape.bas
analog clock.bas
another look at trig functions.bas
aquarium v2.bas
arc_ui.bas
autumn scene.bas
balls in 3d cube.bas
balls in 3d cube.bas
balls.bas
bezier's autograph book.bas
bezierbounce.bas
blushing snowflakes.bas
bomb.bas
bonkers.bas
bopit.bas
bowling7.bas
bpf2.bas
bplus paddleball.bas
btn 21.bas
circ.bas
circle trap.bas
circles Kalide v2.bas
color chart.bas
colors1.bas
conrec-sb-v01.bas
Graphics
ARC
CHART
CIRCLE
COLOR
DRAW
DRAWPOLY
IMAGE
LINE
PAINT
PEN
PLOT
POINT
PSET
RECT
RGB
RGBF
SHOWPAGE
TEXTHEIGHT
TEXTWIDTH
TXTH
TXTW
VIEW
WINDOW
XMAX
XPOS
YMAX
YPOS
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.