Hardware Reference
In-Depth Information
Adventure 4
Programming Shapes
with Turtle Graphics
SUPPOSE YOU COULD pick up a turtle, dip his tail into coloured ink, place him on a
piece of paper and make him walk around so that his tail paints a spiral shape, a penta-
gon or a noughts and crosses grid? his adventure introduces you to diferent ways
that you can create shapes or line drawings using code.
You'll use a module called Turtle Graphics that works by directing a cursor (or turtle )
around the screen using movement instructions; see an example of the result in Figure
4-1. his movement leaves a colour trail like a pen, which means you are able to pro-
gram a computer to draw. Turtle Graphics was originally a feature of the programming
language LOGO (Logic Oriented Graphic Oriented), which was designed to teach
young people how to program using a logical sequence of steps by means of an
onscreen cursor called a turtle . LOGO continues to be a very popular way to learn logic
and sequencing in computer programming. Both Scratch and Python include turtle
modules that can be used to create shapes, drawings and patterns.
his adventure draws on many of the computing concepts you have already used in
previous tutorials in this topic, such as sequencing, variables and loops, to create
shapes and spirals in both Scratch and Python programming environments on the
Raspberry Pi.
Search WWH ::




Custom Search