DisplacementMapFilter
コマンドのループby俺俺コマンド
// forked from northprint's Bitmapdata.perlinNoise
// forked from nium's forked from: forked from: forked from: Bitmapdata.noise
// forked from northprint's forked from: forked from: Bitmapdata.noise
// forked from northprint's forked from: Bitmapdata.noise
// forked from northprint's Bitmapdata.noise
//コマンドのループby俺俺コマンド
// write as3 code here..
package {
import flash.display.*;
import flash.events.*;
import jp.progression.commands.*;
import jp.progression.events.*;
import flash.geom.*;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.filters.DisplacementMapFilter;
public class NoiseTest extends MovieClip {
private var _bitmapdata:BitmapData;
private var _bitmapdata2:BitmapData;
private var _bitmap:Bitmap;
private var _loop:LoopCommand;
private var _noiseMode:int = 0;
private var _text:TextField;
private var _offset:Array = [new Point(0,0),new Point(0,0)];
public function NoiseTest() {
_bitmapdata = new BitmapData( stage.stageWidth, stage.stageHeight, true );
_text = new TextField();
_text.defaultTextFormat = new TextFormat('Verdana', 64, 0xffffff, true);
_text.autoSize = TextFieldAutoSize.LEFT;
_text.text = 'Wonderfl!!';
_bitmapdata2 = new BitmapData(stage.stageWidth, stage.stageHeight, false);
_bitmapdata2.draw(_text);
_bitmap = new Bitmap( _bitmapdata2 );
addChild( _bitmap );
addEventListener( Event.ENTER_FRAME, _enterFrame );
_loop = new LoopCommand(
new SerialList( null,
new Wait( 3000 ),
function():void { _noiseMode = ++_noiseMode % 3; }
),
function():Boolean { return false; }
);
_loop.execute();
}
private function _enterFrame( e:Event ):void {
_offset[0].x += 2;
_offset[1].y += 2;
switch ( _noiseMode ) {
case 0 : { _bitmapdata.perlinNoise(50, 50, 2, 1, false, true, 4 | 2 | 1, false, _offset);break;}
case 1 : { _bitmapdata.perlinNoise(50, 100, 2, 1, false, true, 4 | 2 | 1, false, _offset);break;}
case 2 : { _bitmapdata.perlinNoise(100, 50, 2, 1, false, true, 4 | 1 | 4, false, _offset);break;}
}
var dmf:DisplacementMapFilter = new DisplacementMapFilter(_bitmapdata, null,BitmapDataChannel.BLUE,BitmapDataChannel.BLUE, 15,15,"color");
_bitmapdata2.draw(_text);
_bitmapdata2.applyFilter(_bitmapdata2,new Rectangle(0,0,_bitmapdata2.width,_bitmapdata2.height),new Point(0,0),dmf);
}
}
}
import jp.progression.commands.*;
import jp.progression.core.commands.Command;
import jp.progression.events.*;
class LoopCommand extends Command {
private var _command:Command;
private var _condition:Function;
public function LoopCommand( command:Command, condition:Function, initObject:Object = null ) {
super( _execute, _interrupt, initObject );
_command = command;
_condition = condition;
timeOut = 0;
}
private function _execute():void{
if ( _condition.apply( this ) ) {
executeComplete();
}
_command.addEventListener( CommandEvent.COMMAND_COMPLETE, _commandComplete );
_command.execute();
}
private function _commandComplete( e:CommandEvent ):void {
_command.removeEventListener( CommandEvent.COMMAND_COMPLETE, _commandComplete );
_execute();
}
private function _interrupt():void {
if ( _command ) {
_command.removeEventListener( CommandEvent.COMMAND_COMPLETE, _commandComplete );
_command = null;
}
interruptComplete();
}
public override function clone():Command{
return new LoopCommand( _command, _condition, this );
}
}