Homework Two: Turtle Graphics


Project Writeup

The project was to create program that would draw a building in turtle graphics. The idea was to design a function that would draw a building in terms of length of one of the sides on the building. The reason for designing a building based on the length of a side of the builiding is that after the function was created, any user could insert a value into the function and the same building shape would reappear based on the size of the value that was entered into the function. For example, the length of the window might be defined in the function as being 10% as long as the bottom of the building. In this example, no matter what the size of the bottom of the building is, the windows will always be 10% of that length. After a function was created for a building that would keep its proportions no matter what size value was entered into the function, a city line was to be created by using the building function multiple times.

The parameters that were included in my building function included dx, x0, y0, red, green, and blue. The parameter dx controlled the size of the building, dx was the length of the bottom side of the rectangle that formed the main body of the building. The parameter x0 controlled the x-coordinate where the turtle began to draw the building, and the parameter y0 controlled the y-coordinate where the turtle began to draw the building. All of the parameters red, green, and blue were entered on a zero to one scale that controlled the color of the building. Obviously the most important parameters were dx, which controlled the scale of the building, and the parameters x0 and y0 which set the origin. The orgin in the buildings are the top left corner of the rectangular base that makes up the body of the building.

The image below represents a isolated version of the building that my function created, based on the length of the bottom of the building. All other pieces of the building are scaled from this section of the building.

The image below is the "artful" collection of my buildings into a cityscape. The only difference between this picture and the one from above is the size, number, color, and locations of the buildings.

Extension

The extension that I chose to take on was to create a function for other objects (besides a building), that might be found in a cityscape. The object that I chose to create was a school bus. I used the length of the tail end of the bus as the parameter that all other shapes' sizes would be based off of. For parameters I used dx, x0, and y0. The parameter dx dictated the size of the bus. The x0 parameter determined the x-cooridinate that the turtle would start drawing the bus, and the y0 parameter determined the y-coordinate that the turtle would start drawing the bus. The orgin in the bus function, where the turtle begins to draw the bus, is at the top left corner of the hexagontal stop sign. Unlike the building, I spefically set colors to certain parts of the bus in order to maintain the basic colors of a school bus. The reason for this is that the figure is not detailed enough to be reconized as a school bus if the colors were awkward. The following picture is an example of the bus function at work, the bus on the bottom is exactly twice the size of the one on top.

And finally, a compilation of all of the work...



Next Assignment: Grids and Mosaics

Back To Home Page