Project 7
Skip to end of metadata
Go to start of metadata

The task was to use L-systems to create trees, and fractals. We had to use the interpreter and l-system files to create an outdoor scene, a 3x3 grid of trees, and a page with a fractal and tree.

The scene1() function makes a fractal and a tree. This is the code used throughout the file:
lsys = lsystem.createFromFile( 'systemA.txt' )
fracstr = lsystem.buildString( lsys, 4 ) -50, 100, 0 )
interpreter.drawString( fracstr, 5, 90 )
I had to create the file, then call buildString to form the tree. Then I had to place the tree and finally use drawString to draw the tree.
Scene 1:

Unable to render embedded object: File (scene1) not found.

In the scene2() function I used a loop to build the 3x3 grid for the trees. The loop has two range functions, and I had to create lists that the loop can access to know the location and angles of the trees. The lists look like this:
xpos = [ -200, 0, 200 ]
ypos = [ 150, 0, -150 ]
angles = [ 22.5, 45, 60 ]
The loop looks like:
for row in range(3):
for col in range(3): xposcol, yposrow, 90 )
tstr = lsystem.buildString( lsys, col+1 )
interpreter.drawString( tstr, 5, anglesrow )
Scene 2:

Unable to render embedded object: File (Scene2) not found.

The final task was to make the scene3() function to make a simple outdoor scene. I used the same type of code as scene1(), but added color to the trees and also made the trees different styles with different angles.
Scene 3:

Unable to render embedded object: File (scene3) not found.

The problems I had were placing the trees and making sure they were going in the right direction and had the right orientation.

The extension I did were to add berries to the trees by adding an elif statement in my file. The berries can be seen in scene 3 on the left and right trees. The other extension I did was to create my own L-system and I created a pattern of boxes with circles connected. I experimented with making different kinds of fractals. My favorite is:

Unable to render embedded object: File (extension) not found.

By doing this project I learned how to use L-systems. I learned how to write my own L-system or to add new letters to that L-system. I learned how to build and draw the strings by importing from the interpreter file and I learned how to use loops and lists together.

  • No labels