★ CODING ★ LISTINGS ★ KALEIDOSCOPE (COMPUTING WITH THE AMSTRAD) ★ |
Kaleidoscope (Computing with the Amstrad) | Coding Listings |
MANY of the best computer graphics programs seem to originate from traditional visual toys, and Kaleidoscope is no exception. In the original, one of several sectors contains coloured pieces of tinsel cut in various shapes -triangles, rectangles, crescents and so on. Shaking the instrument causes these to form a random pattern in the sector. When you look through the eyepiece, -mirror reflections in the remaining sectors show a pleasing symmetrical image which you can change as often as you like. To simulate the coloured tinsel shapes, the program uses a series of different sized rectangles in a variety of colours. The length to width ratio of these rectangles varies randomly and they are drawn initally in one sector. (Sector B shown in Figure I.) Almost instantaneously each shape is repeated in the other seven sectors using machine code. The result is effectively to mirror the initial pattern about the dividing lines between the sectors centered about the graphics origin - the middle of the screen. For those who like to experiment the following information may be of use: In line 80 the number 7 restricts the size of the largest block allowed into the pattern while the values 6 and 2 determine the minimum size and length to width ratio respectively. Keep the latter at 2 or more because under certain conditions the parameters passed to the machine code can have weird effects. The factor 0.3 in line 90 determines approximately the percentage of background black appearing in the display. The machine code routine checks that exactly four parameters have v been received from Basic. Plotting a single pixel uses rom call &BBEA and each pixel is plotted 8 times - once in each sector. When one row of dots is complete, according to parameter b%, other rows of similar length are repeated underneath from parameter a%. The very first pixel to be plotted takes its position from the variables x% and y%. Kaleidoscope runs on all CPC Amstrads. The patterns produced will show on a green screen but to get the best effects colour is essential.
|