1. Draw a spiral¶
In this practice we are going to move a character so that it draws a spiral with colors on the screen.
We start the Scratch editor.
We delete the cat by clicking on it with the right mouse button and then pressing delete.
We added a new character, a polar bear.
Press the new object button
Then click on Animals Category.
Then we select the bear2 object.
In the Programs tab we create a new function called Startup.
First click on the button more blocks
Then click on create a block
Then we change the name of the new block to Home
Finally we press the button OK
We program the Start function with the following instructions
With this initial program, the polar bear will be placed in the center of the screen at a small size and all previous drawings will be erased. In this way everything will start blank every time we run the program.
Now we will create the variable Side that will store the size of the side of the spiral.
Within the Data tab,
press create a variable
We change the name of the variable to Side
Finally we press the button OK
Finally we will create the program that draws a spiral.
Finally we will click on the green flag to see the result:
Exercises¶
Modify the program so that it draws an octagonal spiral. The turns must be 45 degrees and in each turn the Side must change 1. The spiral must stop when the size of the Side is greater than 147.
Modify the program so that it draws a hexagonal spiral (with 60 degree turns)