fork 020403
/**
* Copyright juniuisae ( http://wonderfl.net/user/juniuisae )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/p528
*/
package {
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
[SWF(width=465,height=465,backgroundColor=0)]
import flash.geom.Matrix;
import flash.geom.ColorTransform;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.BlendMode;
import flash.filters.BlurFilter;
import flash.geom.Point;
import flash.display.BitmapDataChannel;
import flash.filters.DisplacementMapFilter;
[SWF(width=465,height=465,backgroundColor=0)]
public class BitmapDataSample4 extends Sprite {
private var bmpdata:BitmapData;
private var sprite:Sprite;
private var matrix:Matrix;
private var colortrans:ColorTransform;
private var filter:BlurFilter;
public function BitmapDataSample4() {
bmpdata = new BitmapData(465, 465, false, 0);
addChild ( new Bitmap(bmpdata));
sprite = newFig (232, 232, 300, 0xFFFFFF );
matrix = new Matrix();
colortrans = new ColorTransform();
filter = new BlurFilter(2,2,1);
addEventListener( Event.ENTER_FRAME,enterframe);
stage.addEventListener(MouseEvent.CLICK, reset );
}
private function newFig( cx:Number, cy:Number,size:Number,col:uint ):Sprite{
var shape:Sprite = new Sprite();
shape.graphics.lineStyle( 0, 0x000000, 0.3);
shape.graphics.beginFill( col );
shape.graphics.drawCircle( cx, cy, size * 0.5 );
shape.graphics.drawCircle( cx, cy, size * 0.4 );
var w:Number = size * 0.6;
var h:Number = size * 0.15;
shape.graphics.drawRect( cx -w / 2, cy -h / 2, w, h );
shape.graphics.endFill();
return shape;
}
private function enterframe(e:Event):void{
matrix.identity();
var s:Number = Math.random() * 2;
matrix.scale(s, s);
matrix.rotate( Math.PI * Math.random());
matrix.translate( mouseX, mouseY);
colortrans.greenMultiplier = mouseX/465;
colortrans.blueMultiplier = mouseY/465;
colortrans.alphaMultiplier = Math.random()- 0.2;
bmpdata.applyFilter( bmpdata, bmpdata.rect, bmpdata.rect.topLeft,filter );
bmpdata.draw( sprite, matrix, colortrans, BlendMode.ADD);
}
private function reset(e:MouseEvent):void{
bmpdata.fillRect( bmpdata.rect, 0xFF000000 );
}
}}