⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 生成倒影.as

📁 该AS可以生成图片的倒影效果。该源码由ACTIONSCRIPT3.0编写。欢迎使用。
💻 AS
字号:
function createRef(p_source:DisplayObject):void{ 
   //对源显示对象做上下反转处理 
    var bd:BitmapData=new BitmapData(p_source.width,p_source.height,true,0); 
    var mtx:Matrix=new Matrix(); 
    mtx.d=-1;mtx.ty=bd.height; 
    bd.draw(p_source,mtx); 
//生成一个渐变遮罩 
    var width:int=bd.width; 
    var height:int=bd.height; 
    mtx=new Matrix(); 
    mtx.createGradientBox(width,height,0.5 * Math.PI); 
    var shape:Shape = new Shape(); 
    shape.graphics.beginGradientFill(GradientType.LINEAR,[0,0],[0.9,0.2],[0,0xFF],mtx) 
    shape.graphics.drawRect(0,0,width,height); 
    shape.graphics.endFill(); 
    var mask_bd:BitmapData=new BitmapData(width,height,true,0); 
    mask_bd.draw(shape); 
//生成最终效果 
    bd.copyPixels(bd,bd.rect,new Point(0,0),mask_bd,new Point(0,0),false); 
//将倒影位图放在源显示对象下面 
    var ref:Bitmap=new Bitmap(); 
    ref.y=p_source.height; 
    ref.bitmapData=bd; 
    p_source.parent.addChild(ref); 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -