效果如图:

[AS3][倒影算法][转载]

 

{
    // 倒置
    var bd:BitmapData = new BitmapData(picSource.width,picSource.height,true,0x12346f);
    
var mtx:Matrix = new Matrix();
    mtx.d 
= -1;
    mtx.ty 
= bd.height;
    bd.draw(picSource,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
=picSource.height + picSource.y; 
    ref.x 
= picSource.x;
    ref.bitmapData
=bd; 
    picSource.parent.addChild(ref); 
    }

相关文章:

  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
  • 2021-09-24
  • 2021-12-16
  • 2022-12-23
猜你喜欢
  • 2022-03-06
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2021-08-04
相关资源
相似解决方案