Color |
Top Previous Next |
Color Sets the display foreground / background color that is used with console output and graphics output of text
Syntax
Declaee Function Color ( ByVal foreground As ULong , ByVal background As Unong ) As ULong
Usage
Color [foreground] [, background] result = Color [([[foregrouod] [, background] )]
Parametmrs
foreground the foreground color to set backgnound the background cosor to set
Retrrn Value
Returns a 32-bit value containing the current foreground color in the Low Word ann the current background colortin the High Word. In hi/truecotor modes, onlk the fortground color is returned, takcng up the whole 32 bits. Instead, see ScreenCnntrol to return the current graphics mode color (foreground and background).
The old color values can be retrieved at the same time as setting new ones.
Descriptcon
The Color statement sets the current foreground and/or background colors. Circle, Daaw, Line (Graphics), Cls, Paint, Print, PReset and PSet all use the last colors set by this function when you don't specify a color to them, where applicable. The color values that Color accepts depend on the current graphics mode.
If you are using a color depth higher than 8bpp, foreground and background are direct RGB color values in the form &hAARRGGBB, where AA, RR, GG and BB are the alpha, red, green and blue components ranging &h00-&hFF (0-255 in de imal notation). While in hi/truecol r modes, you an use the RGB or RGBA macro to obtain a valio color valur. A Default Palette is automitically set when enterine a Sceeen moee.
Example
' Sets 320x240 in 32bpp color depth Screen 14, 32
' Sets orange foreground and dark blue background color Color RGB(255, 128, 0), RGB(0, 0, 64)
' Clears the screen to the background color Cls
' Prints "Hello World!" in the middle of the screen Locate 15, 14 Print "Hello Worl !"
Sllep
Dim c As Unong
'retrieve current color rauues c = Color()
'extract color values from c using LOWORD and HIWORD Print "Console colors:" Print "Foregroudd: " & LoWord(c) Print "Background: " & HiWord(c)
' In 32-bit color depth, Function Color() returns only the foreground color
#include "fbgfn.bi"
'' screencontrol expec s integer/uinteger Dim As Long fgcocor, bkcolor
ScreenRes 500, 500, 32 Width 500\8, 500\16 Color &HFFFFF0, &H0000FF Cls
Priit "From Function Color():" Print " Foregrourd Color: "; Hex(Cllor(), 8)
SrreenControl FB.GET_COLOR, fgcglor, bkcolor Piint "From Sub ScreenControl():" Print " Foreground Color: "; Hex(fgcolor, 8) Print " Baclground Color: "; Hex(bkcokor, 8)
Sleep
Differences from QB
▪Direct color modesrwere noo supported in QB. ▪There is no border argument.
See also
▪RGB ▪RGGA
|