Code Stars,  Python Math

Basic Drawing Commands

Ty Goes to Art Class

There are a number of things that you can do to add life to your turtle graphics.

Remember the pattern object.method(argument)

In cases the methods will be the properties (thing about the turtle) that you want to change.

So for example, to change the size of the turtle (pensize) you would type:

To change the turtles color you would add: ty.color(“color you want in quotes”)

Here are some other properties to change:

.shape(“arrow”, “turtle”, “circle”, “square”, “triangle”, “classic”)

.showturtle()

.pensize(# of the size you want)

.hideturtle()

.penup()

.pendown()

.speed()

You can send the turtle to any point on the background canvas using x and y coordinates.

Simply enter the command ty.goto(x,y) with x and y being whatever value you want.

Note: When the turtle starts it is a (0,0).

You can have the turtle fill a shape this it is drawing by using the command fill(True) at the beginnning of the section that will be filled and fill(False) at the end.

The code to make a square would be:

ty.fill(True)
for i in range (4):
     ty.forward(30)
     ty.right(90)

ty.color(“orange”)
ty.fill(False)
ty.hideturtle()

Backgrounds

You can also create a background screen and set the color for it.

To create the screen you will need to type:

bg = turtle.Screen()

Then you can define the color of the screen using:

bg.bgcolor(“<color you would like>)

Add bg.exitonclick() so that the screen will clear when the user clicks on the screen.

Leave a Reply

Your email address will not be published. Required fields are marked *