Homework 4

Ticker Tape Turtles

Task:

The task was to explore minimal user interface using turtle graphics as a visual aid. In the first step of the project I renamed my linear.py program into follow.py. Within this, I altered the code slightly to accept basic commands such as 'u' for up(), 'f' for forward, etc. The forward, backward, right, and left functions were all hardcoded with (10), (10), (30), and (30) respectively. The program was then passed a hardcoded string and executed a drawing using efreeman_shapes.py and the other basic drawing functions. After this, the program was modified again to run in real-time with integrated user input. The program printed a list of command options with a single character representing each respective function. The user typed one of the given characters and the program executed the given drawing command of the user's choice then the program propmped the user for another command. Should the user choose an unacceptable character, a polite error message was printed and the user was prompted again. The program was ended when the user pressed carriage return. To save the user's progress within the function, a file 'memory.txt' was opend before the promp/draw loop. All user input was then saved to 'memory.txt' as it was typed. I concluded the first part of the project by creating and saving a scene from follow.py.

The second part of the project followed the same principle of follow.py however, it was named linearC.py. This program functioned the same as follow.py yet it had one major difference: upon starting, the user is prompted to enter a filename they wish to read from. The file is then opened and the program reads a string of commands from the file, sending the string to processString. This draws an image from the string of commands saved in the file. To conclude the second part of the project, I saved the respective scene from linearC.py.

Additional User Interface and Program Functionality:

As mentioned previously, the follow.py program uses user interface in the form of single character input from the user. These command inputs are then carried out as the turtle follows the definition of the command. This entire process is looped within a while True: loop. In order to abort this loop, the user must only type a carriage return and the turtle program closes. The linearC.py program follows the same principle of using a character to represent a command and then carrying out the respective command. The major difference however, is that prior to the loop which executes the drawing, the user is prompted to enter a filename which contains a string of command characters such as 'ufffrrdsffzfftbbllff'. The loop within the program iterates a command for each individual character as it loops through the string.

Explanation of Extension:

As part of an extension, I followed the instructions for executing koch.py. Upon executing the program and then calling the resulting saved file into linearC.py, I realized the resulting image is similar to a snowflake. As an additional extension, I again modified follow.py to begin by prompting the user if they would like to read from a previously saved file. The user inputs either 'y' for yes or 'n' for no. If they select yes, the program is iterated such as in linearC.py, should the user choose no, the program is iterated as the previous version of the follow.py program.

Scene A from follow.py

Scene B from linearC.py

Scene C from koch.py and linearC.py