Turing has quite a large number of predefined procedures. We've used some already. In chapter one we used the locate and color procedures. In chapter two we used procedures to generate random numbers and for graphics (eg. drawline and drawfilloval). In this chapter we will learn how to make our own procedures that we can then use just like the predefined ones.
In chapter two we saw procedures called drawoval and drawbox. Perhaps it would have been nice if there was one called drawtriangle. Let's make one. Suppose we wanted a red triangle that had its three vertices at (100, 100), (150, 150) and (100, 200). A Turing program that would do that would look like this:
|
|
|
This procedure does have some limitations. One major one is that it will always draw a red triangle in the same place.
Later in this chapter we'll learn how to modify it so that we can draw triangles in different places
in different colours.
|