Welcome to our exciting lesson, Rainbow Paintbrush! In this lesson, we are going to create a fun drawing tool that changes colours as you draw.
We will use Scratch's pen blocks, colour changing, and mouse movement features. By the end of this lesson, you will have your own rainbow paintbrush that follows your mouse pointer and changes colour as it moves. Let's get started!
Open the Scratch website in a new tab and create a new project. Delete the cat sprite from the project.
We need to add a sprite that we will use for out pen.
Add the Ball sprite from the sprite library and give it this code to shrink it smaller.
when green flag clicked
set size to (30) %
To add a sprite from the sprite library follow these steps:
You can use search box or the filter links (Animals, People, Fantasy etc) to locate your sprite.
Now, we want our pen (the ball sprite) to follow our mouse pointer. This will allow us to control where we draw on the screen.
To do this, add the following code to your ball sprite:
when green flag clicked
set size to (30) %
forever
go to [mouse-pointer v]
end
Before we start drawing, we need to add a special group of blocks to our project. These blocks are part of the Pen extension.
To add this extension, click on the 'Extensions' button at the bottom left of the Scratch interface. A window will pop up with different extensions. Find and click on the 'Pen' extension. You will see that new blocks have been added to your blocks palette under the category 'Pen'.
Scratch Extensions are additional sets of blocks that expand the capabilities of your Scratch projects. They allow you to:
When you add an extension to your project: