Difference between revisions of "Set.text.attribute"
(Created page with "The '''set.text.attribute''' command sets the foreground and background color for the display commands. == Syntax == set.text.attribute(byt FG, byt BG)...") |
|||
Line 13: | Line 13: | ||
On the [[Hercules Graphics Card (HGC)]] display, there are only two colors available (black and white). When displaying text (on either screen) if the set foreground value is less than or equal to the set background value, AGI draws black text on a white background, otherwise it draws white text on black background. | On the [[Hercules Graphics Card (HGC)]] display, there are only two colors available (black and white). When displaying text (on either screen) if the set foreground value is less than or equal to the set background value, AGI draws black text on a white background, otherwise it draws white text on black background. | ||
− | The text screen on a Color Graphics Adapter (CGA) display supports sixteen colors, so it will show all combinations of background and foreground color just like Enhanced Graphics Adapter displays. On the graphics screen, CGA only has four colors, so AGI uses a table to choose foreground text colors when the background is black (if background is not black, foreground | + | The text screen on a Color Graphics Adapter (CGA) display supports sixteen colors, so it will show all combinations of background and foreground color just like Enhanced Graphics Adapter displays. On the graphics screen, CGA only has four colors, so AGI uses a table to choose foreground text colors when the background is black (if background is not black, AGI uses black foreground on white background, same as EGA displays): |
{| class="wikitable" | {| class="wikitable" |
Latest revision as of 20:53, 21 April 2019
The set.text.attribute command sets the foreground and background color for the display commands.
Syntax
set.text.attribute(byt FG, byt BG);
Remarks
This command sets the foreground and background colors used by AGI to display text with the display or display.v commands to FG and BG respectively. The input line also uses the foreground and background colors set by this command. The default foreground color is white, and the default background color is black for both the graphics screen and the text screen.
When the text screen is active, both the background color and the foreground color are displayed according to the values set by the set.text.attribute command. On the graphics screen, AGI limits the background color to black or white. If the background color is is black, AGI draws text using the set values for background and foreground. If the background color is any value other than black, AGI uses white as the background, and draws text with black foreground (ignoring the set foreground value).
On the Hercules Graphics Card (HGC) display, there are only two colors available (black and white). When displaying text (on either screen) if the set foreground value is less than or equal to the set background value, AGI draws black text on a white background, otherwise it draws white text on black background.
The text screen on a Color Graphics Adapter (CGA) display supports sixteen colors, so it will show all combinations of background and foreground color just like Enhanced Graphics Adapter displays. On the graphics screen, CGA only has four colors, so AGI uses a table to choose foreground text colors when the background is black (if background is not black, AGI uses black foreground on white background, same as EGA displays):
Foreground Color |
CGA-0 | CGA-1 |
---|---|---|
0 (black) | black | black |
1 (blue) | green | cyan |
2 (green) | green | cyan |
3 (cyan) | green | cyan |
4 (red) | red | magenta |
5 (magenta) | red | magenta |
6 (brown) | red | magenta |
7 (light gray) | brown | white |
8 (dark gray) | brown | white |
9 (light blue) | green | cyan |
10 (light green) | green | cyan |
11 (light cyan) | red | magenta |
12 (light red) | red | magenta |
13 (light magenta) | red | magenta |
14 (yellow) | red | magenta |
15 (white) | brown | white |
Using values for FG and BG greater than 15 will not cause AGI to crash, but may cause unexpected results. AGI uses only the lower nibble (four least significant bits) of each number to determine the actual colors to display. Internally, AGI combines the FG and BG values into a single 8 bit number that is used by the text drawing functions. Because of the way the numbers are combined, it is actually possible to draw black text on non-black backgrounds on the graphics screen. If FG is greater than 128 and BG is zero, AGI will use the higher nibble (upper four bits) of FG as the background color, and calls to display and display.v will draw black text on colored background. Using the text.screen command when this is the case will also clear the text screen to the 'hacked' foreground color.
Possible Errors
None.
Example
<syntaxhighlight lang="agi"> text.screen(); set.text.attribute(1, 14); display(5, 5, "message text"); [ this will display blue text on a yellow background graphics(); display(5, 5, "message text"); [ on graphics screen this will be black text on white background </syntaxhighlight>
Technical Information
Required Interpreter Version: | Available in all AGI versions. |
Byte-Code Value: | 109 (0x6D hex) |