✏️
Coding🚀 Ages 7-10Beginner 9 min read

Drawing with the Pen in Scratch

A step-by-step lesson on the Pen blocks in Scratch: turn on the Pen extension, draw your first line, set colour and thickness, draw shapes with loops, and build a complete drawing app that follows the mouse pointer.

Key takeaways

  • The Pen blocks let a sprite draw a line as it moves around the stage
  • 'pen down' starts drawing and 'pen up' stops; the sprite is the pen tip
  • 'set pen color' and 'set pen size' change how the line looks
  • Repeating a move-and-turn pair inside a loop draws shapes like squares and stars

What is the Pen in Scratch?

Imagine taping a marker to the bottom of a toy car. As the car drives around, the marker draws a line that follows its path. That is exactly what the Pen does in Scratch. Your sprite becomes the pen tip, and wherever it moves, it can leave a coloured line behind.

The Pen is one of the most fun parts of Scratch because a few simple blocks can make beautiful patterns — squares, stars, spirals and rainbows. In this lesson you will turn on the Pen, learn its main blocks, and draw real shapes step by step.

If Scratch is brand new to you, work through getting started with Scratch first. It also helps to understand how the sprite moves around the grid, which you can learn in coordinates and movement in Scratch.

Step 1: Turn on the Pen blocks

The Pen blocks are hidden until you switch them on.

  1. Look at the bottom-left corner of the Scratch screen for the Add Extension button (it looks like a small square with a plus).
  2. Click it, then choose Pen from the list.

A new blue Pen category now appears in your blocks palette. These are the blocks we will use:

  • pen down — lowers the pen so the sprite starts drawing.
  • pen up — lifts the pen so the sprite can move without drawing.
  • erase all — clears every pen mark from the stage.
  • set pen color to — picks the colour of the line.
  • set pen size to — sets how thick the line is.
  • stamp — prints a copy of the sprite's costume onto the stage.

Step 2: Draw your first line

Let's draw a single straight line. Click a sprite (the cat is fine) and build this script:

when green flag clicked
erase all
go to x: -150 y: 0
pen down
move 200 steps
pen up

Read it block by block:

  1. erase all clears anything left from before.
  2. go to x: -150 y: 0 moves the sprite to the left side of the stage before drawing, so the line starts there.
  3. pen down presses the pen onto the stage.
  4. move 200 steps slides the sprite to the right, dragging a line behind it.
  5. pen up lifts the pen so the sprite stops drawing.

Click the green flag and you will see a straight line appear. That is your first drawing!

Step 3: Choose a colour and thickness

A plain line is a bit boring. Let's make it bold and colourful. Add two blocks right after erase all:

when green flag clicked
erase all
set pen color to [blue]
set pen size to 8
go to x: -150 y: 0
pen down
move 200 steps
pen up
  • set pen color to lets you click the colour swatch and slide the colour, brightness and shade to pick any colour you like.
  • set pen size to 8 makes the line 8 pixels thick. Try changing 8 to 2 for a thin line, or 20 for a chunky one.

Step 4: Draw a square with a loop

Drawing one line is easy, but drawing four lines one at a time would be slow. A square is just the same action repeated: move forward, then turn a corner. In Scratch we use a repeat loop so we do not have to copy blocks over and over. If loops are new to you, see loops and repeats.

A square has 4 sides and 4 corners. Each corner is a 90-degree turn. So we repeat "move, turn 90" four times:

when green flag clicked
erase all
set pen color to [purple]
set pen size to 5
go to x: 0 y: 0
pen down
repeat 4
  move 100 steps
  turn right 90 degrees
pen up

Click the green flag. The sprite walks forward 100 steps, turns right, walks again, turns again — four times — and ends up back where it started, having drawn a perfect square. Magic!

Every Pen block, and what it does

The Pen extension adds eight blocks. This is all of them:

BlockWhat it does
erase allWipes every pen mark off the stage. Put it at the start of almost every project.
pen downStarts drawing. From now on the sprite leaves a trail wherever it moves.
pen upStops drawing, so the sprite can move without leaving a line.
stampPrints a copy of the sprite's picture onto the stage, like a rubber stamp.
set pen color toPicks an exact colour from a colour swatch.
change pen color byShifts the colour along the rainbow — use it in a loop for a colour-cycling line.
set pen size toSets line thickness in pixels. 1 is hairline, 20 is a fat marker.
change pen size byMakes the line get gradually thicker or thinner as you draw.

The commonest mistake is forgetting pen down. If your sprite moves but no line appears, that is almost always why.

The complete pen script: a drawing app

Here is the script most people are looking for — a drawing app where the sprite follows your mouse and draws only while the button is held down:

when green flag clicked
erase all
pen up
set pen size to 4
show
forever
    go to (mouse-pointer)
    if <mouse down?> then
        pen down
    else
        pen up

Read it line by line and you can see why each part is there:

  • erase all clears anything left over from last time.
  • pen up makes sure you do not start with a stray line from the sprite's old position.
  • show guarantees the sprite is visible — a hidden sprite still draws, which is confusing when you are testing.
  • The forever loop runs about 30 times a second, so the line looks smooth.
  • go to (mouse-pointer) before the pen check means the sprite is already in the right place when the pen goes down.

Two upgrades worth adding. To hide the sprite so you see only the drawing, swap show for hide — the pen still works. To cycle colours as you draw, add change pen color by 2 inside the loop.

If you want the sprite to animate while it draws, add next costume inside the forever loop and a wait 0.05 seconds to slow it down — see animations and costumes in Scratch.

A worked project: a colourful star

Now let's draw something prettier — a five-pointed star. The trick to a star is the turn angle. To draw a star you make 5 points, and at each point the sprite turns by 144 degrees (because 5 points × 144 = 720, which is two full circles, the special pattern that makes a star).

Add the Pen extension if you have not already, then build this on your sprite:

when green flag clicked
erase all
set pen color to [yellow]
set pen size to 4
go to x: 0 y: -50
pen down
repeat 5
  move 150 steps
  turn right 144 degrees
pen up

Here is what happens, step by step:

  1. erase all gives a clean stage, and the pen colour and size are set to a thick yellow.
  2. The sprite moves to a starting spot near the bottom and pen down begins drawing.
  3. The repeat 5 loop runs the move-and-turn pair five times. Each turn right 144 degrees sends the line across to the opposite point of the star.
  4. After 5 lines the star joins up, and pen up stops drawing.

Click the green flag and watch a star appear in five quick strokes. Try changing the colour or the move 150 steps to draw a bigger or smaller star.

Try it: make it your own

You can draw lines, squares and stars. Now experiment with these challenges:

  • Change the shape: for a triangle, use repeat 3 and turn right 120 degrees. For a hexagon, use repeat 6 and turn right 60 degrees.
  • Rainbow shapes: put your shape inside another repeat 6 loop, and add change pen color by 20 and turn right 60 degrees each time, to spin colourful copies into a flower pattern.
  • Make a spiral: in a loop, move 5 steps, then turn right 15 degrees, and slowly grow the move amount.
  • Stamp art: use pen up and the stamp block to print rows of your sprite instead of lines.

If a shape does not close up neatly, check your turn angle and your repeat number — for any regular shape, the angle is 360 divided by the number of sides. Reading your blocks carefully to find the problem is called debugging, and every coder does it. Have fun drawing! ✏️

Quick quiz

Test yourself and earn XP

What does the 'pen down' block do?

How do you stop the sprite from drawing?

To draw a square, how many times do you repeat 'move 100 steps, turn 90 degrees'?

Why do we usually add 'erase all' at the start of a drawing script?

Which block makes the drawn line thicker?

FAQ

They are not shown by default. Click the 'Add Extension' button at the bottom-left of the screen, then choose 'Pen'. A new blue Pen category appears in the blocks palette with all the drawing blocks.

Add an 'erase all' block right after 'when green flag clicked'. That clears every pen mark before you draw again, so each run starts on a clean stage.