zoukankan      html  css  js  c++  java
  • [ActionScript 3.0] AS3.0 烟雾粒子效果

    package {
        import flash.display.Bitmap;
        import flash.display.BitmapData;
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.geom.Point;
        [SWF(width="500",height="400")]
        public class SmokeFog extends Sprite {
            private var vectormap:BitmapData;
            private var bmpdata:BitmapData;
            private var oy:int = 0;
            private var w:int;
            
            public function SmokeFog(){
                w = 200;
                vectormap = new BitmapData(w, w);
                bmpdata = new BitmapData(w, w, false, 0);
                addChild(new Bitmap(bmpdata));
                stage.addEventListener(Event.ENTER_FRAME, reset);
            }
            
            private function reset(e:Event):void {
                vectormap.perlinNoise(w * .5, w * .5, 3, 1, false, true, 7, false, [new Point(0, oy++)]);
                bmpdata.fillRect(bmpdata.rect, 0);
                for (var y:int = 0; y < vectormap.height; y++){
                    for (var x:int = 0; x < vectormap.width; x++){
                        var px:uint = vectormap.getPixel(x, y);
                        var r:int = px >> 16 & 0xFF;
                        var g:int = px >> 8 & 0xFF;
                        var b:int = px & 0xFF;
                        var tx:int = x + (g / 0xFF - .5) * w;
                        var ty:int = y + (b / 0xFF - .5) * w;
                        
                        if (ty < 0 || ty >= bmpdata.height || tx < 0 || tx >= bmpdata.width)
                            continue;
                        var col:uint = bmpdata.getPixel(tx, ty);
                        col += 0x010101 * (int)(r * .2);
                        if (col > 0xFFFFFF)
                            col = 0xFFFFFF;
                        bmpdata.setPixel(tx, ty, col);
                    }
                }
            }
        }
    }
  • 相关阅读:
    Android学习地址
    Android动画设计源码地址
    chromeWebBrowser之浏览器开发
    win8.1蓝屏解决
    打包应用程序
    win8.1解决鼠标右键反应慢的问题
    Rewrite服务器和robots文件屏蔽动态页面
    第08组 Alpha事后诸葛亮
    第08组 Alpha冲刺(6/6)
    第08组 Alpha冲刺(5/6)
  • 原文地址:https://www.cnblogs.com/frost-yen/p/5623646.html
Copyright © 2011-2022 走看看