Project 9

Writeup:

For this week's project, we used classes to further explore the use of lsystems. To get us started, we were provided with the skeleton for the LSystem class, which had certain methods that we had to complete on our own. I created fields for the objects in the set method, and then completed the setIteration function, which simply checked to make sure the iterations were between 0 and 10. The setDistance and setAngle methods set the distance and angle fields to the given value. For the generateString method, I created a copy of the baseString,and then created for loop to find and replace the rule for each iteration. For thewrite method, I opened a file to write to, and then wrote the first four aspects of the lsystem to the file (self.baseString, self.iteration, self.angle, self.distance), each specified as a string, integer, or float. To write my rules the file, I made a for loop that searched my self.rules list and wrote the elements of my rules to the file. At the end of my file, I made a test loop to make sure everything was working as it should. Once all this was finished, I downloaded parse.py and ran the program. Here's the first image:

The fields in the LSystem object are self.baseString, self.rules, self.iteration, self.angle, self.distance. These hold the baseString, list of rules, number of iterations, degree of angle, and distance moved by the turtle, respectively.

For my final scene, I used your processString function to to draw my images, and messed around with some different lsystems to create different trees. For each instance, I assigned a new variable to my LSystem class with different strings, rules iterations, angles, and positions in the window. Here's the image - I call it "A September Drive on I-95)":

Extensions: As you can see, I made some leaves with different sizes and colors in order to make it look like a fall scene. I got the basic idea from our first lsystem project, but I made some adjustments. I also decided to include a sun, which actually resulted from a weird circular (attempt at a) tree as I was testing out different lsystems. I tightened up the circle, made all the leaves yellow with a bit of orange, and raised it along the y-axis to make it look like it was in the sky. It looks kind of like a sun, right?