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

Edit History

COLOR

COLOR foreground-color [, background-color]

Home > Reference > Graphics

Specifies the foreground color foreground-color and the optional background color background-color.

Color can be either an index from the build in color palette (see table) or the return value of the commands RGB and RGBF.

Index Color
0 █ black
1 █ blue
2 █ green
3 █ cyan
4 █ red
5 █ magenta
6 █ yellow
7 █ white
8 █ gray
9 █ bright blue
10 █ bright green
11 █ bright cyan
12 █ bright red
13 █ bright magenta
14 █ bright yellow
15 █ bright white

Example 1

color 14, 1
print "Yellow text on blue background"

Example 2: Assigning SmallBASIC standard colors to text

For back = 0 To 7 Do
  text = back Xor 15 ' count down text color (15 to 8)
  
  Color text, back
  Print Using " FG and BG COLOR: ##, ## "; text, back;
  
  Color back, text ' reverse colors
  Print Using " FG and BG COLOR: ##, ## "; back, text
Next

Example 3: Using RGB and RGBF to draw a magenta filled rectangle with white boarder

color rgb(255, 67, 133)
rect 10, 10, 100, 100 filled  ' filling always with foreground color

color rgbf(1, 1, 1)
rect 10, 10, 100, 100

Example 4: Assigning RGB-colors to text

Print "Try color printing with some RGB shades"
Print
For shade = 0 To 10
  text = rgb(shade * 25, 0, 0)
  back = rgb(255 - shade * 25, 255 - shade * 25, 255 - shade * 25)
  
  Color text, back
  
  Print "Here is black to red on white to black "; shade * 25; ","; 255 - 25 * shade
  
  Color back, text ' reverse colors
  
  Print "Here is reverse white to black on black to red."
  print
Next

Example 5: Chart of the 16 SmallBASIC standard colors and their numbers

' Color chart of the 16 SmallBASIC standard colors
' for 0 = black to 15 = bright white
dy = ymax / 16
for i = 0 to 15
  rect 0, i * dy, xmax, i * dy + dy, i filled
  at 0, i * dy : print i;
next

Example 6

You may include “color_const.bas” file in another file to make your code more clear.

' demo - add these lines to another BAS file:
' ------------------------------------------
'  Include "color_const.bas" ' actuall filename must be lower case for Linux.
'
'  Circle 200, 200, 50, 1, YELLOW FILLED
'  Color BRIGHT_MAGENTA, BLUE: ? "Bright Magenta on Blue"
' ------------------------------------------
' color_const.bas - COLOR values for characters and pixels:
Const BLACK           = 0
Const BLUE            = 1
Const GREEN           = 2
Const CYAN            = 3
Const RED             = 4
Const MAGENTA         = 5
Const BROWN           = 6
Const WHITE           = 7
Const GRAY            = 8
Const BRIGHT_BLUE     = 9
Const BRIGHT_GREEN    = 10
Const BRIGHT_CYAN     = 11
Const BRIGHT_RED      = 12
Const BRIGHT_MAGENTA  = 13
Const YELLOW          = 14
Const BRIGHT_WHITE    = 15
Code samples using COLOR
100lines.bas   2048.bas   3d block lettes.bas   3d rotating cube with message.bas   3d wire cube v1.bas   3d_palmx.bas   3d_torus.bas   3dtorus.bas   A Rubens, Peter Paul Landscape.bas   amortig.bas   analog clock.bas   anball 1.0.bas   angel feather.bas   another look at trig functions.bas   aquarium v2.bas   arc_ui.bas   B+B.bas   Ball.bas   balls in 3d cube.bas   bb2fork smurf.bas   bezier's autograph book.bas   bezier_pen.bas   bezierbounce.bas   biorythms.bas   blackbox.bas   Blackbox.bas   blushing snowflakes.bas   bmpreal.bas   boing.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, 8 May 2025 22:57:28 +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.