Coding Compendium
A free 100-page ebook collecting my projects and tutorials for Raspberry Pi, micro:bit, Scratch and Python. Simply join my newsletter to download it.
Sean McManus, author of Scratch Programming in Easy Steps and Cool Scratch Projects in Easy Steps, shows you how to draw any regular shape or polygon in Scratch
One of the most enjoyable features in the Scratch programming language is the pen, which enables you to draw pictures on the screen by moving sprites around. Here's a simple program I wrote for my Code Club to show them how they can draw a triangle, square, a pentagon, septagon (or heptagon), hexagon, octogon, nonagon, decagon and on and on. I had some fun trying to remember the names for the regular shapes after an eight sided one.
There are two important numbers you need to know:
My program in the next section calculates this automatically for you, but if you just want to draw a square or another shape, it's clearer to do the maths and drop the numbers in. Here's how to draw a square, for example:
To change the length of the sides, change the number of steps the sprite moves. For shapes with more sides than 16, you'll need to use smaller side lengths, otherwise the sprite will go off the screen.
Feel free to share that program card image with your friends on Twitter, Facebook or other social network. Try it with your Code Club group, classroom or family too!
Find more 10 block Scratch demos here. For more information on my Scratch books and more bonus content, visit the Scratch Programming in Easy Steps and Cool Scratch Projects in Easy Steps homepages.
© Sean McManus. All rights reserved.
Visit www.sean.co.uk for free chapters from Sean's coding books (including Mission Python, Scratch Programming in Easy Steps and Coder Academy) and more!
A free 100-page ebook collecting my projects and tutorials for Raspberry Pi, micro:bit, Scratch and Python. Simply join my newsletter to download it.
Web Design in Easy Steps, now in its 7th Edition, shows you how to make effective websites that work on any device.
Power up your Microsoft Excel skills with this powerful pocket-sized book of tips that will save you time and help you learn more from your spreadsheets.
This book, now fully updated for Scratch 3, will take you from the basics of the Scratch language into the depths of its more advanced features. A great way to start programming.
Code a space adventure game in this Python programming book published by No Starch Press.
Discover how to make 3D games, create mazes, build a drum machine, make a game with cartoon animals and more!