Editor

Draw a Sailboat in Python Turtle

Intermediate · Things to draw · 81 lines · draws in about 10 seconds

Triangles from lists of points make the sails, and arcs that bend one way and then the other make the wavy lines across the sea.

Draw a Sailboat in Python Turtle: the finished drawing
import turtle
screen = turtle.Screen()
screen.bgcolor("white")
screen.title("Sailboat")
t = turtle.Turtle()
t.speed(8)
def polygon(points, color):
# Join the points with straight lines and fill the shape
t.penup()
t.goto(points[-1])
t.pendown()
t.color(color)
t.begin_fill()
for point in points:
t.goto(point)
t.end_fill()
def wave_row(x, y):
# A wavy line: arcs that bend right, then left, eight times
t.penup()
t.goto(x, y)
t.setheading(60)
t.pendown()
for _ in range(8):
t.circle(-20, 120)
t.circle(20, 120)
def seagull(x, y):
# Two small arcs side by side look like a bird far away
t.penup()
t.goto(x, y)
t.pendown()
for _ in range(2):
t.setheading(60)
t.circle(-12, 120)
# The sky, the sun and two seagulls
polygon([(-300, -60), (300, -60), (300, 220), (-300, 220)], "lightskyblue")
t.penup()
t.goto(-210, 140)
t.dot(80, "gold")
t.pensize(3)
t.pencolor("dimgray")
seagull(150, 150)
seagull(205, 120)
t.pensize(1)
# Two sails and the mast
polygon([(10, -10), (10, 185), (150, -10)], "white")
polygon([(-10, -10), (-10, 150), (-125, -10)], "orange")
t.pensize(6)
t.pencolor("saddlebrown")
t.penup()
t.goto(0, -30)
t.pendown()
t.goto(0, 195)
t.pensize(1)
# A small flag at the top of the mast
polygon([(0, 195), (40, 183), (0, 171)], "crimson")
# The hull, wider at the top than at the bottom
polygon([(-170, -20), (170, -20), (120, -110), (-120, -110)], "sienna")
# The sea goes last so it covers the bottom of the boat
polygon([(-300, -220), (300, -220), (300, -60), (-300, -60)], "royalblue")
t.pensize(4)
t.pencolor("lightcyan")
wave_row(-262, -100)
wave_row(-294, -145)
wave_row(-262, -190)
t.hideturtle()
turtle.done()

How the code works

Waves from arcs

The turtle starts pointing 60 degrees up. circle(-20, 120) bends right over a crest and circle(20, 120) bends left through a dip, which leaves it pointing 60 degrees up again, ready for the next wave.

def wave_row(x, y):
    # A wavy line: arcs that bend right, then left, eight times
    t.penup()
    t.goto(x, y)
    t.setheading(60)
    t.pendown()
    for _ in range(8):
        t.circle(-20, 120)
        t.circle(20, 120)

Seagulls

Two small arcs side by side, each starting at the same heading, look like a bird far away.

def seagull(x, y):
    # Two small arcs side by side look like a bird far away
    t.penup()
    t.goto(x, y)
    t.pendown()
    for _ in range(2):
        t.setheading(60)
        t.circle(-12, 120)

Sails, mast and flag

Each sail is a right-angled triangle given as three points. The mast is a thick brown line from below the sails to above them, and the flag is one more small triangle.

# Two sails and the mast
polygon([(10, -10), (10, 185), (150, -10)], "white")
polygon([(-10, -10), (-10, 150), (-125, -10)], "orange")
t.pensize(6)
t.pencolor("saddlebrown")
t.penup()
t.goto(0, -30)
t.pendown()
t.goto(0, 195)
t.pensize(1)

# A small flag at the top of the mast
polygon([(0, 195), (40, 183), (0, 171)], "crimson")

The sea in front

The hull is drawn before the sea, so the sea covers its bottom and the boat seems to float. The three rows of waves start at different x positions so they do not line up.

# The sea goes last so it covers the bottom of the boat
polygon([(-300, -220), (300, -220), (300, -60), (-300, -60)], "royalblue")
t.pensize(4)
t.pencolor("lightcyan")
wave_row(-262, -100)
wave_row(-294, -145)
wave_row(-262, -190)

Make it yours

Change the code above and press Run. Some ideas:

  • Turn it into a sunset: change "lightskyblue" to "lightsalmon" and the sun's "gold" to "orangered".
  • Change "orange" in the second sail's polygon() to "crimson" for a red sail.
  • For bigger waves, change both 20s in wave_row() to 25 and range(8) to range(6).

What it uses

Every turtle command the site supports is listed on Python turtle online.