Cool Shapes To Draw Easy
How to draw a triangle, square, pentagon or any regular shape or polygon in Scratch
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.
How to draw polygons in Scratch
There are two important numbers you need to know:
- The number of sides the shape has. You use this to decide how many times to repeat. To draw a square in Scratch, you repeat four times. To draw a triangle, repeat 3. Each time you repeat, you draw a line and turn a corner.
- The angle of the turn at each corner. The way to calculate this is to take 360 and divide it by the number of sides. So to draw a square, the angle is 360/4 = 90. When drawing a triangle, it's 360/3 = 120.
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.
Program to draw any polygon in Scratch
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!
Try the program
Find out more...
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.
Credits
© 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!
Discover my latest books
100 Top Tips: Microsoft Excel
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.
- More
Scratch Programming IES
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.
- More
Mission Python
Code a space adventure game in this Python programming book published by No Starch Press.
- More
Cool Scratch Projects in Easy Steps
Discover how to make 3D games, create mazes, build a drum machine, make a game with cartoon animals and more!
- More
Raspberry Pi For Dummies
Set up your Raspberry Pi, then learn how to use the Linux command line, Scratch, Python, Sonic Pi, Minecraft and electronics projects with it.
- More
Earworm
In this entertaining techno-thriller for adults, Sean McManus takes a slice through the music industry: from the boardroom to the stage; from the studio to the record fair.
- More
Scratch and Raspberry Pi resources
Sean's Scratch Resources
Tips, tutorials and free book chapters for Scratch, a coding language widely used in schools.
- More
Sean's Raspberry Pi Resources
Tutorials and guides for the Raspberry Pi, a budget computer perfect for learning to program.
- More
Cool Shapes To Draw Easy
Source: https://www.sean.co.uk/books/scratch-programming-in-easy-steps/draw-any-shape.shtm
Posted by: chalfantretticuld.blogspot.com
0 Response to "Cool Shapes To Draw Easy"
Post a Comment