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

flash on 2009-11-1

マウスのまわりをラインがうねうねをdraw
@author ibu4gin
いろいろぱくってます
Get Adobe Flash player
by ibu4gin 02 Nov 2009
    Embed
/**
 * Copyright ibu4gin ( http://wonderfl.net/user/ibu4gin )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/m3Rm
 */

/*
マウスのまわりをラインがうねうねをdraw
@author ibu4gin
いろいろぱくってます

*/
package {
	import flash.display.Sprite;
	import flash.display.Graphics;
	import flash.display.Shape;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.BlendMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.geom.Matrix;
	import flash.geom.ColorTransform;
	import flash.filters.ColorMatrixFilter;
	import flash.filters.BlurFilter;
	
	
	public class line extends Sprite
	{
		private var pptArr     :Array = [];
		private var canvas     :BitmapData;
		private var bmp        :Bitmap;
		private var line_base  :Sprite;
		private var canvas_base:Sprite;
		private var test_flg:Boolean = false;
		private var S_W        :Number;
		private var S_H        :Number;
		
		public function line():void
		{
		    Wonderfl.capture_delay( 2 );
			stage.frameRate = 60;
			S_W = 465;
			S_H = 465;
			
			line_base   = new Sprite(); 
			canvas_base = addChild( new Sprite() ) as Sprite; 
			
			canvas = new BitmapData(S_W,S_H,true,0x00FFFFFF);//0x00
            bmp    = new Bitmap( canvas );
			canvas_base.addChild( bmp );
			
			for(var v:uint = 0;  v < pptNUM; ++v)pptArr[v] = new PhyPo(S_W/2, S_H/2);
			
			if(test_flg){
				addChild( line_base );
			}
			
			addEventListener(Event.ENTER_FRAME, render)
		}
		
		// レンダリング
		private function render(E:Event):void
		{
			
			Line_Loop();
			
			if(!test_flg){
			
			bmpDraw();
			
			fadeStep();
			
			}
			
		}
		
		
		// フィルターetc
		private var mat     :Matrix;
		private var rota_num:Number;
		private var po      :Point             = new Point();
		private var BLURFil :BlurFilter        = new BlurFilter(4,4,2);
		private var ColorTR :ColorTransform    = new ColorTransform(Math.random()*0.4+0.6,Math.random()*0.4+0.6,Math.random()*0.4+0.6,1,0,0,0,0);
		private var CoMatFil:ColorMatrixFilter = new ColorMatrixFilter([2,   0,   0,   0,   -100, 0,   2,   0,   0,   -100,	0,   0,   2,   0,   -100,0,   0,   0,   1,   0]);
																		
		private function bmpDraw():void
		{
			canvas.draw(line_base, mat, null, BlendMode.ADD, null, true);//6ADD//2SCREEN//
		}
		
		
		public function fadeStep():void
        {
			canvas.applyFilter(canvas, canvas.rect, po, BLURFil);
			//canvas.applyFilter(canvas, canvas.rect, po, CoMatFil)
			//canvas.colorTransform(canvas.rect, );
        }
				
		// ライン生成
		private var KN        :Number = 4;//4
		private var tenPo_X   :Number = 0;
		private var tenPo_Y   :Number = 0;
		private var hankei    :Number = 100;//400-200
		private var angle     :Number = 0;
		private var yuragi_num:Number = 0;
		private var my_byo    :Number = 0;	
		//ラインのポイント数
		private var pptNUM    :int    = 10;//10
		
		private var mouseXX:Number;
		private var mouseYY:Number;
		
		private function Line_Loop(E:Event = null):void
		{
			
			my_byo += 0.02;//0.02
			yuragi_num =  -5000 * Math.sin( my_byo * Math.PI * 2 * 0.1 );///1000
			yuragi_num = yuragi_num | 0;
			angle += 0.00001 * yuragi_num;//0.0001//
			
			
			if( hankei < 300 ){//400
				hankei += 1;
			}
			
			mouseXX = mouseX-50;
			mouseYY = mouseY+50;
			//mouseXX = (S_W/2 -50);
			//mouseYY = (S_H/2 +50);
			
			tenPo_X = mouseXX + hankei * Math.cos( angle + Math.PI * 2 );
			tenPo_Y = mouseYY + hankei * Math.sin( angle + Math.PI * 2 );
			
			for(var v:uint =0; v < pptNUM; v++){
				
				pptArr[v].Loop();
				
				if(v == 0){
					pptArr[v].SET_kasokudo( ( tenPo_X - pptArr[v].X) * (KN+15), ( tenPo_Y - pptArr[v].Y) * (KN+40) );//(KN+20)
				}else{
					pptArr[v].SET_kasokudo( ( pptArr[v-1].X - pptArr[v].X) * KN, ( pptArr[v-1].Y - pptArr[v].Y) * KN);//KN-4
				}
			}
			
			//ライン生成
			line_base.graphics.clear();
			line_base.graphics.lineStyle( 1 , 0x3976AA);
			Drawline( pptArr, line_base);
		}
		
		
		private function Drawline( Arr:Array, SP:Sprite ):void
		{
			var num:int = Arr.length;
			
			if(num >= 3){
				SP.graphics.moveTo(Arr[1].X,Arr[1].Y);
				
				for(var v:uint = 1; v <= num-3; v++){
					SP.graphics.curveTo(Arr[v].X,Arr[v].Y,(Arr[v].X+Arr[v+1].X)/2,(Arr[v].Y+Arr[v+1].Y)/2);
				}
				
				SP.graphics.curveTo(Arr[num-2].X,Arr[num-2].Y,Arr[num-1].X,Arr[num-1].Y);
			}
		}
		
		
		
	}//class
}//package


class PhyPo
{
	public  var X:Number, Y:Number;
	private var vX:Number, vY:Number;
	private var aX:Number, aY:Number;
	private var B:Number;
	private var t:Number = 0.02;
	public function set _t( value:Number ):void{ _t = value; }
	private var add_t:Number = 0.5;
	public function set _add_t( value:Number ):void{ _add_t = value; }

	public function PhyPo(XX:Number = 0, YY:Number = 0):void
	{
		X = XX;
		Y = YY;
		B =  0.9;
		vX = 0;
		vY = 0;
		aX = 0;
		aY = 0;
	}
	
	public function Loop():void
	{
		var XXX:Number = vX *t + add_t * aX * t * t;
		var YYY:Number = vY *t + add_t * aY * t * t;
		
		X += XXX;
		Y += YYY;
		
		X += vX *t + add_t * aX * t * t;
		Y += vY *t + add_t * aY * t * t;

		vX += aX * t;
		vY += aY * t;
		
		vX *= B;
		vY *= B;
		
		aX = 0;
		aY = 0;
	}//

	function SET_kasokudo(aaX:Number = 0,aaY:Number = 0):void
	{
		aX += aaX;
		aY += aaY;
	}
			
}