SCRATCH ISN’T JUST about variables, loops, and operators. It’s also a great place to create original interactive art and animations. In this adventure, you discover how to use Scratch to create, change, and animate your own artistic creations.
Scratch lets you create your own sprites and backdrops by drawing, painting, and importing graphics from your computer—or even by taking pictures using a camera connected to your computer!
The tool for creating your own graphics is called the Paint Editor. You’ve worked with the Paint Editor in previous adventures, but in this one, you learn about some more advanced ways to use it. In no time at all, you’ll be painting like a pro!
One popular use for the Paint Editor is to create multiple backdrops that can be connected to form a slideshow. Slideshows are a great way to show off several of your artistic creations or to teach new skills. To make a slideshow that teaches people how to make a peanut butter and jelly sandwich, follow these steps:
Click the Paint New Backdrop icon.
The Paint Editor opens, with a new backdrop called backdrop2 highlighted, as shown in Figure 8-1. This backdrop is your title slide.
When the cursor appears, type How to Make a Peanut Butter and Jelly Sandwich. The text is too long to fit on one line, so press Return or Enter before you type Peanut Butter and Jelly Sandwich.
Your title backdrop should now look similar to Figure 8-2.
If your title still has a line around it, that means it’s selected. Click somewhere else in the Paint Editor to unselect it.
When you click outside of the text box, the title appears on the Stage, as shown in Figure 8-3.
Use the Selection tool to drag a rectangle around all the text in your Paint Editor.
When you finish drawing the rectangle, it turns blue, and squares—called handles—appear at the corners and on the sides, as shown in Figure 8-4.
Notice how the edges of the text get choppy when you make it bigger? To understand why that happens and how you can fix it, you need to know about the two different ways that you can use the Paint Editor. These are Vector mode and Bitmap mode. Which one you’ll use at any one time depends on what kind of art you’re creating.
Whenever you open the Paint Editor to create something new, it opens in Bitmap mode. You know you’re in Bitmap mode when your tools are on the left side of the Paint Area.
The Bitmap tools let you draw anything you want. They paint shapes, text, lines, and color using tiny squares called pixels.
Bitmap tools work really well for editing with photographs or really complicated drawings. They give you precise control over every pixel in an image or graphic.
However, bitmap graphics are made of a certain number of pixels, so when you make them larger, they look distorted, or pixelated, as shown in Figure 8-6.
Another drawback to bitmap graphics is that they don’t have the ability to be layered. For this reason, after you create text or a shape using bitmap tools, you can’t easily resize or modify them.
When you’re working with text or shapes, it’s much easier to work with the Paint Editor’s other tools, the Vector Drawing tools.
Vector Drawing tools use lines, rather than pixels, to create graphics. Vector graphics work great for illustrations, text, and shapes.
When you use Vector Drawing tools, you can easily resize shapes and move things around in layers in the Paint Editor. Follow these steps to make a new title slide using the Vector Drawing tools.
In the lower-right corner of the Paint Editor, click the button that says Convert to Vector.
Notice that the tools disappear from the left side of the Paint Editor and new tools appear on the right.
Type How to Make a Peanut Butter and Jelly Sandwich. You can press Return or Enter to create multiple lines of text that fit in the Paint Area.
If you want, you can change the font and the color by using the Font menu and the Color Palette at the bottom of the Paint Editor. When you’re done typing, the title should look similar to Figure 8-7.
Click the Select tool in the Vector Drawing tools.
It’s the tool at the very top, which looks like an arrow.
Use the Select tool to click the text in the Paint Area.
Handles appear around the text.
Use the handles around the text to resize it to fit the entire Paint Area, as shown in Figure 8-8.
Notice how vector text stays smooth no matter how large you make it or how much you squish and stretch it. This is because it’s made up of shapes and lines that can be any size, rather than pixels.
The next step in your slideshow project is to make the slides that tell people how to make this delicious sandwich. Follow these steps.
Draw two squares on your backdrop, as shown in Figure 8-9.
If you hold down the Shift key as you draw your rectangles, you make perfect squares!
These will be the pieces of bread for the sandwich.
Change the text on this backdrop to Spread jelly on the other slice of bread.
Your project should now look like Figure 8-14.
Change the text on this backdrop to Enjoy your sandwich!
This completes your backdrops for the project. Your project should look like Figure 8-15.
Next, you write a script to make the slides change. Follow these steps.
Click the Scratch the Cat sprite in the Sprites Pane.
The Costume Editor appears, with Scratch the Cat in the middle of it.
when green flag clicked
block from the Events Block Palette to the Scripts Area.switch backdrop to ()
block from the Looks Block Palette and snap it to the when green flag clicked
block.switch backdrop to ()
block to Title.when () key pressed
block from the Events Block Palette to the Scripts Area.when () key pressed
block to Space.switch backdrop to ()
block from the Looks Block Palette and snap it to the bottom of the when () key pressed
block. Change the drop-down menu in the switch backdrop to ()
block to Next Backdrop.
Your script should now look like Figure 8-16.
Click the Green Flag to start your slideshow and press the space bar to go through each of the slides!
Scratch’s Pen blocks make it possible for you to write programs that create graphics and help you to draw pictures on the Stage.
You saw an example of code that draws using the pen in the random drawing program in Adventure 2. In this adventure, you use the pen to create a skywriting plane program that draws in the sky with clouds as you move your mouse around the Stage.
Figure 8-18 shows what the finished program will look like on the Stage.
To code the Skywriting app, follow these steps:
Click Choose Backdrop from Library.
The Backdrop Library opens.
Click the Choose Sprite from Library icon in the Sprites Pane.
The Sprite Library opens.
Click the Choose Sprite from Library icon in the Sprites Pane again and add the Cloud sprite to your project.
Your program should now look like Figure 8-19.
Now that the Stage is set, your first task is to make this plane fly wherever your mouse goes on the Stage.
when green flag clicked
block from the Events Block Palette to the Scripts Area.forever
block from the Control Block Palette to the Scripts Area and snap it to the when green flag clicked
block.go to ()
block from the Motion Block Palette and snap it inside the forever
block.go to ()
block to Mouse-pointer.Your script should now look like Figure 8-20. Click the Green Flag and move your mouse around the Stage to see how the airplane follows it.
Next, you add a script to the cloud to make it follow the plane and draw wherever the plane goes!
when green flag
clicked block from the Events Block Palette to the Scripts Area. Drag a go back () layers
block from the Looks Block Palette and snap it to the when green flag clicked
block.
This block causes the cloud to hide behind the airplane.
Drag a clear
block from the Pen Block Palette and snap it to the bottom of the go back ()
layers
block.
The clear
block erases the previous drawing every time you press the Green Flag.
forever
block from the Control Block Palette to the Scripts Area and snap it to the go back () layers
block.go to ()
block from the Motion Block Palette and snap it inside the forever
block. Change the drop-down menu in the go to ()
block to airplane.
This causes the cloud to follow the plane around.
if () then
block from the Control Block Palette and snap it inside the forever
block, to the bottom of the go to (airplane)
block.mouse down?
block from the Sensing Block Palette and snap it into the hexagonal space in the if () then
block. Drag a stamp
block from the Pen Block Palette and snap it inside the if (mouse down?) then
block.
The stamp
block causes an image of the sprite (the cloud, in this case) to be drawn, or stamped, at the current location of the sprite.
The finished cloud script looks like Figure 8-22.
Now press the Green Flag to try it out!
Achievement Unlocked: Scratch Artist
Bloom, by ykoubo, is a great starter project that you can copy and modify to create interesting flower patterns. You can check it out by going to https://scratch.mit.edu/projects/2546637/
. Take a look at the other projects (in the Remixes pane) that are based on this program and then try making your own!
To find out more about bitmap and vector images, go to Scratch class at https://scratch.mit.edu/projects/10568936/
.
3.144.28.50