In this lab, we continued to work with the shape class, trees, l-systems, the turtle interpreter file. However, we put a novel twist on it by introducing non-photorealistic rendering. This meant that we would make the pictures and shapes we created look as thought they were created with less precision rather then pinpoint precision with a computer.
Solutions to Tasks:
1&2&3 ) The first task was to create a 'jitter3' style that caused objects to be broken into 3 line segments and look as though they were constructed with minimal precision. This is shown below in figure 1. In figure 2, I set the style to 'normal' and manipulated the widths. I did this by changing the width of "terp" in the demo_line_styles.py file by using terp.width(1). I was able to do this easily, as width() was a mutator method. Similarly, as shown below in figure 4, I manipulated the dot size by mutating the dotSize value found in the TurtleInterpreter class. I did this by using the mutator method, setDotSize () to set the size from within the demo_line_styles.py file. Lastly, I used the jitter3 and jitter styles by using terp.setStyle() as i had done for changing all the styles. I used setJitter() to change the jitterSigma values when constructing the hexagons show in figures 1 and 3 below.
Figure 1: The jitter3 function called with different jitterSigma values 2,4,6,8 respectively
Figure 2: The regular hexagon object is drawn with different width values 20,5,3,and 10 respectively
Figure 3: The jitter function called with different jitterSigma values 2,4,6,8 respectively
Figure 4: The dotted function called with different dotSize values of 2,4,6, and 8
4) For this portion of the project, I decided to use my Chapel picture from project 9. The original picture is shown below in figure 5. I decided that I would like to use jitter3 for some portions of the drawing version of the chapel, and jitter for others. I first copied my code from project 9 into my new file. Because these were all shapes, I was able to use the mutator method, setStyle() to set the style of every shape to make the drawing seem non-photorealistic rendered. So for every new instance that I drew, I either called __instance__.setStyle("jitter") or __instance__.setStyle("jitter3") on it depending on what looked better when multiple trials were ran. This created the lovely image shown below in figure 6.
Figure 5: Colby Chapel from project 9
Figure 6: The non-photorealistic rendered version of the Chapel shown in figure 5.
5) For creating a L-system, I essentially started randomly adding a bunch of letters and brackets and braces. Then i began to prune the L-system by deleting stuff by making predictions. My final L-system is shown below in figure 7. The result of using this new tree l-system in lieu of the trees in the non-photorealistic rendered version of the Chapel shown in figure 8 below.
Figure 7: L-system that I created by fiddling around with letters at random
Figure 9: The result of changing the L-system used to create the trees.
1) For my first extension, I thought to create a "sketch" kind of style. I decided to do this as when im trying to draw a straight line, i usually go back and forth in small amounts to make the line as straight as possible. This is what i attempted to do in this style. I took into account the suggestion of making slight variations in color between the different lines makes the effect better. I decided to look at a color whee; and its vales to find different values of grey. However, I noticed that any shade of black was the same number for the r, g, and b values. I used this knowledge to create the small snippit of code, show in figure 10 to create the variety of grays that the line could be printed in. I also reduced the jitter sigma to make it more realistic. This sketch style is shown in figure 11 below.
Figure 11: Examples of the sketch style with different shades of grey
2) I also made the berries of the trees a random color in order to make them look more like Christmas ornaments. I did this using random.choice(), which takes in a list, from which it chooses a random one. I then simply entered in all of the possible color strings that I wanted and set the result to a variable, and passed that variable into the turtle.dot() function as the color. These multicolored Christmas ornaments are shown above on the trees in figure 9.
3)Because this project was coded well, it allowed me to create the pentagon in a jitter3 style rather than a normal style. The result of this is shown below in figure 12 when different jitterSigma are used.
Figure 12: Pentagons that are produced with a jitter3 style and different jitterSigma values.
4) I hardcoded in the files for the L-system for the tree, allowing me to make the code more efficient and cleaner when using the terminal. Previously, I had to enter in everything, including file paths and the file names. Now I simply have to call python3 colby_scene.py and it will produce the same result, allowing for easier testing.
5) I decided to create a new multirule L-system by creating an L-system as I had done before: by simply messing around with letters until I had an idea of how to prune it to my liking. This resulted in figure 14 with the L-system shown in figure 13. I created a ivy-like plant, so i decided to put that on the library because I thought it would look nice.
Figure 13: Extension L-system
Figure 14: Chapel with ivy on it rather than Christmas Trees
6) I decided to approach the gravity on the trees a different way rather than the way suggested. Rather than modifying the angle that the trees had, I modified the L-system. I created the L-system shown in figure 15, which created the following outcome in figure 16.
Figure 15: L-System for tree that creates a tree with gravity
Figure 16: Trees under effects of gravity
7) I also decided to create the Chapel with the sketch style instead of the jitter style. I really preferred this as it seemed more like a sketch to me than the jitter style. The chapel with the sketch effect is shown below in figure 17.
Figure 17: Chapel with Sketch Effect
This week, we really got to learn about utilizing polymorphism and inheritance. This lab and project stressed the importance of using mutator methods as they allow for the coder to change important states in objects. I enjoyed working with the different styles this week. One of my peers helped me debug my code during this, and I received initial instruction during lab from Dr. Bruce Maxwell.