GoalUse the pen blocks and a sub-routine to draw a pattern.
New words
pen extension · a set of blocks that lets a sprite draw lines as it movespen down · a block that makes the sprite draw while it movespen up · a block that makes the sprite stop drawingerase all · a block that clears the stage of all pen drawings
Explanation
The Pen extension adds drawing blocks. After ‘pen down’ the sprite draws a line wherever it moves. ‘Pen up’ lets it move without drawing. ‘Erase all’ clears the stage, so it is a good first block. The block ‘set pen color to’ takes a number, and different numbers give different colours. A sub-routine can draw a shape. To draw a square we move 50 steps and turn 90 degrees, four times. Four turns of 90 degrees make 360 degrees, a full turn. The sprite then faces the way it began and is back at its starting corner. The main script can turn a little and call the square again.
Worked examples
One call of square draws four sides of 50 steps. The turns add up to 4 × 90 = 360 degrees, so the sprite ends where it started and faces the same way.
The main script calls square and then turns 120 degrees, three times. This draws three squares that share one corner. 3 × 120 = 360, so the sprite ends facing the way it began.
Pen up lets the sprite travel without drawing. This script draws one square, jumps 80 steps along without a line, and draws a second square.
Class activity
Walk the shape (a clear floor or a playground, with a friend). Take 4 steps forward and turn a quarter turn to the right. Do this 4 times. Where do you finish? Which way do you face? Now take 3 steps and turn a third of a full turn (120 degrees), three times. What shape did you walk? Draw both walks on paper. If you have a computer or tablet, add the Pen extension in Scratch and build the pinwheel program.
Practice
1
How many degrees does the sprite turn in total while the pinwheel program runs?
One call of square turns 4 × 90 = 360 degrees. Each repeat also turns 120 degrees, so one repeat turns 480 degrees. Three repeats turn 3 × 480 = 1440 degrees, which is four full turns.
2
Change the main script to repeat (6) with a turn of 60 degrees. How many squares are drawn? Does the sprite end facing the way it began?
Six squares are drawn. 6 × 60 = 360, so the turns after the squares add up to a full turn and the sprite faces the way it began. (Each square also turns it 360 degrees.)
3
Which number completes the sub-routine so that it draws a triangle with three equal sides?
120. The sprite makes three turns, and 3 × 120 = 360, a full turn.
4
A pupil runs the pinwheel program but sees nothing on the stage. Which block might be missing? What happens if ‘pen up’ is forgotten between two shapes?
The ‘pen down’ block is missing, so the sprite moves without drawing. If ‘pen up’ is forgotten, the sprite draws a line while it travels between the two shapes.