Академический Документы
Профессиональный Документы
Культура Документы
STEP ER ANCLE
ANCLE
STEP EP
ANCLE
ANCLt
The turtle draws closed figures because it goes forward and rotates a fixed amount and it eventu ally gets back to where it started. We can easily have the turtle draw a spiral by increasing its for ward step on each round of the procedure. Lets change p o l y and name it s p i and thus make a spi ral drawing procedure.
EDIT"POLY
po l y
procedure.
.S T E P 2
ANCLE ANCLE
103
We make one more change to the recursion line. We tell s p i to add 2 steps to :s t e p . Thus,
TO S P I : S T E P : A N G L E FD : S T E P RT : A N G L E S P I : STEP + 2 : ANGLE END
Now
try
s pi
n in
S P I 5 90 SP I 5 120 _ _ t c- i a SPI 5 60
Remember
c trl-g
stops.
CTRL-L s h o w s t h e w h o le t u r t l e
field.
u,
Try s p i with other inputs. Change s p i and give it a third input, :i n c , which s p i will add to :s t e p in stead of 2. Then you can change how much the turtles step increases by choosing different num bers for the third input.
ED "SPI
104
Now try
SPI
5 75
You might want to stop the turtle at different places. Try other inputs.