Scratch exercise 111

Spirograph

In this exercise you will create 5 scripts, each of which draw a different geometric pattern automatically.

 

NOTE: You can use any version of Scratch.

 

Complete these steps ..

 

1. Open Scratch, OR create a new game (from the top menu choose "File>New").

 

 

 

2. Delete the Cat sprite then select the stage and paint in black. This is essential if the sprites are to be as visible as possible.

 

 

3. Now create these variables ("for all sprites") ..

Hide "degrees" and then right-click "Which pattern" on the stage and choose "large readout". We will use this variable to display which pattern is currently being drawn.

 

 

4. Add this code/scripts to the stage ..

 

 

5. Use the File menu to save your game. Name it "Spirograph v1" ..

 

 

6. Use the "Paint new sprite" to create a new sprite which consists of a single black dot. Use the smallest paintbrush size ..

 

Click "OK" to finish and re-name the sprite "Nib 1". A nib is the tip of a pen. Our pen nib will be used to draw the patterns.

 

 

7. Add this code/script to "Nib 1" ..

Note: If you are using Scratch Desktop you will need to load the Pen code blocks and use "erase all" instead of "clear").

 

This code/script cleans up the stage if you stop a pattern whilst it is being drawn.

 

 

8. Duplicate "Nib 1" four times and re-name the sprites "Nib 2", "Nib 3", "Nib 4" and "Nib 5".

 

 

9. Select "Nib 1". You will now add the code/script which draws the first pattern. This first pattern is simple, like the spokes in a wheel. Take the time to look at the code/script and understand how it works. Note the following ..

 

Press the "B" key on your keyboard and then "1" to test your game.

When you are ready, press the "E" key to end your game and continue working on it.

 

 

10. Use the File menu to save your game.

 

 

11. Select "Nib 2" and add the second pattern drawing code/script. This is almost the same as the "Nib 1" code/script but this time the spokes curve a little (2 degrees) and there is a flourish at the end of each ..

 

Press the "B" key and then "2" to test your script. Press "E" to end when you are done.

 

 

12. Use the File menu to save your game.

 

 

13. Create the code/script for "Nib 3". This time each "spoke" has two curves and a flourish requiring 3 repeat blocks ..

 

Press the "B" key and then "3" to test your script. Press "E" to end when you are done.

 

 

14. Use the File menu to save your game.

 

 

15. Create the code/script for "Nib 4". This time each "spoke" has a curve, a reverse straight line ("move -10 steps") and a circle flourish ..

 

Press the "B" key and then "4" to test your code/script. Press "E" to end when you are done.

 

 

16. Use the File menu to save your game.

 

 

17. Create the final "Nib 5" pattern code/script. This time we have added repeat loops within repeat loops to create squares and pentagon shapes for each spoke ..

 

Press the "B" key and then "5" to test your script. Press "E" to end when you are done.

 

 

18. Use the File menu to save your game.

 

 

19. Well done. You've finished. Can you create additional patterns by adding more nibs?