Sarah Hirsch's Week Two Writeup

A description of the task

For this assignment we had to create a building by creating a building function in python. I began by creating the exterior outline of my building. I began with the first floor, which was a rectangle. I then made the second floor, which was a smaller rectangle on top of the rectangle that I had already made. All the sides of all of my rectangles were in a form of dx. Here is an example:

forward(dx) right(90) forward(dx/2) right(90) forward(dx) right(90) forward(dx/2) right(90)

I made the lengths in form of dx so that when I eventually created my function I would have only one argument, dx. In my function I also included color and the location of the building. I did the same thing for the third floor of my building. After I had made the outline of my building, I made the building a function, called building. I put all of the aspects of my building that I had created (the three floors) into that function. After making the exterior of the building into a function, I made windows. I did this by creating a square function, called square. The sides of the square were also in the form of dx. I then placed that square function within my building function. I then imported my cityshapes file into a new BBEdit file, called scene1, so that I could make multiple buildings varying in size and in color in one scene. It varied the size and color by changing the value of dx and the values of the colors. I varied their locations by varying x0, and y0. This was my first image. I did the same thing when I made my second image, but I made more buildings in this image and introduced a new building, with the function called building2, and a tree, with the function called tree. These two additional functions were defined in the cityshapes file as well. This made it easy for me to use them because I only had to import cityshapes. Once I had imported cityshapes I could use all of my functions, building, building2, and tree. I then captured these scenes and put them on the webpage below.

Parameters

The parameter that I used to place the location on the screen was x0 and y0. The color of the building was determined by the parameters red, green, and blue. The scale of the building was determined by the length of the sides of each part of my building. This parameter was dx. Such as telling the turtle to go forward(dx) for one side and then for another side I would write forward(dx/2). By using this method I was able to create smaller rectangles on top of bigger rectangle to create a building. I also varied the location of the origin of the turtle by varying the values x0 and y0. Additionally, I varied the colors of my building by varying the values of red, green and blue. I also could vary the overall size of my building by varying the value of dx.

Pictures

Above is a photo of scene 1.

Above is a photo of scene 2.

Above is a photo of my tree. I created this by drawing a rectangle and then drawing a triangle on top of it. I put this into a function called tree.

Above is a photo of my second builing. I created this by making a square and then by making a trangle of top of that square. I then used the same square function that I used in my first building to make the windows in this building as well. I also created a rectangle function to create the door on this building. I made this building a function called building2. I then place the square and rectangle functions within that function.