BB___BACKCOLOR

=BACKCOLOR= toc

Description
> For use with graphics windows and graphicboxes, BACKCOLOR is used to set the color to fill shapes and the background of graphics text.

> 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 "backcolor cyan"
 * 2) handle.ext "backcolor 127 0 127"
 * 1) handle.ext "color "; color$
 * 2) handle.ext "color "; rgb$

Caution!
> There is a 'quirk' when using the command with a graphicbox control. (This does not apply when using the command in a graphics window). The behavior is such that, when a window is resized or minimized and restored, the background of the graphicbox itself will be painted with the last color specified in a backcolor statement. This happens even though you fully expect the background to have no color and have not used a command to apply a background color to the graphicbox control.

> The way to prevent this unexpected behavior from occurring is to specify a fill color for the graphicbox. To keep a neutral background, use a fill color of white or buttonface.

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 backcolor of first shape #g "backcolor red" 'draw a filled circle #g "circlefilled 50" 'set the backcolor of second shape and place it   #g "backcolor yellow; place 100 100" 'draw a filled circle with different pen color #g "color blue; circlefilled 50" 'set the backcolor of third shape and place it   #g "backcolor blue; place 150 150" 'draw a filled circle with a different pen color #g "color pink; circlefilled 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 "Backcolor Demo" for graphics as #g #g "trapclose [quit]" 'put the pen down and place it in the center of the window #g "down; home" 'set the backcolor #g "backcolor red" 'draw a filled circle #g "circlefilled 50" 'show text with red backcolor #g "place 20 200;\The circle is filled with the backcolor red." #g "place 20 230;\The color behind this text is the backcolor red." wait

[quit] close #g end code

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

WindowWidth=400 WindowHeight=300

graphicbox #g.gb 0, 0, 390, 270 open "Backcolor Demo in Graphicbox" for graphics as #g #g "trapclose [quit]" 'put the pen down and place it in the center of the window #g.gb "down; home" 'set the backcolor #g.gb "backcolor blue" 'draw a filled circle #g.gb "circlefilled 50" 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