Ibrahim Riaz CS 151 Project 7
Skip to end of metadata
Go to start of metadata

Ibrahim Riaz Project 7

Abstract:

The purpose of this program was to delve deeper into the world of art using a new tool-fractals and L systems. To achieve this we had to create a lsystem.py file that converts strings into systems, a continual process that has its own set of grammar rules unique to each system. We then created a turtle interpreter that interprets these strings or systems into commands that can be executed in turtle. A lot of what this project boils down to is computational thinking. The coding aspect is not more than an hour but the the thought behind it takes much longer and the reason for that is that with l systems we can create intricate shapes with great ease. This interpreter is used to then create an abstract scene using multiple l systems and manipulating the order in which they are executed. We also import and store different stacks in order to create not only abstract scenes but other works as well such as a grid of trees and realistic scenes. 

Setup:

This project required significant setup. I constructed to files, a python turtle interpreter and an lsystems.py. The latter generates strings which the former translates to turtle commands. Therefore just by creating different strings, we could essentially create extremely complex images as easily as typing a sentence. That said, it took some serious thinking to understand how to achieve that sort of transferable applicability.

Task 1:

Abstract Image

For my first task, I had to create an abstract image. As a lover of nature, I decided to create a representation of the Earth inspired by Sol Lewitt, the green edges mark pastures, the blue grids mark the oceans and the tree itself emphasizes life and its continuation. The tree in the middle utilizes brackets and therefore can help us understand how useful l systems can be at mimicking natural life.

To create this scene, I had to first prepare a set of rules and a base for each of my three components. I then converted them into strings for my interpreter my using the build string function and later drew using the interpreter and drawstring() function.

 

Task 2:

Grid Image (Extension Included)

 

For my second task, I had to create 3 x 3 grid of trees using an l system that used brackets. I therefore chose systemB and using a double for loop with conditionals and variables that would grow with each iteration, I created a grid of trees with more branches/iterations as you go from left to right and a greater angle, 22, 46, 60 as you moved down in each row. 

 

As part of my extension, I first added color and then created a list of colors, mixed it up with randomization to create a unique artwork which has a branch in ever color as we can see in the right.

Task 3:

Non Abstract Scene (Extension Included) 

 

 

For my realistic scene, I chose to create a sun, add a blue background(extension) and recreate my tree from before. This time however, I add a circle option if you press 'o' to my drawstring function and create fruits on my tree. To further ramp up this extension, I not only fill in color but use the random function to go through a list and pick the best possible colors for me naturally.

Extensions:

Extension 3:



For my final extension, I combine the trees with random fruits, import functions from my previous project and add fractal trees on each of these filled shields. Each of these  bases are randomized to fit in with the theme of showcasing different aspects of earth. The addition of colors in the above mentioned photo demonstrates my point. The green symbolizes earth, the blue alludes to water and the orange refers to the sun-all important components of our natural world. 

Questions:

Follow-Up Questions: 

  1. What is your CS understanding of an interpreter?
    An interpreter is a program that translates information inputs into a different language/meaning that is more suited to our purposes. For example, a F key translates to Forward for turtle.
  2. What is an L-system (keep it brief)?
    An L-system is a grammar system that draws fractals by using mathematical algorithms. It has alphabets, rules and a base of existing alphabets upon which these rules are executed.
  3. What does it mean to loop over the characters in a string?
    A string is a list of individual characters, so a for loop goes over each alphabet/character in a string.
  4. What is the purpose of using a stack in drawString?
    Drawstring uses stack to return to the previous position for turtles heading and position. This is helpful as stack only allows access to the most recent item meaning it can be used multiple times within a function as newer information keeps replacing the old one.
  5. Can you think of a movie where you were impressed by the computer generated trees?
    Scooby Doo.

Conclusion:

This project was extremely complicated. It was my first exposure to L systems and fractals. As a core humanities student, seeing art being created in this form was absolutely wonderful. This project taught me the importance and usefulness of stacks and L systems especially in the construction of items that have geometric relationships. I also learnt the importance of being able to convert the top level design into smaller chunks of solvable code ideas.

Acknowledgements:

A list of people you worked with, including TAs and professors. Include in that list anyone whose code you may have seen, such as those of friends who have taken the course in a previous semester.

A list of any resources that you used.  This includes textbooks, lecture notes, python documentation, library documentation or forums.  If you used a specific website, please link to it.

Put the label cs151s20project# on your wiki page.

Labels
  • No labels