5.2.1 Drawing a square

View

Without loops, you can draw a square by drawing a certain length of line and then turns right 90 degrees, again and again until you complete the square. You will surely have your square shape, but you will have a lengthy thread of blocks.  For a complex shape you will feel confused with your own code. You need something shorter that does the same job.

Figure 139: Drawing a square

You can draw the same square with fewer blocks. All you need to do is using a type of loop called repeat until, which you find in the Control section.  Repeats allow you to draw shapes more quickly. They also enable you to create interesting patterns. To draw a square, you can just draw one side, turn, and repeat it 4 times.

Figure 140: Drawing Square using a repeat loop

Last modified: Wednesday, 6 October 2021, 3:39 PM