In this section we'll look at some of the basics of pixel graphics. There are many more things you can do in Turing, but this will be enough to get you started.
The graphics screen is broken up into dots called pixels. Each one can be specified by a point (x, y) like in mathematics. The Turing graphics screen basically represents the first quadrant in the x,y-plane. This means that the lower left corner has coordinates (0, 0). Although this is different than virtually all other programming languages it makes a lot more intuitive sense.
Colours in Turing are specified by int values. They can range from 0 to the predefined constant maxcolor (or maxcolour). To see the value on your computer, just execute the statement: put maxcolour.
It is difficult to remember which number represents each colour so Turing has a number of predefined constants for colours. The following colour constants are predefined:
white | blue | green | cyan |
red | purple (magenta) | brown | black |
grey (gray) | brightblue | brightgreen | brightcyan |
brightred | brightpurple (brightmagenta) | yellow | darkgrey (darkgray) |
Here is a program you can run to see all of the available colours on your computer (Don't worry about trying to understand this program yet; it is just to show the colours):
|
Here are some of the predefined graphics procedures.
Let's look at an example using these procedures:
|
Here is what the output window will look like:
Here is an example with these new procedures:
|
|