BASIC Palette Statements and Functions - fvdhoef/aquarius-plus GitHub Wiki
TYPE: plusBASIC v0.15 graphics statement
FORMAT: DEF RGBLIST var$ = rgb_list
Action: Creates an RGB color list.
- var$ is a simple string variable.
- rgb_list is a series of semi-colon separated rgb_specs
Examples:
DEF RGBLIST R$ = 0,0,0;15,0,0;0,15,0;15,15,0;0,0,15;15,0,15;0,15,15;15,15,15
Creates an RGB color list consisting of the colors black, red, green, yellow, blue, magenta, cyan, and white.
DEF RGBLIST G$="000";"111";"222";"333";"444";"555";"666";"777";"888";"999";"AAA";"BBB";"CCC";"DDD";"EEE";"FFF"
Creates a grayscale RGB color list.
DEF RGBLIST C$ = "000000";"0000AA";"00AA00";"00AAAA";"AA0000";"AA00AA";"AA5500";"AAAAAA";"555555";"5555FF";"55FF55";"55FFFF";"FF5555";"FF55FF";"FFFFFF";"FFFF55"
Creates am RGB color list containing the CGA palette.
An rgb_spec is used to specify an RGB value. It may take on of the following forms:
- An rgb triplet consisting of decimal red, green, and blue value separated with commas.
-
Illegal quantity errorresults if any of the values are not in the range
-
- A string containing red, green, and blue values in one of the following formats:
- A two byte string containing a single RGB value as returned by the
GETPALETTEfunction - Three hexadecimal digits, representing the red, green, and blue values, respectively.
- Six decimal digits consisting of three two digit values for red, green, and blue.
- Only the first digit of each two digit value is significant; the second is ignored.
-
Empty string errorresults if the string has a length of 0 -
Illegal quantity errorresults if the string contains characters that are not hexadecimal digits or its length is not 3 or 6/
- A two byte string containing a single RGB value as returned by the
TYPE: plusBASIC v0.27i graphics statement
FORMAT: Append RGBLIST var$ = rgb_list
Action: As DEF RGBLIAT but appends to the RGB color list.
TYPE: plusBASIC v0.19n disk statement
FORMAT: LOAD PALETTE palette , filespec
Action: Loads palette definition from a file and writes it to the specified palette.
- palette is the palette number to be loaded (see SET PALETTE).
- filespec is a string expression containing an optional path and the full file name.
- If the file is 32 bytes long, it is assumed to be a binary palette definition as returned by
GET_PALLETE$(). - If the file is 64 bytes long. it is assumed to be hexadecimal representation of a binary palette definition.
-
File not found errorresults if the specified file does not exist. -
Overflow errorresults if the file length is not exactly 32 or 64 bytes.
Example:
LOAD PALETTE 0,"grayscale.pal"
Reads file
grayscale.paland writes contents to palette 0.
TYPE: plusBASIC v0.19n disk statement
FORMAT: SAVE PALETTE palette , filespec
Action: Saves specified palette definition to a file.
- palette is the palette number to be saved (see SET PALETTE).
- filespec is a string expression containing an optional path and the full file name.
- The resulting file is 32 bytes long and contain the binary palette definition as returned by
GET_PALLETE$().
Example:
SAVE PALETTE 2,"rgb.pal"
Writes contents of palette 2 to file
rgb.pal
TYPE: plusBASIC graphics statement
FORMAT: SET PALETTE palette TO rgb_list
Action: Sets one or more palette entries to the specified colors.
-
palette is the palette to modify (0 through 3).
- Screen 0 (text) always uses palette 0.
- Screen 1 (bitmap) always uses palette 1.
-
Illegal quantityresults if palette is not between 0 and 3.
-
rgb_list is a string of RGB values created with the
DEF RGBLISTstatement.
Example:
DEF RGBLIST W$ = 15,15,15
SET PALETTE 0 TO W$
Sets the first index of palette 0 to white, changing text screen color 0 from black to white.
DEF RGBLIST B$ = 0,0,0
SET PALETTE 0 TO B$
Sets the first index of palette 0 to black, changing text screen color 0 back to black.
DEF RGBLIST P$ = 0,0,0; 0,0,$F; 0,$F,0; 0,$F,$F; $F,0,0; $F,0,$F; $F,$F,0; $F,$F,$F
SET PALETTE 1 TO P$
Sets the first eight bitmap colors to black, blue, green, cyan, red, magenta, yellow, and white.
DEF RGBLIST G$ = 0,0,0; 1,1,1; 2,2,2; 3,3,3; 4,4,4; 5,5,5; 6,6,6; 7,7,7; 8,8,8; 9,9,9; 10,10,10; 11,11,11; 12,12,12; 13,13,13; 14,14,14; 15,15,15
SET PALETTE 0 TO G$
Sets the text screen colors to shades of gray.
FORMAT: SET PALETTE palette INDEX index TO rgb_values
Action: As above, but entries are set starting at the specified index.
Example:
SET PALETTE 0 INDEX 6 TO RGB$(15,15,15)
Sets color entry 6 of palette 0 to white, changing text color 6 from cyan to white.
DEF RGBLIST P$ = 0,0,0; 0,0,$F; 0,$F,0; 0,$F,$F; $F,0,0; $F,0,$F; $F,$F,0; $F,$F,$F
SET PALETTE 1 INDEX 8 TO P$
Sets the last eight bitmap colors to black, blue, green, cyan, red, magenta, yellow, and white.
TYPE: plusBASIC v0.19n graphics statement
FORMAT: RESET PALETTE palette
Action: Sets the specified palette to the default palette
-
palette is the palette to modify (0 through 3).
-
Illegal quantityresults if palette is not between 0 and 3.
-
plusBASIC v0.71i enhancement
FORMAT: RESET PALETTE *
Action: Sets all 4 palettes to the default palette
TYPE: plusBASIC v0.15n graphics function
FORMAT: GETPALETTE$ ( palette )
Action: Returns the RGB values in the specified palette.
- palette is a palette number in the range 0 through 3.
- Returns a 32 character binary string containing 16 RGB values.
Examples:
P$ = GETPALETTE$(P)
PRINT HEX$({P$)
Prints the contents of palette 0 as a hexadecimal string.
SET PALETTE 1 TO GETPALETT$(0)
Copies palette 0 to palette 1.
plusBASIC v0.27i enhancement_
FORMAT: GETPALETTE$ ( palette , index )
Action: Returns the RGB value of the specified palette entry.
- palette is a palette number in the range 0 through 3.
- index is a palette index in the range 0 through 15.
- Returns a 2 character binary string containing the entry's RGB value.
Examples:
E$=GETPALETTE$(0,1)
PRINT RGBDEC$(E$,' ')
Prints the red, green, and blue values, respectively, of index I of color palette P.
TYPE: plusBASIC v0.22 graphics function
FORMAT: RGB ( rgb_spec )
Action: Returns an integer representing a single RGB value.
- _rgb_spec specifies the red, green, and blue values.
Examples:
RGB(7,15,4)
Returns 2036 (aquamarine).
RGB("FFD")
Returns 4093 (beige).
RGB("A52A2A")
Returns 2594 (brown).
FORMAT: RGB ( rgb_string, delimiter )
Action: Returns an integer representing a single RGB value.
- rgb_string is a string containing decimal red, green, and blue values separated by a delimiter.
-
delimiter is a string or byte value that specifies the delimiter character.
- If the string is more than two characters long, the first character is used.
- The red, green, and blue values are each divided by 16 to create the entry.
-
Illegal quantity errorresults if any value is not in the range 0 through 255, inclusive, rgb_string does not conform to the above format, or delimiter is a number not in the range 0 through 255, inclusive.
Examples:
RGB("230,230,250",",")
Returns 3823 (lavender).
RGB("250 240 230",32)
Returns 4804 (linen).
TYPE: plusBASIC v0.22 graphics function
FORMAT: RGB$ ( rgb_spec )
Action: Returns a two character binary string representing a single RGB value.
- _rgb_spec specifies the red, green, and blue values.
Example:
RGB$(7,15,0)
Returns binary string
$"F001"(chartreuse).
RGB$("FD0")
Returns binary string
$"D00F"(gold).
RGB$("4B0082")
Returns binary string
$"0804"(indigo).
FORMAT: RGB$ ( rgb_string, delimiter )
Action: As RGB ( rgb_string, delimiter ), but returns a two byte binary string.
Example:
10 P$=0
20 FOR I=0 TO 15
30 P$=P$+RGB$(A$[I],9)
40 NEXT I
Converts array
A$()containing a tab-delimited RGB value in each element to an Aquarius+ palette inP$.
TYPE: plusBASIC v0.71f graphics function
FORMAT: RGBR ( rgb_spec )
Action: Returns an integer representing the red component of an RGB value.
- _rgb_spec specifies the red, green, and blue values.
Example:
R$=RGB$(1,2,3)
PRINT GRBR(R$)
Prints
1
TYPE: plusBASIC v0.71f graphics function
FORMAT: RGBG ( rgb_spec )
Action: Returns an integer representing the green component of an RGB value.
- _rgb_spec specifies the red, green, and blue values.
Example:
R$=RGB$(1,2,3)
PRINT GRBG(R$)
Prints
2
TYPE: plusBASIC v0.71f graphics function
FORMAT: RGBG ( rgb_spec )
Action: Returns an integer representing the blue component of an RGB value.
- _rgb_spec specifies the red, green, and blue values.
Example:
R$=RGB$(1,2,3)
PRINT GRBB(R$)
Prints
3
TYPE: plusBASIC v0.27b graphics function
FORMAT: RGBDEC$ ( rgb_val )
Action: Returns a string of comma-separated decimal numbers representing a single RGB value.
- rgb_val is a two byte binary string containing the RGB value.
- The resulting string contains the red, green, and blue values, respectively.
Examples:
R$ = RGB$(1,2,3)
PRINT RGBDEC$(R$)
Prints
1,2,3
PRINT RGBHEX$($"5604")
Prints
4,5,6
FORMAT: RGBDEC$ ( rgb_val , char )
Action: As above, but the specified character is used as the delimiter.
-
char can be either
- A number between 0 and 255
- A string, the first character of which is used.
Examples:
RGBDEC$($"8907",9)
Returns `"7\t8\t9"'.
PRINT RGBDEC$($"BC0A"," ")
Prints
170 187 204
TYPE: plusBASIC v0.27b graphics function
FORMAT: RGBHEX$ ( rgb_val )
Action: Returns a six digit string of hexadecimal numbers representing a single RGB value.
- rgb_val is a two byte binary string containing a single RGB value.
- The resulting string consists of the red, green, and blue values, each repeated twice.
Examples:
R$ = RGB$(1,2,3)
PRINT RGBHEX$(R$)
Prints
112233
PRINT RGBHEX$($"5604")
Prints
445566
FORMAT: RGBHEX$ ( rgb_val , char )
Action: As above, but the specified character is prepended to the string.
-
char can be either
- A number between 0 and 255
- A string, the first character of which is used.
Examples:
PRINT RGBHEX$($"8907",64)
Prints
@778899
PRINT RGBHEX$($"BC0A","#")
Prints
#AABBCC
| Index | RGB | Color | Index | RGB | Color |
|---|---|---|---|---|---|
| 0 | 111 | Black | 8 | CCC | Grey |
| 1 | F11 | Red | 9 | 3BB | Dark Cyan |
| 2 | 1F1 | Green | 10 | C2C | Dark Magenta |
| 3 | FF1 | Yellow | 11 | 419 | Dark Blue |
| 4 | 22E | Blue | 12 | FF7 | Light Yellow |
| 5 | F1F | Magenta | 13 | 2D4 | Dark green |
| 6 | 3CC | Cyan | 14 | B22 | Dark red |
| 7 | FFF | White | 15 | 333 | Dark grey |