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

カラフル縞 すぐ計算

unionのreactorに入っている便利ツールのひとつ
getRandInt(min:int,max:int):int
min以上max以下のランダムな整数を返します。
Get Adobe Flash player
by keno42 10 Sep 2009
    Embed
/**
 * Copyright keno42 ( http://wonderfl.net/user/keno42 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/nRkq
 */

// forked from keno42's カラフル縞
// forked from keno42's getRandInt()
// unionのreactorに入っている便利ツールのひとつ
// getRandInt(min:int,max:int):int
// min以上max以下のランダムな整数を返します。
package {
    import flash.display.*;
    import flash.events.Event;
    import net.user1.utils.getRandInt;

    public class FlashTest extends Sprite {
        private var dataNums:Array = [];
        private var MAX_NUM:int = 30;
        private var bmpData:BitmapData = new BitmapData(465, 465, false, 0);
        public function FlashTest() {
            // write as3 code here..
            for( var i:int = 0; i < MAX_NUM; i++ ){
                dataNums.push( new Array(i+1) );
            }
            addChild( new Bitmap(bmpData) );
            draw();
        }
        private var color:int = 0;
        private var count:int = 0;
        private function draw():void{
            do{
                count++;
                // 緑 255->0(x) 青 0->255(x)
                color = (int(255*(1-count/600))<<8) + int(255*(count/600));
            
                var endFlag:Boolean = true;
                for( var i:int = 0; i < MAX_NUM; i++ ){
                    // 赤 0->255(y)
                    color += int(255/MAX_NUM)<<16;
                    for( var j:int = 0; j <= i; j++ ){
                        if( int(dataNums[i][j]) <= 465 ) endFlag = false;
                        var rand:int = getRandInt(0, i);
                        bmpData.setPixel(dataNums[i][rand], 0.5*i*(i+1)+/*i+*/rand, color);
                        dataNums[i][rand] = int(dataNums[i][rand]) + 1;
                    }
                }
            } while( !endFlag );
        }
    }
}