Spirals
We will now draw our first recursive function with the turtle. The goal is
to draw different kind of spirals with the same function, which prototype is
the following:
[!java]void [/!]spiral([!java]int [/!]steps[!scala]:Int[/!], [!java]int [/!]angle[!scala]:Int[/!], [!java]int [/!]length[!scala]:Int[/!], [!java]int [/!]increment[!scala]:Int[/!])
To help you understanding how to write it, here is an example of how the
parameters change during one specific call:
spiral(5, 90, 0, 3);
forward(0);
left(90);
spiral(4,90,3,3);
forward(3);
left(90);
spiral(3,90,6,3);
forward(6);
left(90);
spiral(2,90,9,3);
forward(9);
left(90);
spiral(1,90,12,3);
forward(12);
left(90);
spiral(0,90,12,3);