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: TreeCurve

added : Line width & alpha
木に見えるフラクタル
Get Adobe Flash player
by Yukulele 07 Mar 2009
// forked from ton's TreeCurve
// added : Line width & alpha
//木に見えるフラクタル
package {
	import flash.display.Sprite;
	import flash.events.*;
	import flash.geom.Point;
	[SWF(backgroundColor=0x000000)]
	public class TreeCurve extends Sprite {
		private var list:Array = new Array();
		private const SIZE:int = 465;
		private const RAD:Number = Math.PI/8;
		private const a:Number = 0.75;
		function TreeCurve() {
                    stage.frameRate=30;
	            addLine(new Line(new Point(SIZE/2, SIZE), new Point(SIZE/2, SIZE*4/5)));
	    	    stage.addEventListener(Event.ENTER_FRAME,onEnterFrameHandler);
		}
		private function onEnterFrameHandler(event:Event):void {
		    var line:Line=list[0];
		    list.splice(0, 1);
		    addLine(new Line(line.endP, new Point(line.endP.x + line.distance * a * Math.cos(line.angle + RAD), line.endP.y + line.distance * a * Math.sin(line.angle+RAD))));
		    addLine(new Line(line.endP, new Point(line.endP.x + line.distance * a * Math.cos(line.angle - RAD), line.endP.y + line.distance * a * Math.sin(line.angle - RAD))));
		}
		private function addLine(line:Line):void {
		    list.push(line);
		    addChild(line);
		}
	}
}
	
import flash.display.Shape;
import flash.geom.Point;
class Line extends Shape {
	public var startP:Point;
	public var endP:Point;
	public var distance:Number;
	public var angle:Number;
        public static var distanceMax:Number=0;
	function Line(startP:Point, endP:Point) {
		this.startP = startP;
		this.endP = endP;
		angle = Math.atan2(endP.y-startP.y, endP.x-startP.x);
		distance = Point.distance(startP, endP);
                distanceMax=Math.max(distance,distanceMax);
		graphics.lineStyle(distance/10,0xffffff,distance/distanceMax);
		graphics.moveTo(startP.x, startP.y);
		graphics.lineTo(endP.x, endP.y);
		graphics.endFill();
	}
}