Home
Project Folders
Teacher Resources
Student Resources
En ESPAÑOL
How Do I?
Literacy
MWForum
Site Map
Search
Our Team

spirals 1 2 3 4 5 6 7 8 9
Spirals 8
Try It
114 KB


Goal:   A spiral grows and shrinks with embedded recursion.


Screenshot


Code
Project Map

to spiral :length :pitch
pd
if :length > howbig [stop]
setc whatcolor
setpensize howthick
fd :length rt angle
carefully [note :pitch 3] [ ]
spiral :length + howtight :pitch - 1
fd :length rt angle
carefully [note :pitch 3] [ ]
end

to reset
cg
end



Notes

This project uses embedded recursion, when the recursive call is not the last line of the procedure.   At first the computer does not run the commands following the recursive call, but it does not ignore them, either; instead, it stores these commands to run later.   When the procedure reaches the stopping point - in this case, when the value of length is greater than the number on the howbig slider - there are no more recursive calls...   but now, the stored-up commands following the recursive call begin to run, from the most recent to the earliest.

This means that if you repeat the same commands after the recursive call as before it, the spiral will first grow and then shrink.   The notes will deepen and then grow high again.




What If?
Experiment with the sliders to find some pleasing designs.


Challenge
As in Spirals 7, create a different procedure (call it new_spiral, perhaps), and place in this procedure the commands that do not change while the spiral procedure is in progress (in this case, the setc and setpensize commands).   Remove these commands from the spiral procedure.   Then call the spiral procedure from within the new procedure.




© copyright 2001 - 2008  OpenWorld Learning.   All rights reserved.