2

A Fill-In on XIO(FILL)

titlebar.gif

Gretchen Schabtach


This tutorial article presents several interesting extensions for the XIO(FILL) program on page 54 of theAtari BASIC Reference Manual.

Your Atari readily fills line drawings of figures with color using a special application of the XIO statement. However, the example in the Atari BASIC Reference Manual(page 54) can be expanded to demonstrate the strengths and limitations of this application. A critical point about XIO filling is that filling stops when a pixel previously filled with color is encountered. Thus, interesting effects occur when the Atari is commanded to fill overlapping figures with color.

To get the most from the following short programs, begin by running the demonstration program on page 54 of the BASIC Reference Manual.Then run Program 1. Program 1 generates three rectangles, randomly positioned, with random proportions, and fills them from top to bottom and left to right with three different colors. Observe what happens when the figures overlap.

Moving line by line, from top to bottom and left to right, the fill stops when a colored pixel is encountered. Thus, when the program generates two overlapping rectangles, filling of the second rectangle stops whenever the first filled rectangle is encountered--and does not resume even if the second rectangle extends to the right beyond the first rectangle.

With a few modifications, Program 1 is not only illuminating with regard to the XIO(FILL) function, but also much more interesting. First, randomly change the colors to be used in filling. Second, generate rectangles continuously. To do this, make the following changes:

20 N = INT(RND(0)*3+1)
160 (i.e., delete)
170 GOTO 20

After you've modified the program as specified above, run it and admire the changes. Now, add a little music to your life. This is easily accomplished by adding the following statements:

81 I = INT(RND(0)*256)
82 SOUND 1,I,10,4
84 SOUND 2,255-I,10,4

Try this, and then delete line 150. This will speed things up a little and make them even more interesting.

Finally, black backgrounds can become tiresome. To randomly change the background color, type in the following:

11 REM: CHANGE BACKGROUND
12 B = INT(RND(0)*16)
13 SETCOLOR 4,B,2
166 REM: CHANGE BACKGRD SO GOTO 12
170 GOTO 12

Your final program listing should look like that shown in Program 2.

There are further simple and interesting modifications. For example, vary the constants in statements which include random number generators--those containing (RND(0)); or delete + 16 in line 10 and provide yourself with a text window in which you can write commentary on what the viewer sees; or change the characteristics of the shapes generated to be filled with color (lines 40 through 80). Your imagination will suggest other possibilities.


Program 1. XIO Example 1

Download P044L1.BAS (Saved BASIC)
Download / View P044L1.LST (Listed BASIC)

Program 2. XIO Example 2

Download P044L2.BAS (Saved BASIC)
Download / View P044L2.LST (Listed BASIC)

Return to Table of Contents | Previous Section | Next Section