码迷,mamicode.com
首页 > 其他好文 > 详细

[ActionScript 3.0] AS3实现滤镜叠加效果

时间:2015-11-09 18:30:56      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

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;
}

 

[ActionScript 3.0] AS3实现滤镜叠加效果

标签:

原文地址:http://www.cnblogs.com/frost-yen/p/4950620.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!