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

クロソイドグラフィック

クリックしてね
CLICK!
Get Adobe Flash player
by 178ep3 12 Jun 2009
/**
 * Copyright 178ep3 ( http://wonderfl.net/user/178ep3 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wydx
 */

//クリックしてね
//CLICK!

package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.MouseEvent;

	public class Contents extends Sprite
	{
		private var  _stage:Stage;
		private var _stg:Sprite;
		private var _list:Array = [];
		private var _bmd:BitmapData;
		private var _bmp:Bitmap;
		
		public function Contents()
		{
			_stage = stage;
			init();

                        addEventListener(Event.ENTER_FRAME,loop);
			_stage.addEventListener(MouseEvent.CLICK,clickH);
		}
		
		private function init():void
		{
                       this.graphics.beginFill(0x00);
                       this.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
                       this.graphics.endFill();

			_stg = new Sprite();
			_bmd = new BitmapData(2000,1300,true,0x000000);
			_bmp = new Bitmap(_bmd);
			addChild(_bmp);
		}
		
		
		private function clickH(e:MouseEvent = null):void
		{
			var _color:uint = Math.random()*0xffffff;
			var max:uint = Math.random()*10+2;
			for(var i:uint=0; i<max; i++)
			{
				var g:Clothoid = new Clothoid(_color);
				_stg.addChild(g);
				g.rotation = Math.random()*360;
				g.x = mouseX;
				g.y = mouseY;
				_list.push(g);
			}
		}
		
		private function loop(e:Event):void
		{
			var len:uint = _list.length -1 ;
			for(var i:int=len; i>-1; i--)
			{
				if(!_list[i].Move())
				{
					_stg.removeChild(_list[i]);
					_list.splice(i,1);
				}
			}
			_bmd.draw(_stg);
		}
	}
}

import flash.display.Sprite;
import flash.display.Shape;
import flash.display.Stage;

class Clothoid extends Sprite
{
	private var _x:Number=0;
	private var _y:Number=0;
	private var _radian:Number=0;
	private var _addRad:Number = Math.random()*0.05 + 0.05;
	private var _max:Number = Math.random()*4+1;
	private var _size:Number = Math.random()*5+1;
	
	private var _mx:Number = 0;
	private var _my:Number = 0;
	
	private var _color:uint;
	private var _alpha:Number = Math.random()*0.3+0.2;
	private var _r:Number = Math.random()*50 +10 ;
	
	
	public function Clothoid(color:uint)
	{
		_color = color;
	}
	
	public function Move():Boolean
	{
		_x += ((_addRad * Math.cos(Math.pow(_radian,2)))*_r);
		_y += ((_addRad * Math.sin(Math.pow(_radian,2)))*_r);
		_radian += _addRad;	
		_size *= 0.97;	
		with(this.graphics)
		{
			clear();
			lineStyle(_size,_color,_alpha);
			moveTo(_mx,_my);
			lineTo(_x,_y);
			endFill();
		}
		_mx = _x;
		_my = _y;
			
			
		if(_radian>=_max)
		{
			return false;
		}
		return true;
	}
}