zoukankan      html  css  js  c++  java
  • bitmapdata的功能,不规则图形的遮罩

    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BitmapDataChannel;
    import flash.geom.Point;
    import flash.geom.Rectangle;
     
    var bmd1:BitmapData = new BitmapData(200, 200, true, 0xFFCCCCCC);
     
    var seed:int = int(Math.random() * int.MAX_VALUE);
    var channels:uint = BitmapDataChannel.RED | BitmapDataChannel.BLUE;
    bmd1.perlinNoise(100, 80, 12, seed, false, true, channels, false, null);
     
    var bitmap1:Bitmap = new Bitmap(bmd1);
    addChild(bitmap1);
     
    var bmd2:BitmapData = new BitmapData(200, 200, true, 0xFFCCCCCC);
    var pt:Point = new Point(0, 0);
    var rect:Rectangle = new Rectangle(0, 0, 200, 200);
    var threshold:uint =  0x00800000; 
    var color:uint = 0x20FF0000;
    var maskColor:uint = 0x00FF0000;
    bmd2.threshold(bmd1, rect, pt, ">", threshold, color, maskColor, true);
     
    var bitmap2:Bitmap = new Bitmap(bmd2);
    bitmap2.x = bitmap1.x + bitmap1.width + 10;
    addChild(bitmap2);
     
     
    bitmapdata的功能,不规则图形的遮罩
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BitmapDataChannel;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    var bmd:BitmapData =new BitmapData(200,200, true,0xFFFF0000);
    var bmdMask:BitmapData =new BitmapData(200,200, true);
    var seed:int=int(Math.random() *int.MAX_VALUE);
    var channels:uint= BitmapDataChannel.RED | BitmapDataChannel.BLUE;
    bmdMask.perlinNoise(100, 80, 12, seed, false, true,channels, false, null);
    var bitmap:Bitmap =new Bitmap(bmd);
    var bitmapMask:Bitmap =new Bitmap(bmdMask);
    //addChild(bitmap);
    //addChild(bitmapMask);
    var threshold:uint= 0x00800000;
     
    var color:uint= 0x00FFFFFF;
    var maskColor:uint= 0x00FF0000;
    bmdMask.threshold(bmdMask, bmdMask.rect, new Point(), ">",threshold, color, maskColor, true);
    var spriteMask =new Sprite();
    spriteMask.addChild(bitmapMask);
    spriteMask.cacheAsBitmap =true;
    addChild(spriteMask);
     
     
     
    var display =new Sprite();
    display.addChild(bitmap);
    display.cacheAsBitmap =true;
    addChild(display);
    display.mask = spriteMask;
  • 相关阅读:
    spring事务管理器设计思想(一)
    ThreaLocal内存泄露的问题
    denyhost防止SSH暴力破解
    qt下调用win32api 修改分辨率
    Windows下pip安装包报错:Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat
    Centos 6.5 下安装socket5代理
    Mac 下安装mitmproxy
    Mac OS 下安装wget
    判断客户端是否使用代理服务器及其匿名级别
    Mac OS 下安装rar unrar命令
  • 原文地址:https://www.cnblogs.com/chenhongyu/p/3342058.html
Copyright © 2011-2022 走看看