Circles and stars

Page 7

If you want the turtle to draw a circle -- Think Turtle. How would a turtle walk? Try walking. Then write in your Logo program.

Look at these pictures:

More and more like a circle

The first is not at all like a circle. The second is more like a circle. The third is almost a circle.

The first is a square. We can draw it like this:

REPEAT 4 [FD 100 RT 90]

(If we want the same color as in the picture we must change it. Can you do that?) The second we can draw like this:

REPEAT 8 [FD 100 RT 45]

It gets bigger than in the picture. If you want it to be smaller the turtle should take shorter steps. The third we can draw like this:

REPEAT 12 [FD 100 RT 30]

If we repeat more times we should make smaller turns. The smaller turns we make the better the circle gets. Can you draw an even better circle? Try. At the end of the this page I will make one too.

Now let's draw a star! We only need to add one word:

BK 100

Where should we add it? After FD 100. Like this:

REPEAT 12 [FD 100 BK 100 RT 30]

Great! But why is it not a circle anymore? Think Turtle -- walk like the turtle would walk. Then you will understand. Remember: BK 100 means that the turtle should walk backwards 100 steps.

Let's teach the turtle a new word for star. Open the editor with "Edall". Then write:

TO STAR
  REPEAT 12 [FD 100 BK 100 RT 30]
END

Then click "File" and "Save and Exit". Just like before.

I promised you that I would make a better circle at the end. Here it is:

REPEAT 360 [FD 1 RT 1]

Let's teach Logo what a circle is. Open the editor with "Edall":

TO CIRCLE
  REPEAT 360 [FD 1 RT 1]
END

Click "File" and "Save and Exit". Now the turtle knows how to make a circle too!

These are the words we know now:

Logo word What it means
FD 100 Walk forward 100 steps
BK 100 Walk backward 100 steps
LT 90 Turn left (good for drawing squares)
RT 90 Turn right (good for drawing squares)
LT 120 Turn left (good for drawing triangles)
RT 120 Turn right (good for drawing triangles)
CS Remove everything you have drawn
HOME Move back to the starting point (and draw a line)
PU Lift the pen so you won't draw when you walk
PD Put the pen towards the screen again
REPEAT 10 [       ] Repeat what's in the box 10 times
SETPC 4 Change the pen to pen number 4
TO ... END Remember the word after TO in the future

They are the same as on the last page. We could draw circles and stars with the words we already knew. Turtles can do much with few words.

These are the new words we have taught the turtle:

New Logo word What it means
SQUARE Draw a square
CIRCLE Draw a circle
STAR Draw a star

Turn page, or back to the table of contents.