As Quiz #13 solution
Move your mouse left and right
/**
* Copyright shapevent ( http://wonderfl.net/user/shapevent )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jCUU
*/
// Move your mouse left and right
package {
import flash.display.Sprite;
import flash.events.Event;
public class RecursiveSpiral extends Sprite {
[SWF(width = 500, height = 500)]
public function RecursiveSpiral() {
/////////////////////////
scaleX = scaleY = 0.5;
x = stage.stageWidth / 2;
y = stage.stageHeight / 2;
addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
graphics.clear();
graphics.lineStyle(0,0);
spiral(mouseX, 200);
}
function spiral(step:Number= 10, maxIter:Number=100, x:Number=0, y:Number=0, inc:Number = 1):void{
if (inc < maxIter){
var theta:Number = inc * step * Math.PI / 180;
graphics.lineTo(x, y);
spiral(step, maxIter, x + theta * Math.cos(theta), y + theta * Math.sin(theta), inc + 1);
}
}
/////////////////////////
}
}
}