13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

IntroductionThis appendix presents a graphics program that is described in a narrativeexplanation and comments in the source text. The graphics program isfollowed by commentaries on the demonstration programs supplied withApple Pascal.By the Way: The demonstration programs included here are intended asexamples that you can run without modification while simultaneouslyproviding you with the opportunity to study the accompanying sourcetext. They are not intended to be models of the best possibleprogramming technique. With this caution in mind, use the programs aslearning tools. One of the best ways to learn might be to try introducingmodifications into one of them.An Annotated Graphics ProgramThe following demonstration program, PATTERNS, is intended to illustratesome helpful points about Apple Pascal. The program creates pleasantgraphics by drawing a triangle on the screen and then repeatedly rotating itby a few degrees and redrawing it. The points of the triangle are always onthe edge of an invisible circle of radius 95 (which fills the height of thescreen) but apart from that it is a random triangle. The angle by which it isrotated each time it is drawn is also random, though it is always between 3and 15 degrees.The color used to draw the triangle is REVERSE, which has intriguingeffects when one image is drawn over another and the lines intersect atsmall angles. Also, as the triangle is repeatedly rotated and redrawn acircular pattern is built up; but eventually the triangle gets rotated back toits original position. When this happens, each new image is exactlysuperimposed on an old one. Because of the REVERSE color, this erases theold image! When all the old images have been erased, the program clearsthe screen, generates a new triangle with a different shape, and starts allover.This repetition continues until the user signals it to halt by pressing anykey. The KEYPRESS function, in the APPLESTUFF unit, can be used tofind out whether the user has pressed a key. (KEYPRESS is described inChapter 16of Part III.)11-296Appendix 2F: Demonstration Programs

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!