Drawing leaves

Page 16

On this page we'll learn how to draw a leaf. But let's first think about circles. Long ago we learned to draw circles. We did it like this:

REPEAT 360 [FD 1 RT 1]

You can see that by looking in the editor at the CIRCLE word. How do we draw half a circle? Try to figure it out before you read on.

This is how: change 360 to 180. Let's make that a parameter so we can change it easily:

TO CIRCLE :x
  REPEAT :x [FD 1 RT 1]
END

Now we can draw half a circle by just writing CIRCLE 180. We can draw less than half a circle also. Try CIRCLE 100.

What does this have to do with leaves? Look at this picture of one:

A leaf

It's just two CIRCLE 100 on opposite sides. So how can we draw a leaf? Try to figure it out yourself. Take your time.

Here's how I would walk to draw a leaf. (If I were a turtle.) First I would draw CIRCLE 100. Then I would turn RT 80. Why? Because in CIRCLE 100 I turn RT 1 100 times. That means I turn 100 degrees altogether. 100+80=180. So If I turn 80 degrees more I have turned halfway round. Then I can just do the same thing again and have a leaf! Like this:

REPEAT 2 [CIRCLE 100 RT 80]

Let's call that LEAF:

TO LEAF
  REPEAT 2 [CIRCLE 100 RT 80]
END

That's it! There's only one problem with our leaf. It's always the same size. That's a problem with the circle too. So let's fix the CIRCLE first.

I would add another parameter to CIRCLE. Like this:

TO CIRCLE :x :size
  REPEAT :x [FD :size RT 1]
END

Try writing CIRCLE 100 1 and CIRCLE 100 2. Do you understand why it works? Can you change LEAF in the same way?

These are the words we know now. They are the same as on the last page:

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
; Don't listen to me now
PRINT [I'm a turtle!] Say "I'm a turtle!"
RANDOM 10 Choose a number from 0 to 9
WAIT 60 Wait for 1 second.
PRINT 2+2 Makes the turtle say 4
TO SQUARE :top Put 5 in your :top pocket when I say SQUARE 5
REPCOUNT The number of the repetition

These are the words we have taught the turtle. LEAF is new. We also added a parameter to CIRCLE:

New Logo word What it means
SQUARE :top Draw a square
CIRCLE :x :size Draw a circle
STAR :number :length Draw a star
LEAF Draw a leaf

(Did you add a parameter to LEAF? Did it work?)

Turn page, or go back to the table of contents.