萬盛學電腦網

 萬盛學電腦網 >> 圖文處理 >> Flash教程 >> as3打造輕紗般的變幻線效果

as3打造輕紗般的變幻線效果

詳細代碼:
 

package {



        import flash.display.Sprite;

        import flash.display.Bitmap;

        import flash.display.BitmapData;

        import flash.events.MouseEvent;

        import flash.events.Event;

        import flash.geom.Point;

        import frocessing.math.PerlinNoise;

        import frocessing.color.ColorHSV;

        //import org.libspark.utils.GeomUtil;



        [SWF(backgroundColor="#000000", width="465", height="465", frameRate="30")]



        public class Main13 extends Sprite {

                private var canvas:Sprite;

                private var bitmap:Bitmap;

                private var bitmapData:BitmapData;

                private static var bWidth:uint = 600;

                private static var bHeight:uint = 600;

                private static var segments:uint = 5;

                private static var ratio:Number = 1/segments;

                private static var colors:uint = 360;

                private var perlin:PerlinNoise;

                private var color:ColorHSV;

                private var t:Number = 0;

                private var c:uint = 0;

                private static var tightness:uint = 40;



                public function Main13() {

                        //Wonderfl.capture_delay(30);

                        stage.frameRate = 120;

                        init();

                }



                private function init():void {

                        graphics.beginFill(0x000000);

                        graphics.drawRect(0, 0, 465, 465);

                        graphics.endFill();

                        canvas = new Sprite();

                        bitmapData = new BitmapData(bWidth, bHeight, true, 0x00000000);

                        bitmap = new Bitmap(bitmapData);

                        addChild(bitmap);

                        bitmap.y = uint((bWidth - bHeight)/2);

                        perlin = new PerlinNoise();

                        color = new ColorHSV();

                        addEventListener(Event.ENTER_FRAME, draw, false, 0, true);

                        stage.addEventListener(MouseEvent.CLICK, reset, false, 0, true);

                }

                private function draw(evt:Event):void {

                        canvas.graphics.clear();

                        color.h = c;

                        canvas.graphics.lineStyle(0, color.value, 0.2);

                  &nb
copyright © 萬盛學電腦網 all rights reserved