Turtle drawing

introduction

In the introduction to Turtle we set up the following code.

code
from turtle import *
screen1 = Screen()
turtle1 = Turtle()
screen1.bgcolor("SkyBlue")
turtle1.color("ForestGreen")
    

Draw a line segment

introduction

The turtle is pointing to the right, so we will draw a line segment to the right 150 pixels long. One pixel length is the size of one of the small dots that display the color on the screen.

code
from turtle import *
screen1 = Screen()
turtle1 = Turtle()
screen1.bgcolor("SkyBlue")
turtle1.color("ForestGreen")
turtle1.forward(150)
    

Turn left 60 degrees and draw a line segment

introduction

Turn left 60 degrees. Then draw a line segment 100 pixels long.

code
from turtle import *
screen1 = Screen()
turtle1 = Turtle()
screen1.bgcolor("SkyBlue")
turtle1.color("ForestGreen")
turtle1.forward(150)
turtle1.left(60)
turtle1.forward(100)
    

Turn right 60 degrees

introduction
    Turn right 60 degrees so it points in the original direction.
    
code
from turtle import *
screen1 = Screen()
turtle1 = Turtle()
screen1.bgcolor("SkyBlue")
turtle1.color("ForestGreen")
turtle1.forward(150)
turtle1.left(60)
turtle1.forward(100)
turtle1.right(60)
    

Set the fill color, begin filling, draw a circle, and end filling.

introduction

Set the fill color to MediumSpringGreen. Before drawing the circle, begin filling the circle with the fill color. Note that begin_fill() and end_fill() are spelled with an underscore. Then draw a circle with radius 50. Drawing the circle starts in the direction the turtle is facing and curves counterclockwise. After drawing the circle, end filling the circle. When the fill ends the color is added to the interior of the circle.

code
from turtle import *
screen1 = Screen()
turtle1 = Turtle()
screen1.bgcolor("SkyBlue")
turtle1.color("ForestGreen")
turtle1.forward(150)
turtle1.left(60)
turtle1.forward(100)
turtle1.right(60)
turtle1.fillcolor("MediumSpringGreen")
turtle1.begin_fill()
turtle1.circle(50)
turtle1.end_fill()
    

Draw arcs

introduction

Draw an arc counterclockwise with radius 70 pixels and an arc of 80 degrees. Note that the radius is the first value given to the circle() function, and the angle of the arc is given second. Then draw a clockwise arc back along the path we have already drawn and on 80 degrees further (160 degrees in total). The negative arc means to draw it clockwise.

code
from turtle import *
screen1 = Screen()
turtle1 = Turtle()
screen1.bgcolor("SkyBlue")
turtle1.color("ForestGreen")
turtle1.forward(150)
turtle1.left(60)
turtle1.forward(100)
turtle1.right(60)
turtle1.fillcolor("MediumSpringGreen")
turtle1.begin_fill()
turtle1.circle(50)
turtle1.end_fill()
turtle1.circle(70,80)
turtle1.circle(70,-160)
    

Return to the home position

introduction

Lift the pen up so we are not drawing a line, return to the home position where we started and put the pen back down. Note that the home() function took the turtle back to the original position and facing the original direction.

code
from turtle import *
screen1 = Screen()
turtle1 = Turtle()
screen1.bgcolor("SkyBlue")
turtle1.color("ForestGreen")
turtle1.forward(150)
turtle1.left(60)
turtle1.forward(100)
turtle1.right(60)
turtle1.fillcolor("MediumSpringGreen")
turtle1.begin_fill()
turtle1.circle(50)
turtle1.end_fill()
turtle1.circle(70,80)
turtle1.circle(70,-160)
turtle1.up()
turtle1.home()
turtle1.down()