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: フラクタルな樹

参考ページ
http://gihyo.jp/design/feature/01/frocessing/0002?page=4
Get Adobe Flash player
by geta 08 Mar 2011
    Embed
/**
 * Copyright geta ( http://wonderfl.net/user/geta )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/dC56
 */

// forked from gam-22's forked from: フラクタルな樹
// forked from gam-22's フラクタルな樹
// 参考ページ
// http://gihyo.jp/design/feature/01/frocessing/0002?page=4

package {
    import flash.display.AVM1Movie;
    import frocessing.display.F5MovieClip2D;
    import flash.text.*;
    
    [SWF(width=465,height=465,backgroundColor=0xFFFFFF)]
    public class tree extends F5MovieClip2D
    {
        private var leaf_length:Number = 200;// 葉っぱの長さ
        private var leaf_max:int = 40;//        葉っぱの数
        private var recursive_max:int = 4;//    再帰回数
        private var cnt:int = 0;
        
        public function setup():void {
        // コンストラクタ
            
            translate( 465/2, 465 );
            
            //線と塗りの色指定
            stroke( 0,122,0,  0.5 );
            noFill();
            
            // 軸を描画
            line (0,0,0,-leaf_length*2);
      
            draw_leaves(recursive_max);
            
            var debug:TextField = new TextField();
            debug.text = "線の数: "+(cnt+1)+"本";
            debug.autoSize = TextFieldAutoSize.LEFT;
            addChild(debug);
            

        }
        
        private function draw_leaves( n:int ):void {
            
            if ( n-- <= 0 ) return;
            
            for (var i:int = 0; i < leaf_max; i++) {
                scale(0.8);
                translate( 0, -leaf_length/2 );
                pushMatrix();
                if (i%2) {
                    rotate( Math.PI/6 );
                } else {
                    rotate( -Math.PI/6 );
                }
                
                line (0,0,0,-leaf_length);
                
                scale(0.5);
                
                draw_leaves(n);

                popMatrix();
                
                cnt++;
            }
        }

    }
}