Project 3 Write Up
Skip to end of metadata
Go to start of metadata

For this project, we improved on a previously made library of turtle-drawn shapes, and applied new skills to the code for our Maine coastline scenes, from last week. Among other things, this entailed using "if" statements, for loops, and implementing multiple layers of functions

Task 1

For task 1, I made a new file called "" and copied and pasted the "goto" function and the function for a rectangle, from a previous project.  I used the code below to incorporate loops into my code, which reduced the amount of actual code needed, simplifying the file. I also added color to the shape by putting the two lines "turtle.fillcolor( fc )" and "turtle.fill( True )" before the code for the block, and the line "turtle.fill( False )" directly after the code for the block. I also added additional parameter for edge length which allowed me to control the scale. 

Task 2

For task 2, I applied the same changed from task 1 to a triangle function, and a hexagon function--adding for loops, color, and additional parameters for scale control. 

Task 3

For task 3, I again applied the same types of changes from task 1, but this time to two more complicated shapes from the last project. This added additional complexities, for example, my boat function uses a triangle function from my old shape library in order to draw the sail of the boat, so in the better shape library, I had to import the old ""  and then use "shapelib.triangle( x-65*scale, y-100*scale, 125*scale )" to call the triangle shape. 

Task 4

For task 4, I made a new coastline scene, but this time added additional parameters so I could control location and scale. 

Task 5

For task 5, I created a new file called "taskI" and imported my new "better_shapelib" file so that I could call on my new and improved functions. I called my main coastline scene three times, each time with different scales and locations, pictured below.
Task 6

For task 6, I created a new "" file, and drew some code for a cross inside of a rectangle, to make a window, and then called my maine coastline scene using parameters that made it fit inside the window. The resulting effect being that the coastline looks like it is through the window, pictured below.

Task 7

For task 7, I created a new function called "task" which calls the coastline function three times, each time with different parameters.  I then called the task function three times, for a total of 9 scenes in one image, pictured below.
I then used the following code below to make the task function call 80% of the time.


For my extensions I, 1), made use of the range function to reduce the amount of code I had to use. 2) Used several levels of encapsulation in task 7, using fairly simple code to create a more complicated image.

  • No labels