Jump to main content

Quick Draw McPaws: Teach A Computer Kitty How to Draw Shapes

1
2
3
4
5
82 reviews

Abstract

Have you ever played a computer game in which a cartoon character, like a dog or a cat, moves or turns when you click on it? Have you ever wondered how characters know how far to move or how far to turn? In this computer science project, you will learn how with a simple (and free) program called Scratch, which will let you write your own computer program that tells a cartoon kitty how to draw shapes.

Summary

Areas of Science
Difficulty
 
Time Required
Short (2-5 days)
Material Availability
Computer with internet access
Cost
Very Low (under $20)
Safety
No issues
Credits

Kristin Strong, Science Buddies

Objective

To determine how to draw different two-dimensional shapes using the computer language Scratch.

Introduction

What are your favorite things to draw? Pets? Trees? Flowers? Rainbows? One of the tricks that artists use when they plan a new drawing is to break down objects into smaller parts and shapes. So the ears on a cat break down into triangles. Or the beak on a bird breaks down into a cone. Shapes like circles, ovals, squares, triangles, hexagons, octagons, cylinders, and cones are the basic building blocks of any drawing.

Drawing of a cat
Figure 1. In this drawing of a cat you can find many shapes, like the triangles in the ears, nose, and rug; the circles in the head and collar; the half-circles in the eyes; the oval in the body; and the rectangle in the rug.

If you look at the simplest two-dimensional (flat) shapes, shown below, you can see that some of them have angles. An angle is where a line makes a sharp turn. You can measure how sharp the turn is by using a tool called a protractor. A protractor has little marks on it, just like a ruler, but instead of measuring inches or centimeters, a protractor measures angles in degrees.

A circle, square, triangle, hexagon, octagon and a lineImage Credit: Kristin Strong, Science Buddies / Science Buddies
Figure 2. These are simple two-dimensional shapes: A circle, square, triangle, hexagon, octagon, and a line.


A protractor with a rotating armImage Credit: Kristin Strong, Science Buddies / Science Buddies
Figure 3. This is the math tool called a protractor that is used to measure the angles in two-dimensional shapes. The protractor in this example is measuring 35 degrees.

Pretend that you want to teach a friend how to draw a square. You decide to walk the path of a square on the floor so that you can show the friend what she has to do. You can see below that to draw a square, you would start walking at point A, travel to point B, and then turn (or rotate) 90 degrees, so that you can reach point C. Then you turn 90 degrees again to get to point D. Finally, you walk some more until you come back to point A.

Now suppose your friend tells you that she wants to learn how to draw a triangle, so you show her that path, too. To draw a triangle, you start at Point A, travel to Point B, and then have to turn very far—120 degrees—so that you can continue on the path to Point C. Then you have to turn 120 degrees again, so that you can come back to Point A.

In this computer science project, you are going to teach a kitty how to draw. The kitty is a cartoon character who is just a beginning artist. She doesn't even know how to draw shapes, like a triangle, yet. You'll help her by writing a simple computer program—a set of instructions for the computer. The computer program will tell her how to move so that she can draw her first shapes and get her start becoming a great artist!

Terms and Concepts

Questions

Bibliography

Watch these video to learn about angles and using a protractor:

These resources will introduce you to Scratch:

Materials and Equipment

Experimental Procedure

Getting Started with Scratch

  1. The first thing you should do is sign onto Scratch. If you do not have an account yet, click on 'Sign Up' to create an account.
  2. If this is your first time using Scratch or if you need a refresher, read the Getting Started with Scratch guide from the Raspberry Pi foundation.
  3. When you first start up Scratch, you'll see your artist cat come up on the screen. Meow! It's time to program Kitty so that she can draw shapes.
  4. If you want to change the way Kitty looks before you start, read the Variations section, below the Experimental Procedure, to find out how.

Writing Instructions for the Kitty

  1. The first thing Kitty needs to learn is when to start drawing. It's a little bit like when you run a race and someone says, "1, 2, 3...go!" You need to tell Kitty when to go. Find the symbol with the green flag under the Events category.

    Cropped screenshot of a when green flag clicked block in the program ScratchImage Credit
    Figure 4. This block runs the script below it when the green flag is clicked.
  2. Now Kitty must erase any previous drawings so that she can start out with a fresh page. It's kind of like getting a fresh sheet of paper with no marks on it. Go to the Pen category and get the Erase all element and snap it onto the flag. The Erase all element clears the page. If you do not already have the Pen category in your selection of blocks, you can add it by clicking the Add extension button on the bottom left of the screen and selecting the Pen extension.

    Cropped screenshot of a clear block in the program ScratchImage Credit
    Figure 5. This block clears everything on the screen that was drawn by elements in the Pen category.
  3. The next thing you need to tell Kitty is where to start drawing her shapes. The center of the screen where Kitty will be drawing has the coordinates x=0 and y=0. This is a good place to start drawing, but if you want to tell her to choose a different spot, feel free to do so, using the instructions below.
    An x-y coordinate system with the point 0,0 marked with a green dot, and the point negative 150,0 marked with a red dotImage Credit: Science Buddies
    Figure 6. Points on the coordinate plane are represented as ordered pairs (x, y), where 'x' is the horizontal distance from the y-axis (positive to the right, negative to the left), and 'y' is the vertical distance from the x-axis (positive upwards, negative downwards).

    To tell Kitty to go to the starting point (indicated by the green circle) and start drawing, you need to find the Go To instruction under the Motion category, which looks like this:

    Cropped screenshot of a go to x and y coordinate block in the program ScratchImage Credit: Scratch, Science Buddies / Science Buddies
    Figure 7. This block moves the sprite to the specified x and y position on the screen.

    Drag this Go To element to the center panel and snap it onto the "Clear" element. Be sure to enter a 0 for x and a 0 for y, if those numbers are not already there and if those are the coordinates at which you want Kitty to start.

  4. It's time to choose a color for Kitty's pen. Go to the Pen category and find the element that says "Set Pen Color to..." and is followed by a colored block (not the one followed by a white space for a number to be typed in). Drag it over to the center panel and snap it on to your "Go To x:__ y:__" element. Click on the color that you want for Kitty's pen.

    Cropped screenshot of a set pen color block in the program ScratchImage Credit: Scratch, Science Buddies / Science Buddies
    Figure 8. This block allows you to change the color of the pen.
  5. Now Kitty has a pretty pen, but you have to tell her to use it! Go to the Pen category, and find the element called "Pen Down" and snap it to the bottom of your growing chain of computer language commands (called blocks). This will tell Kitty to put her pen down on the page.

    Cropped screenshot of a pen down block in the program ScratchImage Credit
    Figure 9. This block lowers the pen, allowing the sprite to draw as it moves.
  6. Now it gets exciting. It's time for Kitty to learn how to draw her first shapes. Remember from the Introduction how you taught your friend to draw a square and a triangle using steps and angles? Go to the Motion category and take a look at the elements that begin with "Move" and "Turn."

    Cropped screenshot of a move steps block in the program ScratchImage Credit: Scratch, Science Buddies / Science Buddies
    Figure 10. The move block is used to move the sprite a certain number of steps in the direction it is currently facing. The turn block is used to rotate the sprite by a specified number of degrees.

    That's exactly what you did when you walked the path of the square and the triangle—you moved and turned, moved and turned, moved and turned, over and over again until you completed the shape. So you know you're going to need those two elements in your list of instructions.

    • Move the "Move" and "Turn" elements to the center panel and type in some starting values, like 60 steps and 90 degrees, just to get started. You will change these values during your testing.

    But how do you make Kitty do something over and over again? That's where the Control category can help you. Look at the "Repeat" element. Any instructions you put inside the repeat element will be repeated again and again!

    Cropped screenshot of a repeat block in the program ScratchImage Credit
    Figure 11. This block has a space where you can insert a numerical value, and the block will then repeat the attached code or blocks of code that many times.

    • Move the "Repeat" element to the center panel and type in a starting value of 20 (indicating to repeat 20 times). You will change this value during your testing.

    Arrange the "Move," "Turn," and "Repeat" elements in a way that you think will make Kitty draw shapes. Hint: Notice the white space between the "Repeat" element's golden shape—do you think that will help you use this block? You can stuff as many blocks inside there as you want and they will all be repeated the number of times that you have set.

  7. It's not time to test just yet. First, you need to make Kitty put the pen away and move herself out of the way after she is done drawing, so that you can see what shape she has made. Go back to the Pen category and drag over the Pen Up element, which means "Take your pen off the paper, Kitty!"
    Cropped screenshot of a pen up block in the program ScratchImage Credit
    Figure 12. This block lifts the pen, so the sprite will no longer draw anything as it moves.
  8. To get her to move out of the way, you want to move her to a coordinate that is away from her drawing, like the red circle shown in the graph several steps above. Use the "Go To x:__y:__" element in the Motion category again to get her to move out of the way.

    Cropped screenshot of a go to x and y coordinate block in the program ScratchImage Credit: Scratch, Science Buddies / Science Buddies
    Figure 13. This block moves the sprite to the specified x and y position on the screen.

    Enter -150 for the x-coordinate, and 0 for the y-coordinate. Feel free to choose a different ending location.

  9. Finally, you want Kitty to look at her masterpiece, not up in the sky or down at the ground. Choose the "Point in Direction..." element from the Motion category to get her to look right. Leave the number as is, reading 90 (which means 90 degrees).

    Cropped screenshot of a point in direction block in the program ScratchImage Credit: Scratch, Science Buddies / Science Buddies
    Figure 14. This block has a space where you can input a numerical value representing the angle in degrees. When the block is executed, the sprite will adjust its orientation to face the specified direction.

Testing Your Computer Program

  1. Now that your program is written, you need to test it and adjust it to get Kitty to draw certain shapes. It's time to experiment. To start running the program, just click the green flag above the white screen where you see Kitty.
  2. What happened? Did she draw a shape? What shape is it? Experiment with the values in the "Move," "Turn," and "Repeat" elements to see what shapes you can get her to draw. Create a data table in your lab notebook, like the one below, so that you can remember what different values do in your program. If you need help with your program, read the Science Buddies Troubleshooting a Program in Scratch page.


Number of repeats Number of steps Turn in degrees Shape Kitty drew Comments on the shape, such as its size, or whether it went off the page
20 60 90  
     
     
Table 1. Scratch Testing Data Table

  1. Get Kitty to draw all the basic shapes, like a line, a triangle, a square, a hexagon, an octagon, and a circle. The circle is an interesting challenge, because there are no angles, so you will have to make very small turns and get a shape that approximates a circle. Once you've completed it, would you say it's a very good approximation? Does it look like a circle to you?
    1. Use a protractor to measure the amount of turn needed to draw each shape. For example, to draw a square, you need to turn 90 degrees. To draw a triangle, you might want to try having Kitty turn 120 degrees. These are values to test (one at a time) in your computer program. If you don't know how to use a protractor, see the link to instructions in the Bibliography.
    2. Can you get Kitty to draw different sizes of shapes, such as a small triangle, a medium-sized triangle, and a big triangle?
    3. Can you make Kitty draw slow and fast?
    4. How does the "Repeat" element affect how long Kitty draws?
    5. How does the "Steps" element affect the size of the shape?
    6. How does the "Turn" element affect the type of shape?
icon scientific method

Ask an Expert

Do you have specific questions about your science project? Our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Global Connections

The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.

This project explores topics key to Industry, Innovation and Infrastructure: Build resilient infrastructure, promote sustainable industrialization and foster innovation.

Variations

  • Would you like to change the way Kitty looks? Click on the Looks category for all sorts of fun things to try.
    • There are two elements called "Change Color Effect By..." and "Set Color Effect to..." Experiment with those to see what happens to Kitty. Can you make Kitty turn pink with one of these blocks?
    • Note: When you are experimenting with how something looks, it is best to add the "Clear Graphics Effects" element near the top of the chain of blocks, so that you can start with a fresh, new look each time you click on the green flag.
    • Once you understand what these blocks do for the word Color, click on the word "Color" in each element and you can see even more exciting things to try, like changing "Fisheye," "Whirl," "Pixelate," "Mosaic," "Brightness," and "Ghost." Experiment again to see what each of those does. Is there one you like best? Is there a block that has the power to turn one kitty into many kittens?
    • Another way to change Kitty's look is with the "Switch to Costume" element. You first have to go to the sprite panel, click on Kitty, then in the upper left of the screen click on the "Costume" tab. Then, either draw something yourself with the tools there, or import (bring in) something that you want to change Kitty into, like a puppy or a fish from one of the folders that you see, like the Animals or Fantasy folders.
    • And, just for fun, you can always make Kitty say something at the end of her drawing, like "Ta Da!" or "Where did Kitty go?" (if she has changed into a different animal). The "Say" elements allow you to have Kitty say whatever you wish.
  • If you can teach Kitty how to draw equilateral shapes (shapes that have sides that are the same length), can you teach her how to draw shapes with sides of different lengths, like a rectangle?
  • When you were testing your program, did Kitty draw some unusual shapes that look like flowers? Or beautiful lace? Can you make Kitty color in the flowers by changing the pen size? Can you make Kitty draw a whole flower garden? Make sure she draws herself some catnip!

Careers

If you like this project, you might enjoy exploring these related careers:

Career Profile
Computers are essential tools in the modern world, handling everything from traffic control, car welding, movie animation, shipping, aircraft design, and social networking to book publishing, business management, music mixing, health care, agriculture, and online shopping. Computer programmers are the people who write the instructions that tell computers what to do. Read more
Career Profile
Mathematicians are part of an ancient tradition of searching for patterns, conjecturing, and figuring out truths based on rigorous deduction. Some mathematicians focus on purely theoretical problems, with no obvious or immediate applications, except to advance our understanding of mathematics, while others focus on applied mathematics, where they try to solve problems in economics, business, science, physics, or engineering. Read more
Career Profile
Are you interested in how a website is set up and how the website runs? As a web developer and designer you could design a website's look and feel and create the code to make sure the website works. You could set up a website for your favorite store with payment options, making sure it works with the ever growing list of browsers and devices. Do you like working behind the scenes? You could design the layout or write the supporting code for an app or website while collaborating with other web… Read more

News Feed on This Topic

 
, ,

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Science Buddies Staff. "Quick Draw McPaws: Teach A Computer Kitty How to Draw Shapes." Science Buddies, 17 Jan. 2024, https://www.sciencebuddies.org/science-fair-projects/project-ideas/CompSci_p035/computer-science/program-a-computer-kitty-to-draw-shapes. Accessed 19 Apr. 2024.

APA Style

Science Buddies Staff. (2024, January 17). Quick Draw McPaws: Teach A Computer Kitty How to Draw Shapes. Retrieved from https://www.sciencebuddies.org/science-fair-projects/project-ideas/CompSci_p035/computer-science/program-a-computer-kitty-to-draw-shapes


Last edit date: 2024-01-17
Top
Free science fair projects.