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

Chaos Game No Bitmap

Get Adobe Flash player
by Zahurdias.Calimero 01 Dec 2012
    Embed
/**
 * Copyright Zahurdias.Calimero ( http://wonderfl.net/user/Zahurdias.Calimero )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/sGFo
 */

// forked from Zahurdias.Calimero's forked from: Chaos Game
// forked from takuya1021's Chaos Game
 //Nやwtの値を変えると違う模様ができる。 
//例えば、N=3,wt=0.5のとき、シェルピンスキーの三角形。
//ChaosGameは前に作りましたが、今度はBitmapというものをを使ってみた。
package { 
    import flash.display.*; 
    import flash.text.TextField;  
    import flash.utils.*;
        
    //[SWF(width="400",height="400",backgroundColor="#ffffff")] 
    public class ChaosGame extends Sprite { 

        private const N:Number = 5; 
        private const wt:Number = 0.6; 
        private var textField:TextField = new TextField();
        //private var myShape:Shape = new Shape();
        private var startTime:int;
        private var timeElapsed:int;  
        
        public function ChaosGame() { 
            
            addChild(textField);
            
            var x:Number = 1; 
            var y:Number = 0; 

            graphics.lineStyle(0, 0x000000);
            
            //myShape.graphics.lineStyle(0, 0, 1.0, false, "none", CapsStyle.NONE, JointStyle.ROUND);
            
            for(var i:int = 0;i<50000;i++){ 
                var a:int = Math.random()*N >> 0; 
                var vx:Number = Math.cos(a*2*Math.PI/N); 
                var vy:Number = Math.sin(a*2*Math.PI/N); 
                x = x + (vx - x) * wt; 
                y = y + (vy - y) * wt; 
                //myShape.graphics.drawCircle(x*200+200,y*200+200,0.1);
                graphics.drawRect(x*200+200,y*200+200,0.1,0.1);
            } 
            
            timeElapsed = flash.utils.getTimer() - startTime;
            textField.text=String(timeElapsed);
        } 
    } 
}