Skip to end of metadata
Go to start of metadata

Abstract:

This project was very similar and different at the same time from project 7.  In both projects, I needed to use lsystem and turtle_interpreter to draw different shapes of trees.  The difference was that I created my own lsystem and turtle_interpreter classes for this project to draw my L-systems.  As the project instructions mentioned, the arrangement.py and growth.py, which drew the required images, did not need to import turtle modules because they used the classes I created.  Thus, I had more flexibility? to draw a scene with my L-systems.

Solutions to Tasks:

Task 1:

Following the instructions, I created additional characters to drawString() method in my turtle_interpreter class to give more variations in my L-systems.  The additional characters were as follows.  Basically, I would first add these characters to my L-system strings and then modify the drawString() method to use those characters while drawing L-systems.

Task 2:

 

My leaf was a simple shape; it is an arc with degree 150.  Because I filled it with color, it looked more like a semi-circle.  Based on the classtest.py that was given from the instructions, I modified the x0 and y0 coordinates to place the trees at different locations.  I used random package to draw systemFL and systemGL with different lengths and iterations.

 (Required Image 1)

The sun in the top left corner was added just to reduce some empty space.  I just increased the number of iteration from my previous sun.txt (project 7) to draw this sun.

Task 3:


For growth.py, I made variations of systemDL and systemEL.  For systemDL, I changed the characters within the string to alter some angles between branches and added an extra rule to draw a different shape of leaf.  I added a new character to drawString() method to draw the leaves in purple color as well.  For systemEL, I also changed the angle between branches and added a character to draw berries.  Using for loop and a list of iteration numbers, I made sure the number of iterations increased from 1 to 4.

 (Required Image 2)

I used following text files: systemDL2.txt and systemEL2.txt.

For testing, type systemEL2.txt and systemDL2.txt on command line to reproduce the above image.

Extensions:

  • Have each tree exhibit some variation by modifying aspects of how it is drawn.

As mentioned in task, I used random package to draw systemFL and systemGL trees with different lengths and number of iterations.

See the required image 1 for the effect of the randomly assigned distances and angles.

 

  • Add leaves, berries, or color to your trees by adding symbols to the rules and cases to your turtle interpreter. For each new symbol, you will need another elif case in your drawString method.

I already mentioned that I added a character 'L' to draw L.  For berry, I used character 'B' and turle.dot() to draw the shape of berry.

I set the default color of berry to red for my own conveience.  Pleae see required image 2 to see the berries.

I added following rule to systemDL2.txt to create the purple-colored leaves in required image 2.

 

  • Get fancy with required images 2 or 3. "Fancy" means using programming structures (functions, loops, conditionals, lists, or math) to make a more interesting scene. Describe what you did in your report.

As mentioned in task 3, I used a list of iteration number and for loop to draw the trees at different locations with different iterations.

I did set the angle for drawString() to a certain value to keep the shape of the trees somewhat consistent.  The purpose was to illustrate the differences that iteration numbers made.

 

  • Make more L-systems.

I created following L-system by mistake when I was trying to create a new sun L-system.  Although this does not look like sun, it looks more interesting as iteration number increases.

I used growth2.py to run the text file cool.txt.

 

  • Demonstrate that you can create other kinds of shapes (like squares, triangles, etc) by passing strings to the turtle interpreter's drawString method.

First I added additional strings 'T' and 's' so that drawString() method would draw triangles and squares given the string.

I used single.py and extension6.txt with iteration: 4, distace: 7, and angle:30 to obtain the below image.


Reflections:

All the tools to complete this project were essentially given because I created lsystem and turtle_interpreter classes during the lab.  With the classes, I just needed to figure out how to add some new characters and how to use for loop to place my different trees to create an interesting scene.  To create my own shapes of a leaf, I only had to keep trying different rules or characters.

Sources, imported libraries, and collaborators:

I imported the classes I created myself, such as lsystem and turte_interpreter.  While creating those classes, I used turtle library.  To draw my trees in arrangement.py and growth.py, I imported random and sys packages to create more interesting scenes.  I received help from TAs.

 


 

Labels