11. Draw spirals¶
In this practice we are going to move a character around the screen so that it draws several colored spirals.
We start the Scratch editor.
Press the language button in the top bar and choose English.
We add a new variable Side that will store the size of the side that is currently being drawn.
We change the name of the variable to Side
We add a new extension with the button add extension down left.
We select the Pencil extension to be able to draw.
A new icon will appear in the code bar, the Pencil , with dark green instructions.
We create a new block called start.
First click on the button my blocks
Then we change the name of the new block to start
The start block will be used to start the program. It will move the cat to the center of the screen with small size. Hide the Side variable, lower the pen to paint, set the pen thickness and color, and clear the screen.
We create a new block called square.
First click on the button my blocks
Then we change the name of the new block to square
The square block will be used to draw a square spiral on the screen.
The size of the side starts with the value 5 and grows by 4 steps until it is equal to or greater than 340.
Each step draws a line of "Side" size, increases the size of the side, rotates 90º and increases the color of the pencil.
If we click on the "define square" block, the square spiral will appear on the screen.
Now we are going to create a new block called triangle.
First click on the button my blocks
Then we change the name of the new block to triangle
The triangle block is very similar to the square block, only the angle of rotation changes.
To take advantage of the program already done, we are going to click with the right mouse button on the square instructions and choose the duplicate option.
Once the program has been duplicated, we hook it to the triangle block and change the angle of rotation.
If we click on the block "define triangle", the triangular spiral will appear on the screen.
Challenges¶
Make a new block that draws a star spiral. Modify the parameters of the new block to rotate 150 degrees.
Create a new block to draw an octagonal spiral. Turns must be 45 degrees. The side must add to 1 on each repetition and must be repeated until the side is greater than 150.
Experiment with the program to create new original drawings.