Topic 5 - Shortcuts to Regular Polygons

Drawing a square with 8 commands is a bit tedious and drawing a shape with 20 sides would be much worse!

Fortunately the turtle understands a much shorter instruction for drawing a shape:

REPEAT 4[FD 50 RT 90]

Try it!

 

 

 

This line tells the turtle to repeat something 4 times, the something being the list of instructions in the SQUARE brackets. Make sure you use SQUARE brackets!

Notice that 4 times 90 = 360. Why?

You can draw other shapes easily now, for example:

REPEAT 6[FD 40 RT 60]

With this knowledge you can draw any regular polygon.

Try a 60-sided polygon:

REPEAT 60[FD 4 RT 6]

 

 

 

 

This comes close to another common shape because the computer does't have a fine enough screen to show such short lines.

You can fill a closed shape such as a square with a solid colour using the FILL primitive. You cannot fill a shape with FILL while the turtle is still on the line of the shape, you must move slightly inside it, for example:

REPEAT 8[FD 40 RT 45]
RT 90
FD 20
FILL
BK 20
SETPC 10
LT 90

REPEAT 8
[FD 40 LT 45]
LT 90
FD 20
FILL BK 20
RT 90
SETPC 11

 

 

 

 

 

 

 

 

 

Notice how the turtle is returned to the previous position by issuing the reverse commands, for example, RT 90 always follows LT 90 and BK 20 always follows FD 20.

A classic Logo problem is drawing a house. The main part of the house is simple, just a rectangle. For the doors and windows you can also use rectangles, but you will have to use PU and PD to move the turtle to the correct place for each one. Drawing the roof is more tricky as it involves a trapezium shape.

As an exercise try drawing a house with a door, windows and roof (use a triangle for the roof if you cannot manage a trapezium).

Return to Logo Home Page