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 | RGBF

Edit History

RGBF

c = RGBF (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 floating point values from 0 to 1 for each of the colors. 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 = rgbf(0.047, 0.48, 0.94)
rect 10, 10,  50, 50 color c filled
rect 60, 10, 100, 50 color rgbf(0.047, 0.48, 0.94) filled

Example 2: Clamping of values

c1 = rgbf(-0.55, 2.5, 0.94)    ' same as rgbf(0, 1, 0.94)
c2 = rgbf(0, 1, 0.94)
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 1 step 0.01
    Color 15, Rgbf(c,     0,   0): At 10,   0: Print txt("1. RED");
    Color 15, Rgbf(0,     c,   0): At 10,  30: Print txt("2. GREEN");
    Color 15, Rgbf(0,     0,   c): At 10,  60: Print txt("3. BLUE");
    Color 15, Rgbf(0,     c,   c): At 10,  90: Print txt("4. CYAN");
    Color 15, Rgbf(c,     c,   0): At 10, 120: Print txt("5. YELLOW");
    Color 15, Rgbf(c,     0,   c): At 10, 150: Print txt("6. MAGENTA");
    Color 15, Rgbf(c,     c,   c): At 10, 180: Print txt("7. GRAY");
    Color 15, Rgbf(c,   c\2,   0): At 10, 210: Print txt("8. ORANGE");
    Color 15, Rgbf(c\2, c\2,   0): At 10, 240: Print txt("9. OLIVE");
    Color 15, Rgbf(c\2, c\4,   0): At 10, 270: Print txt("A. BROWN");
    Color 15, Rgbf(c,     0, c\2): At 10, 300: Print txt("B. PINK");
    Color 15, Rgbf(0,     0, c\3): At 10, 330: Print txt("C. NAVY");
    Color 15, Rgbf(c\3, c\2,   c): At 10, 360: Print txt("D. SKY");
    Delay 20
Next
Code samples using RGBF
3d rotating cube with message.bas   bezier's autograph book.bas   bezierbounce.bas   blushing snowflakes.bas   fire demo.bas   Fractal_Mandelbrot.bas   gray scale test.bas   mandelbrot explorer.bas   patterns.bas   plasma magnifico.bas   plasmajvsh.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 Thu, 20 Jul 2023 09:41:05 +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.