import flash.display.BitmapData; import flash.filters.BlurFilter; import flash.geom.ColorTransform; import flash.geom.Matrix; addChild(new Bitmap(overlapFilter(new 元件1(),5,1))); function overlapFilter(obj:DisplayObject, dist:Number, qual:Number):BitmapData { var width0:Number = obj.width+(dist*0.05*obj.width)+4; var height0:Number = obj.height+(dist*0.05*obj.height)+4; var out:BitmapData = new BitmapData(width0,height0,true,0x00000000); var buffer:BitmapData = new BitmapData(width0,height0,true,0x00000000); var blur:BlurFilter = new BlurFilter(3,3,qual); var cmat:ColorTransform = new ColorTransform(1,1,1,0.2,0,0,0,0); var mat:Matrix = new Matrix(); var step:Number; for (var i:Number = dist+20; i>1; i--) { step = 0.05 * i; mat.identity(); mat.scale(step,step); mat.translate(width0/2-obj.width*step/2,height0/2-obj.height*step/2); buffer.fillRect(buffer.rect,0x00000000); buffer.draw(obj,mat); buffer.applyFilter(buffer,buffer.rect,new Point,blur); mat.identity(); out.draw(buffer,mat,cmat); } mat.identity(); mat.translate(dist*0.05*obj.width/2+2,dist*0.05*obj.height/2+2); cmat.alphaMultiplier = 0.3; buffer.dispose(); out.draw(obj,mat,cmat,null,null,true); return out; }
时间: 2024-10-11 06:27:25