Project 9 Unique Trees and Shapes 3
Skip to end of metadata
Go to start of metadata


The purpose of this project is to create a base class and many child (derived) classes that inherit the methods and fields of a base class. Moreover, the L-system classes will be modified in order to use rules that include multiple possible replacement strings and choose them randomly.


The first task is to create a file that functions to create a tree image. Within the file, it should firstly open the L-system file and save it to its table. In addition, it should set its own default values for variables distance, angle, color and iterations. 

There should be a draw function that take advantage of the draw function from the shapes library. 

The whole functionality of this file will be closely similar to the old project files that incorporates drawing functions of images (eg Project 7 and Project 8). However for this case, we use the class method, which uses shapes.Shape as the object or the base class, and Tree as the sub-class.

After creating the Tree class, I created a test function that uses the class Tree to grab the structure of the image and then draw it.

This is the result of the test:

The next task is to create new shapes other than squares and triangles. And, one of them should be filled with a color. 

For this task, I created a pentagon, hexagon, heptagon, octagon, and a nonagon. I created two functions for each - one filled with color and the other doesn't. It's fairly easy to make all of these shapes. By just adding 'F-' s to the string and take into account the exterior angles of each shapes, I should create all of the images. For filling the shapes, I just incorporated { } within each quotations of the string.

To make my result interesting, I created a scene instead of just throwing in shapes in the canvas.

This is the result for task 2:

The third task is fairly similar to what I did with the second task, but this time I have to incorporate tree images to my scene. The theme of the scene is indoor scene. 

In order to create images, I firstly created a new file. Each images in the scene will be placed in variables which calls out the shape functions from the shapes library. However for the tree, I should call it out from the tree library. After creating the variables, I just inputed values to the arguments which should create the image I want.

Here is the result of the indoor scene:

The last task is fairly tricky because I have to create an interesting tile design and make a mosaic out of it. So, I firstly make an attempt to create a tile masterpiece by using some of the shapes I created from the shapes library. The base tile should be square for this case to make it easier to fit in another tile right beside it. Designing the tile is easy, it all just placing the shapes I wanted inside a square and add colors to it. Creating the mosaic, I use a for loop function and place each tile right beside and above each other.

Here is the result for this task:


One of my extensions is to create another mosaic. However, instead of square tiles, I use hexagon shaped tiles.

I searched through google for some inspiration and here is what I got:

The other extension I did is very similar to the last. However, I incorporated the last tile to a new tile and use all three tiles as part of the mosaic.

Here is the most awesome wallpaper you'll ever have!!!


It's very interesting how I can use a new method to draw L-systems. And for this one, I think it's more organized because it is set as base class and child classes. I feel more comfortable using this because I can easily keep track which file and functions I can edit.

Helper: Yavor DEKov