In project 7, I used turtle library again to draw certain different shapes. However, the approach to drawing the shapes was very different from the previous projects that used turtle library. The following were the key differences: 1) I used L-system, which enabled me to draw an organized yet complex graphics/images without long turtle commands and 2) I used list and indexes to contain and manipulate information of different L-systems. Essentially, the idea of using list was recycled from the project 5. I think list is a good way of using different L-systems if one is attempting to assign different parameters to the systems such as color, thickness, scale, etc.
Solutions to tasks:
First of all, I assigned different values to the indexes that I used to draw different L-systems.
. The following list shows the actual values I assigned to those indexes.
How do I actually use this list information to draw L-systems? I just have to assign more parameters to the drawString() function and modify the function like below.
My abstract image had three L-systems that drew tree, sun, and snow. Below is the image.
I wrote my own tree L-system based on systemB.txt; snow and sun L-systems were based on the example that was given during the lecture by professor Skrien.
For task 2, I created two separate functions that drew the grid and a set of 9 trees, respectively. Although I was able to draw a 3x3 grid, I could not figure out how to use double for loop to do so. The set of 9 trees each had specific x and y coordinates so that they would be located inside each grid. Below is the image.
This image is actually one of my extensions but it does what task 2 asks me to do. From the left to right, the number of iterations increases by 1. From the top to bottom, the angle of the L-system changed from 22 to 46 and from 46 to 60.
For extension, I simply assigned different colors to each column to represent the shift of season from summer to fall (green to brown) and from fall to winter (brown to white).
For the scene task, I simply drew a set of 10 trees at different locations a sun in the right top corner. The method I used to the two L-systems was different from the previous tasks. Rather than using the list, I simply assigned a set value to some of the parameters and multiple values to other parameters that I wanted to change. The reason was that I wanted to draw a set of 10 trees by moving a certain amount every time. Thus, I used for loop to draw the trees rather than creating additional sublists inside the big list. I am not sure which is more effective. Below is the image of my scene.
. I created a different L-system draw the trees in this scene.
- Import one of your scenes from project 2 or 3 and add trees or fractal shapes to them. It's all turtle graphics, after all.
As the instruction said, incorporating L-system to my complex scenes from project 3 was easy. It was essentially copy and paste. The problem I faced was the there were so many turtle.goto() commands that I needed to make sure turtle.pen is up/down at right moments. Below is the image of my extension.
- Make task 2 more interesting by adding additional elements to the image that also change across the grid. For example, make the trees move from summer to fall to winter along the horizontal or vertical axis.
This is the extension I showed at the task 2, grid. The way to add additional elements to the image is to add a parameter to the drawString() function.
- Create an L-system of your own that draws something interesting. Start by editing existing L-systems either from the lab or from the Algorithmic Botany Plants book.
I created two L-systems based on the existing ones from the lab and the Algorithmic Botany Plants book. Below are the images.
sun1: , snow2; .
- Add leaves, berries, or color to your trees by adding new alphabet symbols to the rules and cases to your turtle_interpreter. For each new symbol you use in a rule, you will need another elif case in your drawString function.
This extension was quite simple. As the instruction said, I just needed to create a new symbol in a rule, call elif case in drawString() function. Because I wanted to berries, my new symbol was B. For every B in characters, I used turtle.dot(), which would look like berries. Below is the image.
Sources, imported libraries, and collaborators: