# Pages CS 151 Computational Thinking Fall 2012 Lab Assignment 7 Page History

## Key

• This line was added.
• This line was removed.
• Formatting was changed.
Comment: Migrated to Confluence 4.0

The first task was to create a scene with a tree and a fractal. I used a tree from the Algorithmic Beauty of Plants book and a fractal that I made myself for the scene, which was a tree planted in a tile mosaic design on the ground. I used the same basic structure for creating all of the l-system turtle shapes. First, I assigned to "lsys" lsystem.createFromFile( [then the filename of the l-system text I wanted to use] ). Then I set "str1" equal to lsystem.buildString, using "lsys" and the number of iterations I wanted as parameters. I then placed the turtle in the correct spot, with the correct heading, and used interpreter.drawString to draw the l-system shape in turtle. Here is my scene1 picture:

The next task was to create a 3x3 grid of 9 trees, increasing in number of iterations from left to right, and chaning in angle from top to bottom. To do this, I created lists xpos, ypos, and angle, into which I put the three x-values, y-values, and desired angles respectively. Then I used the same structure from task one (though using a different tree) inside two "for" loops for range 3 and 3. I then set the number of iterations in the buildString function to i+1, the x-value to xpos[i], the y-value to ypos[j], and the angle in drawString to angle[j]. The resulting image was this:

The third task was to create an outdoor scene with various sizes of trees and fractals, including at least one new l-system. I used basically the same structure as task two for this, putting in the different values of x that I wanted for the 8 trees I was drawing, leaving them all on the same y-plane, and choosing randomly from a list of three trees: the tree from task one (but with leaves and berries), the tree from task two  (with leaves), and the tree from task one reversed (also with leaves and berries). I then added, using the fractal I had created, two alien spaceships landing. The final touch was a small stream running nearby, created using just straight turtle commands. Here is the picture:

The top of the larger spaceship was off the screen, as it was coming in for a fast landing.