Available on: d32 c128z c128 c64 vic20 atari atarixl to8 c64reu plus4 pc128op d64 mo5 cpc coco3 coco
See also: COLOR BORDER SHADES (constant) RGB
Alias: COLOUR

COLOR

The COLOR command allows you to redefine the colors used by the graphics chipset, where this is possible. "Redefinition" means assigning one of the possible colors to specific registers called "palette registers".

On some systems this is not possible at all, due to limitations of the chipset or the absence of registers: for this reason, in such cases the command is ignored. On other systems this corresponds to the modification of specific registers, to which one of the available colors is assigned. On others it is possible to assign certain shades, which therefore go beyond the number of available colors.

Where it is possible to assign a shade, the value can range from 0 to the constant SHADES. However, it may be more practical to use the RGB function, which allows you to calculate the shade starting from the color components (red, green and blue).

If compatibility with Tuned Simons' BASIC is active, the semantics of the command changes, to directly indicate some specific components through a series of syntax variants. With the three-parameter variant, you can directly set the colors of the border, background and text. With the two-parameter variant, it will be possible to indicate the border and the background. With a single parameter, it will be possible to indicate the color of the border only. There is also the format where the first parameter is omitted, in which case the second indicates the color of the text.

Note that the syntax with one or three parameters is automatically considered as pertaining to TSB.

SYNTAX

 COLOR index, shade
 COLOR border, background, foreground
 COLOR [border,][background] (if TSB is enabled)
 COLOR border
 COLOR ,foreground


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

EXAMPLE

 COLOR 0, $fff


ABBREVIATION: Cr

Join BASIC 10Liner Contest with ugBASIC!

An interesting competition is held at the beginning of each year: the BASIC 10Liner Contest. It is possible to use ugBASIC to participate in the next "BASIC10Liner" competition, in the following categories:

  • PUR-120 - A game in 10 lines of max 120 characters (w/abbrev.)
  • EXTREME-256 - A game in 10 lines of max 256 characters (w/abbrev.)
  • SCHAU - Any program in 10 lines of max 256 characters (w/abbrev.)
In order to reduce space you can use this abbreviation for this instruction:

COLOR ↔ Cr

Any problem?

If you have found a problem with this keyword, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO KEYWORDS