In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: forked from: forked from: オーロラ:解像度下げれば軽い

== matacat ====
* 右上は perlin noise の生成にかかった時間。
* ステージクリックで perlin noise の表示を切り替え。
* The number on the top right means how long did it take
* to generate perlin noises.
* Clicking the stage toggles the visibility of
* perlin noises.
Get Adobe Flash player
by hacker_tufh03t1 18 May 2010
    Embed
/**
 * Copyright hacker_tufh03t1 ( http://wonderfl.net/user/hacker_tufh03t1 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/18Mg
 */

// forked from hacker_tufh03t1's forked from: forked from: オーロラ:解像度下げれば軽い
// forked from hacker_tufh03t1's forked from: オーロラ:解像度下げれば軽い
// forked from matacat's オーロラ:解像度下げれば軽い
// forked from curvedstraightline's オーロラ:重い

/* 
 * == matacat ====
 * 右上は perlin noise の生成にかかった時間。
 * ステージクリックで perlin noise の表示を切り替え。
 * The number on the top right means how long did it take
 * to generate perlin noises.
 * Clicking the stage toggles the visibility of
 * perlin noises.
 */

package
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BlendMode;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Point;
    import flash.text.TextField;
    import flash.utils.getTimer;
    
    public class FlashTest extends Sprite
    {
        private const W:int          = stage.stageWidth;
        private const H:int          = stage.stageHeight;
        private const SIZE:int       = 100;
        private const BLEND:String   = BlendMode.HARDLIGHT;
        private const SMOOTH:Boolean = false;
        
        private var perlinG:BitmapData    = new BitmapData(SIZE, SIZE, false, 0x0);
        private var bmpG:Bitmap           = new Bitmap(perlinG, "auto", SMOOTH);
        private var baseXG:Number         = SIZE / 8;
        private var baseYG:Number         = SIZE;
        private var numOctavesG:uint      = 1;
        private var randomSeedG:int       = int(Math.random() * 0x7FFFFFFF);
        private var stitchG:Boolean       = false;
        private var fractalNoiseG:Boolean = true;
        private var channelOptionsG:uint  = 0;
        private var grayScaleG:Boolean    = true;
        private var offsetsG:Array        = [new Point()];
        private var dxG:Number            = 1 / 8;
        private var dyG:Number            = 1 / 8;
        
        private var perlinC:BitmapData    = perlinG.clone();
        private var bmpC:Bitmap           = new Bitmap(perlinC, "auto", SMOOTH);
        private var baseXC:Number         = SIZE;
        private var baseYC:Number         = SIZE * 4;
        private var numOctavesC:uint      = 1;
        private var randomSeedC:int       = int(Math.random() * 0x7FFFFFFF);
        private var stitchC:Boolean       = false;
        private var fractalNoiseC:Boolean = false;
        private var channelOptionsC:uint  = 7;
        private var grayScaleC:Boolean    = false;
        private var offsetsC:Array        = [new Point()];
        private var dxC:Number            = 1 / -16;
        private var dyC:Number            = 1 / 4;
        
        private var tf:TextField    = new TextField();
        private var standby:Boolean = true;
        private var dispMode:int    = 0;
        
        public function FlashTest()
        {
            bmpG.scaleX = W / SIZE;
            bmpG.scaleY = H / SIZE;
            addChild(bmpG);
            
            bmpC.scaleX    = W / SIZE;
            bmpC.scaleY    = H / SIZE;
            bmpC.blendMode = BLEND;
            addChild(bmpC);
            
            tf.mouseEnabled = false;
            tf.background   = true;
            tf.alpha        = 0.75;
            tf.autoSize     = "right";
            tf.x            = W - tf.width;
            stage.addChild(tf);
            
            addEventListener(Event.ENTER_FRAME, check);
            stage.addEventListener(MouseEvent.CLICK, toggleMode);
        }
        
        private function toggleMode(e:MouseEvent):void
        {
            dispMode       = dispMode < 2 ? dispMode + 1 : 0;
            bmpG.visible   = dispMode < 2;
            bmpC.visible   = dispMode % 2 == 0;
            bmpC.blendMode = bmpC.visible ? BLEND : BlendMode.NORMAL;
        }
        
        private function update():void
        {
            if(bmpG.visible){
                perlinG.perlinNoise(
                    baseXG, baseYG, numOctavesG, randomSeedG, stitchG,
                    fractalNoiseG, channelOptionsG, grayScaleG, offsetsG
                );
            }
            
            if (bmpC.visible) {
                perlinC.perlinNoise(
                    baseXC, baseYC, numOctavesC, randomSeedC, stitchC,
                    fractalNoiseC, channelOptionsC, grayScaleC, offsetsC
                );
            }
            
            offsetsG[0].x += dxG;
            offsetsG[0].y += dyG;
            
            offsetsC[0].x += dxC;
            offsetsC[0].y += dyC;
            
            standby = true;
        }
    }
}