BB___Colors

=Colors= toc =Named Colors=

Description
> There are 17 named colors available, where Lightgray and Palegray are two names for the same color.

Syntax
> Syntax when the color value is a variable name:

Hints
> Buttonface is the default background color assigned through the Windows theme the user has selected. Buttonface is somewhat of a unique case. MSDN Library states that buttonface is the default //unshaded// color used on the faces of buttons. Since it is a system color, it can be specified as a BackgroundColor$ for windows and controls. However, changing the background color of your window will not change the color of the buttons. In JB, button faces will always be //buttonface.//

> The color variables used for GUI controls can only use named colors.

Example
code format="lb" ' list of color names data "black", "blue", "brown", "buttonface", "cyan", "darkblue", "darkcyan" data "darkgray", "darkgreen", "darkpink", "darkred", "green", "lightgray" data "palegray", "pink", "red", "white", "yellow"

' remove mainwin nomainwin

' open a graphics window without scroll bars open "Named Colors" for graphics_nsb as #m #m "trapclose [quit]"    ' trap pushing the close button of the window #m "down"                ' put the pen down #m "\"                   ' advance the pen position by one text line

' print the color names for i = 1 to 18 read Color$

#m "\  "; Color$ next

' move the data pointer back to the beginning restore

' display a box of each color for i = 1 to 18 read Color$

#m "backcolor "; Color$ #m "place 150 "; (i - 1) * 16 #m "boxfilled 100 "; (i - 1) * 16 + 17 next

' prevent the graphics from being erased #m "flush" wait

' close the window and end the program [quit] close #m end code

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

=RGB Colors=

Description
> This is a second form of specifying colors. It works with display modes greater than 256 colors. Colors are defined by mixing Red, Green and Blue. This form cannot be used to set colors for controls or GUI window backgrounds. It can only be used when specifying colors used with graphics windows and graphicboxes.

Syntax
As an example of syntax, to make the background of a graphics window a mix of green and blue, use this statement: > Syntax when the color value is a variable name:

Hints
> When working with graphics, you are not limited to the 17 Named Colors. You can create and use any color you like. > In the RGB system, color values range from 0 - 255, with 0 being the lack of a color and 255 being the maximum amount of a color. A color specified as 0 0 0 will produce black. Conversely, 255 255 255 will produce white. As an example, to produce a color that is maximum Red, specify it as 255 0 0. To produce gray, specify 127 127 127. To avoid surprises, always specify in the order of //red green blue.//

Example
code format="lb" nomainwin

open "RGB Colors" for graphics_nsb as #m #m "trapclose [quit]"    ' trap pushing the close button of the window #m "down"                ' put the pen down

'fill the window with a green-blue background color #m "fill 0 127 200"

' prevent the graphics from being erased #m "flush" wait

' close the window and end the program [quit] close #m end code

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