For this project, we used Python to make a "coastal Maine" scene. We had to think of some things that one could find in such an area, and use the Turtle to draw them, making sure they could be drawn properly no matter the size or position of the turtle. This assignment further familiarized me with the turtle commands.


These are the three simple shapes I drew. This project relied heavily on the "goto" function we created, which makes the turtle travel to specified coordinates without drawing a line, something I did not know how to do on the last project. The function was very useful for organizing the layout of the scenes. The code went as follows:

print "goto():going to", x,y --- This tells us where the cursor is going every time it moves.

turtle.up() --- This lifts the turtle off the canvas so it doesn't draw anything.

turtle.goto(x,y) -- This moves the turtle to the coordinates (x,y).

turtle.down() -- This puts the turtle back down, leaving a mark on (x,y), where it has now landed.

I made a sailboat shape and a buoy shape, and duplicated them in different sizes and areas to make sure they were working correctly. They are both made up of basic shapes, for the most part, but for the sides of the boats, I used quarter-circles by utilizing the command "turtle.circle(length*.5,75)", which draws a circle of radius "length*.5" (taken as an input later, "length" is decided by what scale the user chooses when calling a boat to be drawn) and angle "75" (360 would draw the whole circle, but this draws only a segment). For the sails, I made 30-60-90 triangles, and had to import math at the start to enable square roots to be used in the code. By using the "turtle.color()" command, I assigned the objects different colors: red and brown. The function takes both strings like "red" or RGB integer inputs like 1,0,0 (also red).

To make all of the objects align no matter what position and scale the user chooses, I made the objects take the "scale" argument and multiply it by a certain number to keep everything in proportion, and the x and y inputs had to be done relative to the scale, as well. Since testing things out to make sure they looked right became tiring, I used the commands "turtle.tracer(False)" and "turtle.update", which make it so that the turtle only displays the finished picture instead of drawing it all live for the user.

This was my first attempt at really making the objects assemble to form a scene. I added birds, the sun, and a water line. I made the water line thicker by using the command "turtle.pensize(10)" to change the thickness to 10 pixels instead of the default 1.

 

This is an alternate scene with the objects arranged differently. Most notably, there are fewer birds and the sun is bigger here. With multiple objects arranged like this, the function "turtle.setheader(0)" is very useful, because it sets the turtle to be facing right again, like it does by default, so you don't have to remember what direction the turtle was facing when planning the next move. 


I did an extension (extension 5), for which I added fill colors to make my scene look more interesting. This was done by using "turtle.fill(True)" at the start of whatever needed to be filled in, such as brown for the boat hull, and "turtle.fill(False)" at the end to stop filling the shape. I also added in a better-looking water background by making a filled-in square as the first thing, with everything else drawn on top afterwards. For example, the sails were drawn (in white) by using the following code: 
turtle.fill(True) turtle.color("white") turtle.forward(length) turtle.forward(2*length*math.sqrt(3)) turtle.right(150) turtle.forward((length*4)) turtle.right(120) turtle.forward(2*length) turtle.fill(False)
turtle.fill(True) --- tells the turtle to fill whatever it draws next
turtle.color("white") --- tells the turtle to fill with white
turtle.forward(length) --- tells the turtle to go forward by the "length" input, which is determined, as I mentioned before, by what scale the user chooses
turtle.forward(2*length*math.sqrt(3)) --- draws the "x*sqrt(3)" side of the 30-60-90 triangle that will be the mast
turtle.right(150) --- turns the turtle right 150 degrees
... *the rest of the triangle is drawn in a similar fashion*
turtle.fill(False) --- turns the turtle fill function off so the things drawn next are not filled mistakenly

For my second extension (extension 4), I added waves and more birds. Instead of individually placing them all, I made use of the "random.randint()" command, which can be used to draw many shapes at random coordinates. For the waves, I first made a wave function, then a function called "current" that calls many of them at random spots, which is written the following way:

def current(x,y):

goto(x,y)

for i in range(30):

a=random.randint(-300,300)

b=random.randint(-300,150)

wave(a,b)

"for i in range(30)" tells the turtle that we want 30 waves to be drawn; a is defined as a random value between -300 and 300, and, similarly, b is defined as a random value between -300 and 150; a and b are then used as the coordinates (x and y) for a wave to be drawn.

In this project, I learned a lot about how to manipulate the turtle to make more complete objects. I learned how to fill the shapes in properly, how to draw a lot of randomly placed shapes, how to make the turtle instantly display the finished picture, and how to make a simple background using a basic shape.