Education & Online Learning

Pen graphics in Scratch programming

To use the pen blocks in Scratch, click the highlighted image “Add Extension” button.

Pen Blocks in Scratch Programming - UnicMinds

Click on the pen extension to add it.

Pen blocks in Scratch programmingPen blocks in Scratch programming

The pen section will then appear at the bottom of the block menu.

Pen blocks in children’s Scratch programmingPen blocks in children’s Scratch programming

From the Pen section, select the pen block and add it to the beginning of the program, as shown below:

pen departmentpen department

After clicking on the flag, you can see the output below showing that a line has been drawn.

outputoutput

If you can see the lines behind the cat sprite, that means the pen is working and you can start letting it draw really cool patterns.

To get rid of the cat sprite, add the following code.

Add a hidden block in Looks to the beginning of the program and it will disappear.

Cat Elf - Pen PartCat Elf - Pen Part

After clicking on the flag, you can see the output below, showing that a line is drawn without the cat sprite.

Line Drawing-Cat Elf-Scratch ProgrammingLine Drawing-Cat Elf-Scratch Programming

You can now change the color of your pen using another section in the Pens section, but this section is a little different than others you’ve seen. This is the set pen color to be blocked, as shown below:

Set Pen Color - Children's Scratch ProgrammingSet Pen Color - Children's Scratch Programming

If you keep clicking on the green flag to test your code, you’ll notice that the pen drawing doesn’t disappear.

Add a clear block from the Pen section to the beginning of the code to handle this:

Draw patterns using pen graphics

Drag the repeat from the control section to the block from the beginning. This type of loop performs certain operations over and over again until a True/False condition is met.

Add the following code.

Drawing Pattern Graphics - Children's Scratch ProgrammingDrawing Pattern Graphics - Children's Scratch Programming

The Pen will continue moving 50 steps and rotating 15 degrees forever, displaying the following output:

Pen Graphics – Scratch for KidsPen Graphics – Scratch for Kids

The pen will keep the pattern on it.

We put the “touch edge” condition on the repeat until loop. The pen will continue drawing until it touches the edge of the screen.

Cat Elf – Pen GraphicsCat Elf – Pen Graphics

Output:

Draw circles using pen graphics

Changing the code to move 5 steps will create a circle.

What’s happening here is that these 15 degrees of rotation end up adding up to 360 degrees, so your pen makes a full rotation.

Drawing circles using Pen Graphics - Scratch programmingDrawing circles using Pen Graphics - Scratch programming
Circle - Scratch Programming - Pen GraphicsCircle - Scratch Programming - Pen Graphics

Draw a square using pen graphics

Setting the pen size to 10 will change the thickness of the drawn lines.

Add a block that moves 100 steps and rotates 90 degrees in a repeating loop that runs 4 times, as shown in the code below.

Drawing Squares Using Pen Graphics - Scratch Programming - UnicMindsDrawing boxes using pen graphics - Scratch Programming - UnicMinds

Draw stars using pen graphics

Add a block that moves 100 steps and rotates 135 degrees in a repeating loop that runs 8 times, as shown in the code below.

Brush Graphics-Scratch Programming-StarBrush Graphics-Scratch Programming-Star

Hope this helps, thanks.

You might like to read: Debugging for Kids, Common Coding Terms for Kids, and Events in Scratch Programming



Related Articles

Leave a Reply

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

Back to top button
×

Adblock Detected

*We Appreciate Your Visit!*

To enjoy all the features and content on our website, please consider disabling your ad blocker. Our site relies on ads to provide you with quality content and a seamless experience. Thank you for your understanding!