For this project, we implemented parent and child classes, and modified our lsystems, to create unique trees, or trees that, with each iteration, had a different rule applied to a given base.
First, we changed the rules of the input lsystems so that there were many different chunks of text for each rule. This way, when the lsystem.py file read the lsystem, it chose one of the chunks randomly to apply to the base. To do this, we used a dictionary so that whenever we looked up the base (the key in the dictionary), it would randomly give us one of of the rules (the dictionary's value).
We then created a new parent class called Shape, with methods to draw the shape, and designate its angle, color, side length, and the string that drew the shape. It's draw function allowed us to choose where we would draw the shape.
We used this parent function to draw trees. Since we were using a dictionary to randomly select a rule for each lstring's base, each tree was different. Below is a picture of three different images of three different lsystems. Even though there are only 3 lsystems used, 9 distinct images are created:
We then created another image using distinct polygons repeated around a central axis. Each polygon was a child of the Shape parent class:
Next, we created a scene. This implemented both polygons and trees. A large square with a smaller grid in it made a background, while a large central square made the picture frame. An incomplete triangle served as the frame's hanger, and in the frame was a cluster of trees. Each of these shapes was a child of the Shape parent class:
Finally, we created a mosaic function. For this, I made hexagonal tiles with squares in several of them (it resembled honeycomb with misplaced squares in some of its slots. Instead of making two different functions, I made the ability to make the mosaic entirely in the tile function. The length of the sides of each hexagon was determined by the scale, and the numbers of rows and columns are parameters that can be manipulated when it's called in the file's main function:
As extensions, I made hexagonal tiles and made my lsystems specify their fillcolor (so that it could be distinct from the outline color).
This project taught me how useful inheritance can be once the parent class is made, as well as familiarized me somewhat with dictionaries.
I received help from Hieu and another girl whose name I didn't catch.