In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: 再帰関数でフラクタル

再帰関数っていうものを使ってみたかった。
基本的な考えは合ってるはず
Get Adobe Flash player
by hacker_9p8x8mco 14 Feb 2010
    Embed
/**
 * Copyright hacker_9p8x8mco ( http://wonderfl.net/user/hacker_9p8x8mco )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rwvp
 */

// forked from cpu_t's 再帰関数でフラクタル
// 再帰関数っていうものを使ってみたかった。
// 基本的な考えは合ってるはず
package {
    import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	[SWF(width = 465, height = 465, backgroundColor = 0xFFFFFF, frameRate = 60)]
    public class FlashTest extends Sprite {
        public function FlashTest() {
			addEventListener(Event.ADDED_TO_STAGE, init);
        }
		
		private function init(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			drawLine(stage.stageWidth * .2, stage.stageHeight * .5, 15, 0);
		}
		private function drawLine(x:Number, y:Number, n:Number, a:Number):void
		{
			if (n < 0) return;
			this.graphics.lineStyle( -1, 0x000000);
			this.graphics.moveTo(x, y);
			x += Math.cos(a) * n * 3;
			y += Math.sin(a) * n * 3;
			this.graphics.lineTo(x, y);
			drawLine(x, y,--n, a + (20) / 180 * Math.PI);
			drawLine(x, y,--n, a + (-80) / 180 * Math.PI);
		}
    }
}