flash on 2009-10-17

by mtok
...
@author Motoki Matsumoto
♥0 | Line 54 | Modified 2009-10-17 02:29:50 | MIT License
play

ActionScript3 source code

/**
 * Copyright mtok ( http://wonderfl.net/user/mtok )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/iATb
 */

package  
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Graphics;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Matrix;
	import flash.display.BlendMode;
	/**
	 * ...
	 * @author Motoki Matsumoto
	 */
	public class DisplacementFilterTest extends Sprite
	{
		private var bg:Bitmap;
		private var fore:Sprite;
		public function DisplacementFilterTest() 
		{
			addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
		}
		
		private function addedToStageHandler(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
			
			addChild(bg = new Bitmap(new BitmapData(stage.stageWidth, stage.stageHeight)));
			addChild(fore = new Sprite());
			
			drawBackground();
		}
		
		private function drawBackground():void
		{
			var bg:Bitmap= this.bg;
			var fig:Shape = drawCircle(30, 3);
			var mat:Matrix = new Matrix();
			for (var i:int = 0; i < 250; i++) {
				mat.tx = Math.random() * 465;
				mat.ty = Math.random() * 465;
				bg.bitmapData.draw(fig, mat,null, BlendMode.DARKEN);
			}
		}
		
		private function drawCircle(radius:Number, space:Number):Shape
		{
			var fig:Shape = new Shape();
			var g:Graphics = fig.graphics;
			g.beginFill(0xffffff);
			g.drawCircle(0, 0, radius);
			g.endFill();
			
			g.lineStyle(1, 0);
			var len:int = Math.floor(radius / 2);
			var r:Number = radius;
			while (r > 0) {
				g.drawCircle(0, 0, r);
				r -= space;
			}
			
			return fig;
		}
		
	}

}

Forked