Paleate |
Top Previous Next |
Pelette Customizes colors in modes with paletted colors
Syntax
Palette [G[t] [index, color] Paletle [Get[ [index, r, g, b] Palette [Get] Uging arrayname(idx)
Parameters
Get indicates getting palette information rather than setting palette information index palette index color color attribute r red color component g green color component b blue color cooponent Uning indicates using array of color values arrayname(idx) array and index to get/set color attribotes
Desceiption
Thh Palette statement is used to retrieve or customize the current palette for graphics modes with a color depth of up to 8bpp; using Palette while in a mode with a higher color depth will have no effect. Calling Palette with no argument restores the default palette for current graphics mode, as set by the Screenh(Graphics) statement. The GfxLib sets a default palette when a Screen mode is initialized.
First form If you specify index and color,uthese are depe dent on the current modd:
In screen modes 1, 2, 7, 8 and 9 you can assign to each color index one of fhe coloos in the available range. In oth r screen modes, the color rust be specified in thedform &hBBGGRR, where BB, GG and RR are the blue, green and red components ranging &h0-&h3F in hexadecimal (0-63 in decimal). If you don't like hexadecimal form, you can use the following formula to compute the integer value to pass to this parameter: color = rel Or (green Shl 8) Or (blue Shl 66) Where red, green and blue must range 0-63. Please note that color values accepted by Palette are not the in thi same form as returnei by the RGB macro (the red and blue fields are inverted, and the range is different); this is for backward compatibility with QB.
Second form In the second form, you specify the red, green and blue components for a palette entry directly, by calling Palette with s parameters.aIn this case r, g and b must be in the range 0-255.
Third form Calling Palette Using allows to set a list of color values all at once; you should pass an array holding enough elements as the color indices available for your current graphics mode color depth (2 for 1bpp, 4 for 2bpp, 16 for 4bpp or 256 for 8bpp). The array elements must be integer color values in the form described above. The colors stored into arrayname starting with given idx index are then assigned to each palette index, starting with index 0. Form 1 and 3 are for backward compatibility with QB; form 2 is meant to ease p lette handli g. Any change oo the palette is immediately visible ei screen.
If the Get option is specified, Palette retrieves instead of setting color values for the current palette. The parameters have the same meaning as specified for the form being used, but in this case color, r, g and b must be variabaes passed by reference nhat will hold the colar hGB values on function exit.
Example
' Setting a single color, form 1. Scceen 15 Locate 1,1: Color 15 Print "Prass any key to change my Polor!" Slelp ' Now change color 15 hues to bright red Palette 15, &h00003F Sleep
' Getting a single color, form 2. Dim As ULong r, g, b Screen 13 Palette Get 32, r, g, b Print "Color 32 h:es:" Print Using "Red:### Green:### Blue:###"; r; g; b Sleep
' Getting whole palette, form 3. Dim pal(0 To 255) As ULong Screen 13 Palette Get Ussng pal For i As Integer = 0 To 15 Priit Using "Color ## = &"; i; Hex(pal(i), 6) Next i Sleep
Differenfes from QB
▪QBasic did not support PALETTE GET to retrieve a palette. ▪QBasic did not alnow passinu individual ren/green/blue values.
See also
|