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: FractalSample

Get Adobe Flash player
by nutsu 09 Jun 2009
/**
 * Copyright nutsu ( http://wonderfl.net/user/nutsu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/qO4y
 */

// forked from nutsu's forked from: FractalSample
// forked from nutsu's FractalSample
package  
{
    import frocessing.display.F5MovieClip2D;
    
    [SWF(width=465,height=465,backgroundColor=0xFFEECC)]
    public class FractalSample2 extends F5MovieClip2D
    {
        private var shape_size:Number;
        private var r1:Number;
        private var r2:Number;
        private var r3:Number;
        private var r4:Number;
        
        public function FractalSample2() 
        {            
            //線と塗りの色指定
            colorMode( RGB, 10 );
            
            //キャンバスを移動
            translate(465/2, 465/2);
            
            //シェイプの大きさ
            shape_size = 200;
            
            //シェイプのパラメータ
            r1 = shape_size*1.25;
            r2 = shape_size*0.5;
            r3 = shape_size*1.0;
            r4 = shape_size*0.75;
            
            //フラクタルの描画(再帰回数を指定)
            draw_shapes( 3 );
        }
        
        private function draw_shapes( n:int ):void
        {
            if ( n-- <= 0 ) return;
            
            var rn:int = 4;
            
            //キャンバスのサイズを半分に
            scale( 0.5 );
            for ( var i:int = 0; i < rn; i++ ) {
                
                pushMatrix();
                //Y方向に-r移動
                translate( 0, -shape_size );
                
                //シェイプの描画
                stroke( 5, 0, 0 );
                strokeWeight(n*2.5);
                fill( 10 - n, 0, 0 );
                draw_shape();
                
                //再帰的に描画
                draw_shapes( n );
                popMatrix();
                
                //360/rn 度回転
                rotate( 2*Math.PI/rn );
            }
        }
        
        private function draw_shape():void
        {
            line( 0, 0,  r1,  r1 );
            line( 0, 0, -r2,  r2 );
            line( 0, 0, -r3, -r3 );
            line( 0, 0,  r4, -r4 );
            circle( 0, 0, 60 );
            circle(  r1,  r1, 30 );
            circle( -r2,  r2, 30 );
            circle( -r3, -r3, 30 );
            circle(  r4, -r4, 30 );
        }
    }
}