Skip to 0 minutes and 2 secondsLast week, you were introduced to Scratch. And one of the activities was using the pen features to draw shapes on the stage. In this video, I'm going to show you how you can use repetition to draw more interesting shapes and drawings. One of the things you drew last session was a triangle. So I'm going to recreate that. And we'll draw it when the sprite is clicked. And then I need to get the pen extensions. So let's add those blocks in. And now I can use a pen down block at the start. And then to draw a triangle, I'm going to need some move blocks and some turn blocks.

Skip to 0 minutes and 40 secondsSo I know I'm going to need to move and turn three times, once for each side of the triangle.

Skip to 0 minutes and 52 secondsAnd I remember from last week that a good length was 50 steps for each side. And then I had to turn 120 degrees around the outside of each angle of the triangle, because that's the value of the exterior angle. So let's update each of those blocks. So each time, we're moving 50 steps and then turning 120 degrees.

Skip to 1 minute and 23 secondsAnd then when I click the pencil, you'll see that it draws the triangle. Now, that's one way of drawing a triangle. But I'm going to show you how to use repetition to draw the shape more efficiently. The repeat block in Scratch is in the Control section. So I'm going to drag that repeat block into my coding area. And what I want to do is I still want to move and turn three times. But instead of using that code over and over again, I can put these two blocks inside the repeat block and give the instruction to repeat them three times. So now I don't need these blocks, so I'll just drag them back over into this area to delete them.

Skip to 2 minutes and 12 secondsYou'll notice that the pen down block is outside of the repeat block, because I only want that to happen once before drawing the three sides of the triangle. So let me bring in an erase all block so that we can clear the stage. And then let's click on the pencil, and you'll see that it draws the triangle exactly as it did before. Now I can draw some different shapes by repurposing the same code. So I could draw a square by repeating four times and turning 90 degrees each time.

Skip to 2 minutes and 55 secondsLet's try that out.

Skip to 2 minutes and 58 secondsThat's great. Or I could draw an octagon by repeating the code eight times and just turning 45 degrees each time.

Skip to 3 minutes and 14 secondsAnd you'll see, I only need to change these two numbers to draw lots of different shapes. And also, by using this repetition block, I can repurpose the code to make bigger shapes too. So what I need to do for that is to change this number. So I could choose to draw each side of the octagon so that it's 100 steps. Let's clear and try that one out. Oops. OK, let's clear and try that one again. That's better. Now, I'm not exactly sure what I want to draw next, so the next thing I'm going to do is just to tinker. For example, I don't know what this stamp block does.

Skip to 4 minutes and 0 secondsSo I'm going to drag it into my code, and I'm just going to see what it does. OK. So it stamps a copy of the sprite just before it moves and turns at the beginning of every side. I'm going to change the numbers as well. So I'm just going to choose a repeat number of, let's say, 40. And I'm going to decide to turn 130 degrees each time. And I think I'm going to take that stamp block out, because it doesn't really add to the drawing. And I'm not really sure what I'm doing here. I'm just tinkering with the code, making small changes, and then I'll click the pencil to see what happens. OK, so that's looking nice.

Skip to 4 minutes and 48 secondsI could make some more changes as well. So by looking at the pen blocks, I could decide that I want to change the pen size. So I could say, let's change the pen size by 3.

Skip to 5 minutes and 7 secondsAnd I've also noticed there's a change pen colour block. So I'm going to put that inside the loop so that each side of the shape is going to be drawn in a different colour.

Skip to 5 minutes and 23 secondsAnd that draws a very nice multicoloured shape. But what you'll notice is that the pen thickness is getting thicker each time. So what I think I will do is I will swap out that change pen size block for a set pen size block. And I'll put that at the start and set the pen size to 3. And now if I erase everything and try again, you'll see that it stays the same size. I'll just run it full screen as well so you can see that the pen size doesn't actually change size this time.

Skip to 6 minutes and 4 secondsAnd one final thing you'll notice is that the pencil doesn't actually end up facing in the right direction. And I'd quite like that to happen. So I'm going to add some code in to reset the stage and the sprites when I press the Spacebar. I'm going to make sure that the pen is pointing over to the right-hand side. So it's going to point in direction 90. And as you can see, that's pointing towards the right. I'm also going to make the pencil sprite go back to the centre of the stage when I press the Spacebar. And if you'll remember from week 1, the coordinates for the centre of the stage are x, 0, and y, 0.

Skip to 6 minutes and 48 secondsSo let's pop those values in here. And then, finally, from last week, you'll remember that the order of these instructions is very important too. So let's add the erase all block back in right at the end of this script. So now I can click the Spacebar to clear the stage. And I can click the pencil to draw a shape. And there's my drawing. Now you're going to have a go to see what you can create.

Repetition in Art

In this section, you’ll learn how to use repetition to draw simple shapes as well as more complex patterns.

This video shows how this can be done in Scratch, and demonstrates some simple examples.

Share this video:

This video is from the free online course:

Teaching Programming in Primary Schools

Raspberry Pi Foundation