{{DISPLAYTITLE:_PALETTECOLOR}}
The [[_PALETTECOLOR]] statement sets the color value of a palette entry of an image using 256 color modes or less (4 or 8 BPP).


{{PageSyntax}}
:[[_PALETTECOLOR]] {{Parameter|attribute%}}, {{Parameter|newColor&amp;}}[, {{Parameter|destHandle&amp;}}]


{{PageDescription}}
* The {{Parameter|attribute%}} is the palette index number of the color to set, ranging from 0 to 15 (4 bit) or 0 to 255 (8 bit) color modes.
* The [[LONG]] {{Parameter|newColor&amp;}} is the new color value to set using [[_RGB32]] or [[_RGBA32]] values or using [[HEX$ 32 Bit Values]].
* If {{Parameter|destHandle&amp;}} is omitted, [[_DEST|destination]] is assumed to be the current write page or screen surface.
* If {{Parameter|attribute%}} is outside of image or [[SCREEN|screen]] mode attribute range (0 to 15 or 0 to 255), an [[ERROR Codes|illegal function call]] error will occur.
* If {{Parameter|destHandle&amp;}} does not use a palette, an [[ERROR Codes|illegal function call]] error occurs. '''Will not work in 24/32 bit color palette modes.'''
* If {{Parameter|destHandle&amp;}} is an invalid handle value, an [[ERROR Codes|invalid handle]] error occurs.


&lt;center>'''Basic's 16 Default Color Attributes (non-[[DAC]])'''&lt;/center>
{{OutputStart}}{{text|     Attribute        Description     Red   Green   Blue   32 HEX    HTML Name |Gold}}
         0            Black            0      0       0    000000    Black
{{text|         1            Dark Blue        0      0      42    00008B    DarkBlue|#00208B}}   
{{text|         2            Dark Green       0     42       0    006400    DarkGreen|#006400}}  
{{text|         3            Dark Cyan        0     42      42    008B8B    DarkCyan|#008B8B}}
{{text|         4            Dark Red        42      0       0    8B0000    DarkRed|#8B0000}}
{{text|         5            Dark Magenta    42      0      42    8B008B    DarkMagenta|#8B008B}}
{{text|         6            Dark Yellow     42     21       0    DAA520    GoldenRod|#DAA520}}
{{text|         7            Light Grey      42     42      42    D3D3D3    LightGrey|#D3D3D3}}
{{text|         8            Dark Grey       21     21      21    696969    DimGray|#696969}}
{{text|         9            Blue            21     21      63    0000FF    Blue|#1515FF}}
{{text|        10            Green           21     63      21    15FF15    Lime|#15FF15}}
{{text|        11            Cyan            21     63      63    15FFFF    Cyan|#15FFFF}}
{{text|        12            Red             63     21      21    FF1515    Red|#FF1515}}
{{text|        13            Magenta         63     21      63    FF15FF    Magenta|#FF15FF}}
{{text|        14            Yellow          63     63      21    FFFF00    Yellow|#FFFF00}}
{{text|        15            White           63     63      63    FFFFFF    White|#FFFFFF}} '' ''
{{OutputEnd}}
&lt;center>[http://www.w3schools.com/html/html_colornames.asp HTML Color Table Values and Names] or [http://www.tayloredmktg.com/rgb/#OR Other RGB colors]&lt;/center>
::: ''Note:'' '''QB64''' 32 bit color intensity values from 0 to 255 can be found by multiplying above values by 4.

''Summary:'' The red, green, and blue intensity values can be changed using [[OUT]] or [[PALETTE]] statements. Some '''QBasic''' RGB color attribute values can be changed in [[DAC]] [[SCREEN (statement)|SCREEN]] modes and the [[DAC]] RGB intensity settings may be different. 


{{PageExamples}}
''Example:'' Creating custom background colors in SCREEN 0 that follow the text. [[CLS]] makes entire background one color.
{{CodeStart}}
{{Cl|_PALETTECOLOR}} 1, {{Cl|_RGB32}}(255, 255, 255) ' white.
{{Cl|_PALETTECOLOR}} 2, {{Cl|_RGB32}}(255, 170, 170) ' lighter red.
{{Cl|_PALETTECOLOR}} 3, {{Cl|_RGB32}}(255, 85, 85) ' light red.
{{Cl|_PALETTECOLOR}} 4, {{Cl|_RGB32}}(255, 0, 0) ' red.
{{Cl|_PALETTECOLOR}} 5, {{Cl|_RGB32}}(170, 0, 0) ' dark red.
{{Cl|_PALETTECOLOR}} 6, {{Cl|_RGB32}}(85, 0, 0) ' darker red.

{{Cl|COLOR}} 0, 1: {{Cl|PRINT}} "black on white."
{{Cl|COLOR}} 0, 2: {{Cl|PRINT}} "black on lighter red."
{{Cl|COLOR}} 0, 3: {{Cl|PRINT}} "black on light red."
{{Cl|COLOR}} 0, 4: {{Cl|PRINT}} "black on red."
{{Cl|COLOR}} 0, 5: {{Cl|PRINT}} "black on dark red."
{{Cl|COLOR}} 0, 6: {{Cl|PRINT}} "black on darker red. 

{{Cl|COLOR}} 1, 6: {{Cl|PRINT}} "white on darker red"
{{Cl|COLOR}} 2, 6: {{Cl|PRINT}} "ligher red on darker red" '' ''
{{CodeEnd}}

: ''Note:'' [[_PALETTECOLOR]] expects [[LONG]] [[_RGB32]] or [[_RGBA32]] 32 bit color values, not [[_RGB]] or [[_RGBA]] palette attribute values.


{{PageSeeAlso}}
* [[COLOR]], [[_RGB32]], [[_RGBA32]]
* [[_PALETTECOLOR (function)]]
* [[PALETTE]], [[OUT]], [[INP]]
* [[Images]]
* [[HEX$ 32 Bit Values]]


{{PageNavigation}}
