The purpose of this project was to become familiar with L-systems and writing code for fractal shapes. In order to do this we created a scene that consisted of elements from turtle graphic and fractal shapes. The first task was to create an abstract image using L-systems. The image included three different L-systems; I used systems A1, A2, and AB. I added color by inserting a variable in the L-system and using elif statements that assigned the pen to a specific color based on the variable. Here is a picture of my solution to task 1. (In the image the circular shape is in red, but in my code the color actually is dark blue because I changed it for my scene.)
Required Image 1
The second task was to create a 3x3 grid with nine trees. To create this grid I used the L-system saved in the systemB.txt file. The iterations of the grid increased from 1-3 starting from the left and the angles went from 22, 46, and 60 from the top to bottom. In order to this I used a double four loop as can be seen in the following code. for x in range(-300, 300, 200): for y in range(-300, 300, 200): goto(x+10*scale,y+5*scale) it.drawString( lstrings[i], 7*scale, angles[j] ) j +=1 j = 0 i+=1
for x in range(-300, 300, 200):
for y in range(-300, 300, 200):
it.drawString( lstrings[i], 7*scale, angles[j] )
j = 0
I made the angles equal to the variable j and the lstrings equal to the variable i. Here is an image of my grid.
Required Image 2
The third and final task was to create a scene using at least two L-systems, one of which we had not previously used. For this scene, I took an L-system from page 25 of ABOP and put this in a file named systemC.txt. I also used the L-system saved in the file systemA2.txt. I put these L-systems in my outdoors2 scene from project 2 to add a lake and another tree to the scene. Here is a picture of my scene.
Required Image 3
I completed my first extension in the third task where I just called one of my scenes from project 2 and added a fractal shape (the lake) and a tree to the scene. This extension can be seen in required image 3.
For my second extension I made my abstract image function take in parameters (x,y, scale) and called the function 4 different times at different x,y locations and with a different scale value. This extension can be seen in the image below.
In order to complete this project I learned how to create L-system generated objects and how to change things such as color by manipulating code within an L-system.
List of people I worked with
TA Bilal Ahmad