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.
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.
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.
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.
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; .
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.
This week's project was difficult as usual but fun because L-system was a new concept. I think project 7 was a mix of new concept like L-system and old ones like turtle and list. I wish I could have came up with a nested for loop to created the grid because this project had many opportunities to use nested loops.
Selim's write-up gave me an idea of using list and indexes to add parameters to the L-systems. To do so, though, I needed to revisit my codes written from project 5. Professor Skrien helped me to improve my codes as well. I imported turtle, sys, and libraries I created from the lab.