Data Sheet

ADVENTURES IN RASPBERRY PIBC6
Bonus chapter.indd 6 Trim size: 7.375 in × 9.1875 in October 24, 2017 7:20 PM
Turtle Graphics Command Quick Reference Table
See also the Scratch Quick Reference Table in Adventure3
Commands Description
Pen Blocks (Scratch)
change pen color by x
Changes pen’s colour by x amount.
change pen shade by x
Changes the pen’s shade by x amount.
clear
Clears all pen marks and stamps from the stage.
pen down
Puts down a sprite’s pen so that it will draw.
pen up
Lifts a sprite’s pen so it does not draw.
set pen color to x
Sets a pen’s colour to your choice.
set pen shade to x
Sets the pen’s shade by x amount.
set pen size x
Set’s a pen’s line thickness to x.
stamp
Stamps a sprite’s image on to the stage.
Turtle Module in Python
import turtle
Imports the turtle module into Python. Should be at the
start of any Python Turtle program.
Creating and Naming the “turtle”
alex = turtle.Turtle()
Opens the Turtle Graphics window, with an arrow cursor
in the centre, named alex. The arrow cursor represents
the turtle, whose movements create your drawing.
Move and Draw
forward(x)
Moves the turtle forward by the specied distance x, in
the direction the turtle is headed.
left(x)
Turns turtle left by x units.
right(x)
Turns turtle right by x units.
stamp()
Stamps a copy of the turtle shape onto the canvas at the
current turtle position.
Drawing State
pendown()
Puts the pen down and draws when it moves.
penup()
Picks the pen up and stops drawing.
pensize(x)
Sets the thickness of the line drawn to x pixels.
Turtle State
shape(“turtle”)
Sets the cursor icon. Possible values for the shape are
arrow, turtle, circle, square, triangle, classic.
Colour Control
color(“brown”)
Sets pen colour.
Chapter 4