Project 23 of 35  ·  Scratch Programming  ·  Module 1
Module 1

Paint Box

Build a freehand drawing application using the Pen extension with colour and size controls.

🍓  Open on Raspberry Pi Projects  ↗ Opens the official Raspberry Pi Foundation project — includes starter files and full step-by-step guide

What You Will Build

Build a freehand drawing application using the Pen extension with colour and size controls. Follow the guide below to build the project, then open the official Raspberry Pi page for starter files, worked examples and extra help.

🍓 This project is on the Raspberry Pi Foundation website. Click the orange button above to access the full guide, starter Scratch project and extension activities on projects.raspberrypi.org.

What You Will Learn

  • Use the Pen extension to draw with the mouse
  • Toggle pen up and pen down based on mouse button state
  • Create colour picker buttons that change the pen colour
  • Add size controls for thin, medium and thick strokes
  • Implement an eraser tool and a canvas clear button

Step-by-Step Guide

  • 1Enable the Pen extension. Create a white backdrop as the canvas.
  • 2Add a small dot sprite as the cursor. In forever: go to [mouse-pointer].
  • 3If <mouse down?>: pen down. Else: pen up.
  • 4Add 6 colour button sprites. Each: when clicked → set pen color to [ ].
  • 5Add 3 size buttons: Small (size 2), Medium (size 6), Large (size 14).
  • 6Add an Eraser button: set pen colour to white, set pen size to 20.
  • 7Add a Clear button: clear (erases all pen drawing from the canvas).
  • 8Add a Stamp mode: when a shape sprite is clicked, stamp it onto the canvas.
  • 9Show the current colour and size as variables on screen.
  • 10Test drawing — the canvas should respond immediately to mouse movement.

Extension Challenges

Finished the main project? Push further:

  • Add a spray paint tool: while mouse is held, draw random dots within a radius of the cursor.
  • Add a shape tool: click two points to draw a straight line between them using a custom block.
  • Add an undo button that stores the last 3 canvas states as costumes.