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: この木なんの木 ランダム化

// forked from undo's この木なんの木キモい木
package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Point;
	
	[SWF(width='465',height='465')]
	public class Test extends Sprite
	{
		private var _omegaBase:Number = Math.PI/5;//枝の開き具合
		private var _devPerBase:Number = 1/4;//枝が開くまでの長さ
		private var _devideTime:int = 10;//枝わかれする回数 15くらいを超えると重いよ!
		
		
		public function Test()
		{
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		private function init(evt:Event = null):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			this.stage.align = StageAlign.TOP_LEFT;
			this.stage.scaleMode = StageScaleMode.NO_SCALE;
			
			//this.graphics.lineStyle(0,0);
			drawLine(new Point(230,350),new Point(230,50), this._devideTime);
		}
		
		private function drawLine(pa:Point, pb:Point, devide:int):void
		{
			var _omega:Number = this._omegaBase * Math.random();
			var _devPer:Number = this._devPerBase * Math.random();
			
			
			this.graphics.lineStyle(devide, Math.random()*0xffffff);
			this.graphics.moveTo(pa.x,pa.y);
			var def:Point = new Point(pb.x-pa.x,pb.y-pa.y);
			this.graphics.lineTo(pa.x + def.x*_devPer,pa.y + def.y*_devPer);
			if(devide != 0)
			{
				var radian:Number = Math.atan2(def.y, def.x);
				var radius:Number = Math.sqrt(def.x*def.x*(1-_devPer)*(1-_devPer) + def.y*def.y*(1-_devPer)*(1-_devPer));
				this.drawLine(new Point(pa.x + def.x*_devPer,pa.y + def.y*_devPer),new Point(pa.x + def.x*_devPer + Math.cos(radian+_omega)*radius, pa.y + def.y*_devPer + Math.sin(radian+_omega)*radius),devide-1);
				this.drawLine(new Point(pa.x + def.x*_devPer,pa.y + def.y*_devPer),new Point(pa.x + def.x*_devPer + Math.cos(radian-_omega)*radius, pa.y + def.y*_devPer + Math.sin(radian-_omega)*radius),devide-1);
			}
		}
	}
}