forked from: flash on 2009-12-28
/**
* Copyright h_ike ( http://wonderfl.net/user/h_ike )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/hFoA
*/
// forked from h_ike's flash on 2009-12-28
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.filters.*;
public class FlashTest extends Sprite {
private var bmd:BitmapData;
private var sprite:Sprite;
private var mtrx:Matrix;
private var mtrx2:Matrix;
private var ct:ColorTransform;
private var ct2:ColorTransform;
private var bf:BlurFilter;
private var dmf:DisplacementMapFilter;
private var mapBitmap:BitmapData;
//
public function FlashTest(){
bmd = new BitmapData(465,465,false,0);
addChild(new Bitmap(bmd));
mtrx = new Matrix();
mtrx2 = new Matrix();
ct = new ColorTransform(0.985,0.98,0.98);
ct2 = new ColorTransform();
bf = new BlurFilter(2,2,1);
//
mapBitmap = new BitmapData(465,465,false,0);
var mapPoint:Point = mapBitmap.rect.topLeft;
var componentX:uint = BitmapDataChannel.RED;
var componentY:uint = BitmapDataChannel.GREEN;
var scaleX:Number = 8;
var scaleY:Number = 8;
mapBitmap.perlinNoise(100,100,4,0,false,false);
dmf = new DisplacementMapFilter(mapBitmap,mapPoint,componentX,componentY,scaleX,scaleY);
//
sprite = new Sprite();
sprite.graphics.beginFill(0x000000);
sprite.graphics.drawRect(-10,-10,20,20);
addEventListener(Event.ENTER_FRAME,loop);
}
private function loop(e:Event):void{
mtrx.identity();
var s:Number = Math.random()*8;
mtrx.scale(s,s);
mtrx.rotate(Math.PI*Math.random());
mtrx.translate(mouseX,mouseY);
mtrx2.scale(2,2);
//
ct2.redOffset = Math.random()*255;
ct2.greenOffset = Math.random()*255
ct2.blueOffset = Math.random()*255;
bmd.draw(sprite,mtrx,ct2,BlendMode.SCREEN);
bmd.colorTransform(bmd.rect,ct);
bmd.applyFilter(bmd,bmd.rect,bmd.rect.topLeft,bf);
bmd.applyFilter(bmd,bmd.rect,bmd.rect.topLeft,dmf);
}
}
}