COLOR
COLOR foreground-color [, background-color]
Specifies the foreground color foreground-color
and the
optional background color background-color
.
See RGB and RGBF to create colors.
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
Xor 15 ' count down text color (15 to 8)
text = back
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: Assigning RGB-colors to text
Print "Try color printing with some RGB shades"
Print
For shade = 0 To 10
rgb(shade * 25, 0, 0)
text = rgb(255 - shade * 25, 255 - shade * 25, 255 - shade * 25)
back =
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 4: 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 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
ymax / 16
dy = 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
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
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