PALETTECOLOR: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 17: Line 17:


<center>'''Basic's 16 Default Color Attributes (non-[[DAC]])'''</center>
<center>'''Basic's 16 Default Color Attributes (non-[[DAC]])'''</center>
{{OutputStart}}{{text|     Attribute       Description     Red   Green   Blue  32 HEX    HTML Name |Gold}}
{{OutputStart}}{{Text|     Attribute       Description     Red   Green   Blue  32 HEX    HTML Name |Gold}}
          0            Black            0      0      0    000000    Black
          0            Black            0      0      0    000000    Black
{{text|         1            Dark Blue        0      0      42    00008B    DarkBlue|#00208B}}
{{Text|         1            Dark Blue        0      0      42    00008B    DarkBlue|#00208B}}
{{text|         2            Dark Green      0    42      0    006400    DarkGreen|#006400}}
{{Text|         2            Dark Green      0    42      0    006400    DarkGreen|#006400}}
{{text|         3            Dark Cyan        0    42      42    008B8B    DarkCyan|#008B8B}}
{{Text|         3            Dark Cyan        0    42      42    008B8B    DarkCyan|#008B8B}}
{{text|         4            Dark Red        42      0      0    8B0000    DarkRed|#8B0000}}
{{Text|         4            Dark Red        42      0      0    8B0000    DarkRed|#8B0000}}
{{text|         5            Dark Magenta    42      0      42    8B008B    DarkMagenta|#8B008B}}
{{Text|         5            Dark Magenta    42      0      42    8B008B    DarkMagenta|#8B008B}}
{{text|         6            Dark Yellow    42    21      0    DAA520    GoldenRod|#DAA520}}
{{Text|         6            Dark Yellow    42    21      0    DAA520    GoldenRod|#DAA520}}
{{text|         7            Light Grey      42    42      42    D3D3D3    LightGrey|#D3D3D3}}
{{Text|         7            Light Grey      42    42      42    D3D3D3    LightGrey|#D3D3D3}}
{{text|        8            Dark Grey      21    21      21    696969    DimGray|#696969}}
{{Text|        8            Dark Grey      21    21      21    696969    DimGray|#696969}}
{{text|         9            Blue            21    21      63    0000FF    Blue|#1515FF}}
{{Text|         9            Blue            21    21      63    0000FF    Blue|#1515FF}}
{{text|        10            Green          21    63      21    15FF15    Lime|#15FF15}}
{{Text|        10            Green          21    63      21    15FF15    Lime|#15FF15}}
{{text|        11            Cyan            21    63      63    15FFFF    Cyan|#15FFFF}}
{{Text|        11            Cyan            21    63      63    15FFFF    Cyan|#15FFFF}}
{{text|        12            Red            63    21      21    FF1515    Red|#FF1515}}
{{Text|        12            Red            63    21      21    FF1515    Red|#FF1515}}
{{text|        13            Magenta        63    21      63    FF15FF    Magenta|#FF15FF}}
{{Text|        13            Magenta        63    21      63    FF15FF    Magenta|#FF15FF}}
{{text|        14            Yellow          63    63      21    FFFF00    Yellow|#FFFF00}}
{{Text|        14            Yellow          63    63      21    FFFF00    Yellow|#FFFF00}}
{{text|        15            White          63    63      63    FFFFFF    White|#FFFFFF}}
{{Text|        15            White          63    63      63    FFFFFF    White|#FFFFFF}}
{{OutputEnd}}
{{OutputEnd}}
<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]</center>
<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]</center>
::: ''Note:'' '''QB64''' 32 bit color intensity values from 0 to 255 can be found by multiplying above values by 4.
::: ''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.
''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]] modes and the [[DAC]] RGB intensity settings may be different.





Latest revision as of 22:40, 11 February 2023

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


Syntax

_PALETTECOLOR attribute%, newColor&[, destHandle&]


Description

  • The 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 newColor& is the new color value to set using _RGB32 or _RGBA32 values or using HEX$ 32 Bit Values.
  • If destHandle& is omitted, destination is assumed to be the current write page or screen surface.
  • If attribute% is outside of image or screen mode attribute range (0 to 15 or 0 to 255), an illegal function call error will occur.
  • If destHandle& does not use a palette, an illegal function call error occurs. Will not work in 24/32 bit color palette modes.
  • If destHandle& is an invalid handle value, an invalid handle error occurs.


Basic's 16 Default Color Attributes (non-DAC)
     Attribute        Description     Red   Green   Blue   32 HEX    HTML Name 
         0            Black            0      0       0    000000    Black
         1            Dark Blue        0      0      42    00008B    DarkBlue
         2            Dark Green       0     42       0    006400    DarkGreen
         3            Dark Cyan        0     42      42    008B8B    DarkCyan
         4            Dark Red        42      0       0    8B0000    DarkRed
         5            Dark Magenta    42      0      42    8B008B    DarkMagenta
         6            Dark Yellow     42     21       0    DAA520    GoldenRod
         7            Light Grey      42     42      42    D3D3D3    LightGrey
         8            Dark Grey       21     21      21    696969    DimGray
         9            Blue            21     21      63    0000FF    Blue
        10            Green           21     63      21    15FF15    Lime
        11            Cyan            21     63      63    15FFFF    Cyan
        12            Red             63     21      21    FF1515    Red
        13            Magenta         63     21      63    FF15FF    Magenta
        14            Yellow          63     63      21    FFFF00    Yellow
        15            White           63     63      63    FFFFFF    White
HTML Color Table Values and Names or Other RGB colors
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 modes and the DAC RGB intensity settings may be different.


Examples

Example: Creating custom background colors in SCREEN 0 that follow the text. CLS makes entire background one color.

_PALETTECOLOR 1, _RGB32(255, 255, 255) ' white.
_PALETTECOLOR 2, _RGB32(255, 170, 170) ' lighter red.
_PALETTECOLOR 3, _RGB32(255, 85, 85) ' light red.
_PALETTECOLOR 4, _RGB32(255, 0, 0) ' red.
_PALETTECOLOR 5, _RGB32(170, 0, 0) ' dark red.
_PALETTECOLOR 6, _RGB32(85, 0, 0) ' darker red.

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

COLOR 1, 6: PRINT "white on darker red"
COLOR 2, 6: PRINT "ligher red on darker red"
Note: _PALETTECOLOR expects LONG _RGB32 or _RGBA32 32 bit color values, not _RGB or _RGBA palette attribute values.


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link