ActionScript Organic Plasma


Plasma altContent

Go get some Flash-Player



ActionScript3 Source:
/*  * 1 or normal
    * 2 or layer
    * 3 or multiply
    * 4 or screen
    * 5 or lighten
    * 6 or darken
    * 7 or difference
    * 8 or add
    * 9 or subtract
    * 10 or invert
    * 11 or alpha
    * 12 or erase
    * 13 or overlay
    * 14 or hardlight */
package
{
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
 
	public class Main extends Sprite
	{
		private var _bitmap:BitmapData;
		private var _bitmapOverlay:BitmapData;
		private var _xoffset:int = 0;
		private var _xoffsetOverlay:int = 666; // set this to random please
		private var _yoffsetOverlay:int = 666; // set this to random please
		private var overlay:Sprite = new Sprite();
 
		public function Main():void
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
 
		private function init(e:Event = null):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
 
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.stageHeight = 300;
			stage.stageWidth = 600;
 
			overlay.blendMode = difference;
			_bitmap = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0xFFFFFF);
			var image:Bitmap = new Bitmap(_bitmap);
 
			_bitmapOverlay = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0xFFFFFF);
			var imageOverlay:Bitmap = new Bitmap(_bitmapOverlay);
 
			var point:Point = new Point (30, 0);
			_bitmap.perlinNoise (50, 50, 2, 1000, false, true, 2, false, [point, point]);
 
			addChild(image);
			overlay.addChild(imageOverlay);
			addChild(overlay);
 
			addEventListener (Event.ENTER_FRAME, onEnterFrame);
		}
 
		public function onEnterFrame (event:Event):void {
			_xoffsetOverlay += 10;
			_yoffsetOverlay -= 1;
			var pointOverlay:Point = new Point (_xoffsetOverlay, _yoffsetOverlay);
			_bitmapOverlay.perlinNoise (50, 50, 1, 1000, false, true,
								2, false, [pointOverlay, pointOverlay]);
		}
	}
}