To use the Pen blocks in Scratch, please click on the highlighted image, Add extension button.
Click on the Pen extension to add it.
The Pen section then appears at the bottom of the blocks menu.
From the Pen section, select the pen down block and add it to the start of your program, like this:
On clicking the flag, you can see the output below showing that a line is drawn.
If you can see the lines behind the cat sprite, then the pen is working and one can start making it draw really cool patterns.
To get rid of the cat sprite, the following code is added.
Add a hide block from Looks to the start of the program and it’ll disappear.
On clicking the flag, you can see the output below showing that a line is drawn without the cat sprite.
Now, one can change the colour of the pen with another block from the Pen section, but the block is a little different to the others you’ve seen. It’s the set pen color to block and looks like this:
If you’ve been clicking on the green flag to test your code, you’ll have noticed that the drawings the pen makes don’t go away.
Add a clear block from the Pen section to the start of your code to take care of that:
Drawing Patterns using Pen Graphics
Drag repeat until block from control section in scratch. This type of loop will do something over and over again, until a True/False condition is met.
The following code is added.
Pen will keep moving 50 steps and turn by 15 degrees forever showing the output below:
The Pen will keep the pattern above without stopping.
We have put the condition “touching edge” condition on repeat until loop. The pen will keep drawing till the pen touches the edge of the screen.
Output:
Drawing circle using Pen graphics
Changing the code to move 5 steps will create a circle.
What’s happening here is that those 15-degree turns eventually add up to 360 degrees, and so your pen turns in a full circle.
Drawing square using Pen graphics
Setting the Pen size of 10 will change the thickness of the line drawn.
Add move 100 steps and turn 90 degrees block in a repeat loop which runs for 4 times as shown in the code below.
Drawing Star using Pen graphics
Add move 100 steps and turn 135 degrees block in a repeat loop which runs for 8 times as shown in the code below.
Hope this is useful, thank you.
You may like to read: Debugging for Kids, Common Coding Terms for Kids, & Events in Scratch Programming