SCRATCH
Drawing shapes with maths and code
Les Pounder shows how we can use simple maths to draw patterns and shapes, just like a classic childhood toy.
OUR EXPERT
Les Pounder is Associate Editor at Tom’s Hardware and a freelance maker for hire. He blogs about his adventures and projects at bigl.es
YOU NEED
A PC or a Raspberry Pi 3/4/400 The code for this project can be run online at https://bit.ly/LXF281 scratch.
As a child I had Spirograph, and it was fascinating how coloured pencils and a rotating cog could create such wonderful patterns. Little did we know that years later we would be reproducing those same patterns with code. In this tutorial we shall use a little maths to generate coloured patterns in Scratch 3.
Scratch 3 should come pre-installed on your Raspberry Pi OS image, but just in case it is missing it can be installed from the main menu, under Preferences > Recommended Software. Scratch 3 is found in the Programming category; tick the box and click Apply to install. Once installed, Scratch 3 can be found in the main menu under Programming.
Open Scratch 3. On first start Scratch may take a little while to open. We’re going to assume that you have an understanding of how to code with Scratch, but if not we covered the basics in previous issues. Before we write any new code we need to click the blue folder icon at the bottom left of the screen to load the Extensions menu. From there select Pen and a palette of new blocks is added to our code.