BB___COLOR

=COLOR= toc

Description
> For use with graphics windows and graphicboxes, COLOR is used to set the foreground color, which is the pen color. The color of graphics text and of drawn shapes and lines is set with COLOR. (COLOR is **NOT** used to fill drawn shapes).

> There are three graphics commands that deal with color: >> color >> backcolor >> fill

Syntax
> //Color commands are NOT case sensitive.// > Color can be specified using any one of the standard system colors or using the RGB pure color method. See colors. e.g.: > code format="lb" 'using a variable for value of color color$="darkgray" rgb$="155 30 155" code
 * 1)  - a graphics window
 * 2)  - a graphicbox
 * 1) handle.ext "color cyan"
 * 2) handle.ext "color 127 0 127"
 * 1) handle.ext "color "; color$
 * 2) handle.ext "color "; rgb$

Hints
> Color set with color commands can be changed with each new graphic command. Run this example: code format="lb" nomainwin

WindowWidth=400 WindowHeight=300

open "Change Colors Demo" for graphics as #g #g "trapclose [quit]" 'put the pen down, give it a size and place it   #g "down; size 2; place 50 50" 'set the color of first shape #g "color red" 'draw a circle #g "circle 50" 'set the color of second shape and place it   #g "color yellow; place 100 100" 'draw an ellipse with different pen color #g "color blue; ellipse 100 50" 'set the color of third shape and place it   #g "color blue; place 150 150" 'draw a box with a different pen color #g "color pink; box 50 50"

wait

[quit] close #g end code

Example
An example of the command in a graphics window. code format="lb" nomainwin

WindowWidth=400 WindowHeight=300

open "Color Demo" for graphics_nf_nsb as #g #g "trapclose [quit]"

'put pen down #g "down; place 150 150" 'set color #g "color red" 'print text and a shape #g "\HOME" #g "line 150 160 200 160" wait

[quit] close #g end code

An example of the command in a graphicbox. code format="lb" nomainwin

WindowWidth=400 WindowHeight=300

graphicbox #g.gb 2, 2, 390, 270 open "Color Demo" for graphics_nf_nsb as #g #g "trapclose [quit]"

'put pen down #g.gb "down; place 150 150" 'set color #g.gb "color red" 'print text and a shape #g.gb "\HOME" #g.gb "line 150 160 200 160" wait

[quit] close #g end code

An example combining all three color commands in a graphics window. code format="lb" nomainwin

WindowWidth=400 WindowHeight=300

open "All Color Demo" for graphics as #g #g "trapclose [quit]"

'fill window with color #g "fill cyan" 'set the pen color #g "color red" 'set the backcolor #g "backcolor yellow" 'put the pen down and place it in the center of the window #g "down; home" 'draw a filled circle #g "circlefilled 40" 'draw some text #g "place 20 20;\The cyan window color is set by FILL command." #g "\\The red text color and the red outline of the circle" #g "\is set with the COLOR command." #g "place 20 200;\The circle is filled with the BACKCOLOR yellow." #g "place 20 230;\The color behind the text is the BACKCOLOR yellow." #g "flush" 'make graphics stick wait

[quit] close #g end code

Useful Functions
code format="lb" Place a useful function using this keyword here code