GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Download
  • News
  • Community
  • Resources
  • Language Reference
  • SmallBASIC Manual

This view

  • Original page
  • New address

GeezerVison is showing smallbasic.github.io — SmallBASIC | RGB

Edit History

RGB

c = RGB (r, g, b)

Home > Reference > Graphics

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
Code samples using RGB
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.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   crgb.bas   crop circles 1.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  
This page was last edited on Wed, 19 Jul 2023 00:04:43 +0200 | Markdown processed with pandoc 3.1.12.1
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.