How to Draw Polygons in Scratch

How to Draw Polygons in Scratch

Ever wanted to create all equilateral polygons in Scratch using just a few blocks?
This beginner tutorial shows how the same small set of blocks can generate shapes like triangles, squares, and pentagons. Using the Pen extension, variables, and sliders, the code becomes an interactive shape-drawing tool.

This post supports the video tutorial below by explaining the ideas behind the project and walking through the code step by step.

What’s Covered in This Tutorial

  • How to calculate turning angles to draw equilateral polygons
  • How to use variables and sliders to control the shape’s sides, length, and color
  • How to use loops to draw shapes with less code
  • How to keep the code organized using custom blocks
  • How to draw on the stage using Scratch’s pen extension

Step-by-Step: Drawing a Polygon in Scratch

To draw an equilateral shape in Scratch, the turning angle must be calculated. Here’s the formula:

Turning angle = 360° ÷ number of sides

This tells the sprite how much to turn after drawing each side. For example:

  • Triangle (3 sides) → turn 120°
  • Square (4 sides) → turn 90°
  • Pentagon (5 sides) → turn 72°

Polygon Turning angle

Once the angle is set, the sprite simply moves forward and turns, repeating these steps for each side.

Adding Sliders to Control the Shape

To make the code more fun and interactive, create these three variables and turn them into sliders:

  • Sides: How many sides the shape has
  • Length: How long each side should be
  • Color: What color the pen should draw with

Properties Slider

Then use a repeat loop to draw the shape. Repeat By placing everything inside a forever loop, the shape updates automatically as the sliders are moved. Forever This project may look simple, but it highlights what real coding is about: creating smart, reusable code that adapts.

Key Programming Concepts

  • Variable: Stores values like number of sides or color, allowing the code to change based on input.
  • Loop: Repeats a set of instructions multiple times.
  • Custom Block: A reusable group of code commands that keep the project organized and modular. Custom Block
  • Pen Extension: Let’s the sprite draw on the screen, controlling pen size, color, and erasing.
    Scratch Pen Extension

Common Problems and How to Fix Them

ProblemWhat to Check
Shape doesn’t closeMake sure the sprite turns 360 ÷ sides degrees and repeats the correct number of times.
Old shapes stay on screenUse the erase all block before each new drawing
Sliders don’t workCheck that the variables are used inside the drawing code

Advanced Ideas to Explore

  • Animate the shapes by rotating them slightly between repeats
  • Change or randomize pen colors to make the drawing more colorful and alive.
  • Use ask blocks to let others type in custom values
  • Combine shapes to create patterns or complex designs

Finished This Tutorial?

For those interested in expanding this project and creating something more advanced, the post below is the perfect next step. drawing patterns in Scratch


If you’re interested in more projects like this, be sure to check out our YouTube channel, where we regularly share new tutorials to help you explore, learn, and create with Scratch.

Happy Coding!
TheSTEAMIst
The STEAMistt Avatar
Last updated on