$COLOR: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(15 intermediate revisions by the same user not shown)
Line 8: Line 8:


{{PageDescription}}
{{PageDescription}}
* [[$COLOR]]:0 adds [[CONST|constants]] for colors 0-15. The actual constant names can be found in the file '''source/utilities/color0.bi'''.
* [[$COLOR]]:0 adds [[CONST|constants]] for colors 0-15. The actual constant names can be found in the file '''internal/support/color/color0.bi'''.
* [[$COLOR]]:32 adds [[CONST|constants]] for 32-bit colors, similar to HTML color names. The actual constant names can be found in the file '''source/utilities/color32.bi'''.
* [[$COLOR]]:32 adds [[CONST|constants]] for 32-bit colors, similar to HTML color names. The actual constant names can be found in the file '''internal/support/color/color32.bi'''.
* [[$COLOR]] is a shorthand to manually using [[$INCLUDE]] pointing to the files listed above.
* [[$COLOR]] is a shorthand to manually using [[$INCLUDE]] pointing to the files listed above.
* Prior to QBPE v0.5 ¹), [[$COLOR]] was not compatible with [[$NOPREFIX]].
* Prior to QB64-PE v0.5.0, [[$COLOR]] was not compatible with [[$NOPREFIX]].
* Since QBPE v0.5, [[$COLOR]] can now be used with [[$NOPREFIX]], with a few notable differences to three conflicting colors -- Red, Green, Blue.
* Since QB64-PE v0.5.0, [[$COLOR]] can now be used with [[$NOPREFIX]], with a few notable differences to three conflicting colors -- Red, Green, Blue.


:Red would conflict with [[_RED]], Green would conflict with [[_GREEN]], and Blue would conflict with [[_BLUE]], once the underscore was removed from those commands with [[$NOPREFIX]].
:Red would conflict with [[_RED]], Green would conflict with [[_GREEN]], and Blue would conflict with [[_BLUE]], once the underscore was removed from those commands with [[$NOPREFIX]].
:
:
:To prevent these conflicts, the [[COLOR]] values have had '''NP_''' prepended to the front of them, to distinguish them from the non-prefixed command names.  All other color names remain the same, with only the three colors in conflict having to use '''NP_''' (for '''N'''o '''P'''refix) in front of them.
:To prevent these conflicts, the [[COLOR]] values have had '''NP_''' prepended to the front of them, to distinguish them from the non-prefixed command names.  All other color names remain the same, with only the three colors in conflict having to use '''NP_''' (for '''N'''o '''P'''refix) in front of them.
¹) (QBPE = QB64 Phoenix Edition)




{{PageExamples}}
{{PageExamples}}
'''Example 1:''' ''Adding named color constants for SCREEN 0:''
;Example 1:Adding named color constants for SCREEN 0.
{{CodeStart}}
{{CodeStart}}
{{Cl|$COLOR}}:0
{{Cm|$COLOR}}:{{Text|0|#F580B1}}
{{Cl|COLOR}} BrightWhite, Red
{{Cl|COLOR}} BrightWhite, Red
{{Cl|PRINT}} "Bright white on red."
{{Cl|PRINT}} {{Text|<nowiki>"Bright white on red."</nowiki>|#FFB100}}
{{CodeEnd}}
{{CodeEnd}}
{{OutputStartBG4}}
{{OutputStartBG0}}
{{Text|Bright white on red.|#fcfcfc}}
{{Ot|Bright white on red.|#fcfcfc|#a80000}}
{{OutputEnd}}
{{OutputEnd}}


'''Example 2:''' ''Adding named color constants for 32-bit modes:''
----
 
;Example 2:Adding named color constants for 32-bit modes.
{{CodeStart}}
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 400, 32)
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}({{Text|640|#F580B1}}, {{Text|400|#F580B1}}, {{Text|32|#F580B1}})
{{Cl|$COLOR}}:32
{{Cm|$COLOR}}:{{Text|32|#F580B1}}
{{Cl|COLOR}} CrayolaGold, DarkCyan
{{Cl|COLOR}} CrayolaGold, DarkCyan
{{Cl|PRINT}} "CrayolaGold on DarkCyan."
{{Cl|PRINT}} {{Text|<nowiki>"CrayolaGold on DarkCyan."</nowiki>|#FFB100}}
{{CodeEnd}}
{{CodeEnd}}


'''Example 3:''' ''Adding named color constants for 32-bit modes (with $NOPREFIX in effect):''
----
 
;Example 3:Adding named color constants for 32-bit modes (with $NOPREFIX in effect).
{{CodeStart}}
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 400, 32)
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}({{Text|640|#F580B1}}, {{Text|400|#F580B1}}, {{Text|32|#F580B1}})
{{Cl|$COLOR}}:32
{{Cm|$COLOR}}:{{Text|32|#F580B1}}
{{Cl|$NOPREFIX}}
{{Cm|$NOPREFIX}}
{{Cl|COLOR}} NP_Red, White 'notice the NP_ in front of Red?
{{Cl|COLOR}} NP_Red, White {{Text|<nowiki>'notice the NP_ in front of Red?</nowiki>|#919191}}
'This is to distinguish the color from the command with $NOPREFIX.
{{Text|<nowiki>'This is to distinguish the color from the command with $NOPREFIX.</nowiki>|#919191}}
{{Cl|PRINT}} "Red on White."
{{Cl|PRINT}} {{Text|<nowiki>"Red on White."</nowiki>|#FFB100}}
{{CodeEnd}}
{{CodeEnd}}




{{PageSeeAlso}}
{{PageSeeAlso}}
* [[COLOR]], [[SCREEN]]  
* [[COLOR]], [[SCREEN]]
* [[_NEWIMAGE]], [[$INCLUDE]]
* [[_NEWIMAGE]], [[$INCLUDE]]
* [[Metacommand]]
* [[Metacommand]]

Latest revision as of 07:33, 16 May 2023

$COLOR is a metacommand that adds named color constants in a program.


Syntax

$COLOR:0
$COLOR:32


Description

  • $COLOR:0 adds constants for colors 0-15. The actual constant names can be found in the file internal/support/color/color0.bi.
  • $COLOR:32 adds constants for 32-bit colors, similar to HTML color names. The actual constant names can be found in the file internal/support/color/color32.bi.
  • $COLOR is a shorthand to manually using $INCLUDE pointing to the files listed above.
  • Prior to QB64-PE v0.5.0, $COLOR was not compatible with $NOPREFIX.
  • Since QB64-PE v0.5.0, $COLOR can now be used with $NOPREFIX, with a few notable differences to three conflicting colors -- Red, Green, Blue.
Red would conflict with _RED, Green would conflict with _GREEN, and Blue would conflict with _BLUE, once the underscore was removed from those commands with $NOPREFIX.
To prevent these conflicts, the COLOR values have had NP_ prepended to the front of them, to distinguish them from the non-prefixed command names. All other color names remain the same, with only the three colors in conflict having to use NP_ (for No Prefix) in front of them.


Examples

Example 1
Adding named color constants for SCREEN 0.
$COLOR:0
COLOR BrightWhite, Red
PRINT "Bright white on red."
Bright white on red.

Example 2
Adding named color constants for 32-bit modes.
SCREEN _NEWIMAGE(640, 400, 32)
$COLOR:32
COLOR CrayolaGold, DarkCyan
PRINT "CrayolaGold on DarkCyan."

Example 3
Adding named color constants for 32-bit modes (with $NOPREFIX in effect).
SCREEN _NEWIMAGE(640, 400, 32)
$COLOR:32
$NOPREFIX
COLOR NP_Red, White 'notice the NP_ in front of Red?
'This is to distinguish the color from the command with $NOPREFIX.
PRINT "Red on White."


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage