For this assignment, our main task was to create a museum scene that would contain our previous "coastal Maine" scene. We incorporated loops and conditionals into our code to create the shapes in the scene.
For task 1, I added a fill and a color argument to my block function to enable the choice to be filled or not and the color to be chosen each time the function is called. Before the block was drawn within each function, I put code that would have the conditional "if fill==True:" to check if the fill is wanted or not each time the function was called, and the same was done for which color the function should be.
if fill==True: --Checks that the argument is true for the function, meaning the shape should be filled.
turtle.fill(True) -- turns on the fill function of the turtle.
turtle.color(color) -- chooses the color of the fill, which is whatever color the user put for the "color" argument.
The same basic technique was used for tasks 2 and 3.
For task 4, I took the code to make my coastal Maine scene and converted it to an adjustable picture by following the scaling rules, meaning it could be at any location at any size. I first had to define the entire function, which called the individual parts of the scene, using x,y, and scale parameters. Then I had to make each individual object's chosen parameters scalable by multiplying their scales, for example, by the scale of the entire scene, or their coordinates by the scale plus the initial coordinates of the scene itself.
Next, I made a "taskI" file for task 5. This picture, above, was made by calling the "myscene" function in the better_shapelib.py file. The components were imported from the shapelib.py file, and the size and coordinates of the entire scene could be controlled by giving the function three arguments. The coordinates and size of the entire scene had to be incorporated into the individual components' own coordinates and sizes. I called upon the function three times with different inputs each time in order to make this turtle graphics drawing.
For task 6, I created a museum scene in a taskII.py file. I made it using my block and triangle functions, and colored it by calling the better_shapelib.py shapes while filling in their arguments for color. I tried to use different colors to create the illusion of shadow and to make it more obvious that the scene was a museum. I put my coastal Maine scene into this scene as a painting by calling the myscene function from better_shapelib.py according to the arguments for coordinates and size. I eventually found a spot and size that made it look like the old scene was a painting in the new scene. The picture is below.
For task 7, I edited my museum scene by giving it a user-input parameter: whether the painting is sparkling or not, and how many sparkles it has. The command line argument checks if the user has input anything after calling the program in the terminal through the following code:
for i in range (N):
If the user has, then there will be as many stars as what the user wrote after calling the program. If not, nothing will happen. Images showing 20 vs. 5 stars are pictured below.
I undertook extensions 3 and 1. As one can see, one of them (extension 3) contains the scene within the scene within the scene. I did this by making the scene normally at first, then placing a smaller-scaled version of it into where the picture would be, and then again placing another smaller scene into that scene. I had to call the function titled "adjustablescene" each time I wanted to do add another layer of encapsulation into the scene, which had the parameters (x,y) and scale. The other extension, extension 1, had the museum scene with both coastal Maine scenes located inside of it, both in their own picture frames. For this, I had to change a lot of the code, including getting rid of all the calls to the adjustablescene function that was used for extension 3. I made a frame for each scene, one being called "scene1pic" and the other being called "scene2pic". Each needed to be adjustable according to, again, arguments for coordinates and scale, which needed to be applied to each object's (x,y) location as well as scale by using the aforementioned methods.
In this project, I learned how to have a program's top level of code only execute by using a conditional statement to check if the main code was being called. I also learned how to scale every component of a scene according to the entire scene's scales, defined by its arguments. Lastly, I learned how to let command line arguments affect the appearance of my scenes.
Note: I worked alone on this project