Turbo Prolog
Turbo Prolog
Turbo Prolog
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
8 Tutorial VI:<br />
Graphics and Sound<br />
Apart from windows, the other way to brighten up your programs is to use graphics<br />
and sound. <strong>Turbo</strong> <strong>Prolog</strong> offers a choice of point- and line-based graphics or a full set of<br />
Turtle Graphics commands. Complex shapes are easy to draw with Turtle Graphicsall<br />
you have to do is guide a little pen-carrying turtle around the screen. This chapter<br />
describes these facilities in detail, gives some attractive example programs and concludes<br />
with two applications of the sound standard predicate, one of which turns your<br />
computer into a piano!<br />
TURBO PROLOG'S GRAPHICS<br />
Before using <strong>Turbo</strong> <strong>Prolog</strong>'s graphics commands, you must set up the screen in an<br />
appropriate way using the standard predicate graphics. When you've finished with<br />
graphics, the standard predicate text can be used to clear the screen and return to text<br />
mode.<br />
The graphics predicate takes the form<br />
graphics(ModeParam,Palette,Background)<br />
and initializes the screen in medium, high or extra-high resolution graphics. The possible<br />
values for ModeParam and the resulting screen formats are shown in Table 8-1. The<br />
standard IBM Color/Graphics Adapter supports modes I and 2: and modes 3,4, and 5<br />
are supported by the Enhanced Graphics Adapter. In all cases, graphics clears the<br />
screen and positions the cursor at the upper left corner.<br />
In mode I four colors can be used (colors 0, 1,2, and 3), as shown in Table 8-2. Color °<br />
is the current background color. Colors are determined by one of two palettes,<br />
selected according to whether Palette is bound to ° or I. Modes 3 and 4 offer sixteen<br />
colors, and mode 5 offers 3.<br />
Background (also an integer value) selects one of the background colors shown in Table<br />
8-3.<br />
91