AS Quiz #13

Today’s quiz is not multiple choice. Instead, your task is to draw a spiral using a recursive function.

Optionally you can alter your function to draw other types of spiral forms:

(You can view various solutions in the comments – as well as my solution at wonderfl)

6 comments

  1. This is my approach:

    var g:Graphics = graphics;
    g.lineStyle(1, 0x000000);
    g.moveTo(stage.stageWidth/2, stage.stageHeight/2);
    drawSpiral(0, 0);
    function drawSpiral(r, alpha){
    g.lineTo(stage.stageWidth/2+r*Math.cos(alpha), stage.stageHeight/2+r*Math.sin(alpha));
    if (r>100)
    return;

    drawSpiral(r+1,alpha+0.2);
    }

Leave a Reply

Your email address will not be published. Required fields are marked *