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

textile_02

Get Adobe Flash player
by makishima 15 Jul 2011
    Embed
/**
 * Copyright makishima ( http://wonderfl.net/user/makishima )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/3yXQ
 */

// forked from makishima's textile_01
package {
  import frocessing.display.F5MovieClip2D;
  
  [SWF(width=465,height=465,backgroundColor=0xFFEECC)]
  public class FractalSample extends F5MovieClip2D
  {
    private var shape_size:Number;
    private var r1:Number;
    private var r2:Number;
    private var r3:Number;
    
    public function FractalSample() 
    {
      //線と塗りの色指定
      noStroke( );
      colorMode( RGB, 6 );
      
      //キャンバスを移動
      translate( 465/2, 465/2 + 30 );
      
      //シェイプの大きさ
      shape_size = 400;
      
      //三角形の座標パラメータ
      r1 = shape_size;
      r2 = r1/2;
      r3 = r2*Math.sqrt(3);
      
      //フラクタルの描画
      //再帰回数を指定
      draw_shapes( 5 );   //・・・・・(1)
      
     
      
    }
    
    private function draw_shapes( n:int ):void
    {
      if ( n-- <= 0 ) return;
      
      var rn:int = 3;
      for ( var i:int = 0; i < rn; i++ ) {
        
        pushMatrix();
        //キャンバスのサイズを半分に
        scale( 1/(2+Math.random()*0.1));
        //Y方向に-r移動
        translate( 0, -shape_size );
        
        //正三角形の描画

        fill( 5-n , 0, 0);
        triangle( 0, -r1, r3, r2, -r3, r2 );      
        //再帰的に描画
        draw_shapes( n );  //・・・・・(2)
        popMatrix();
        
        //360/rn 度回転
        rotate( (2+Math.random()*0.1)*Math.PI/rn );
      }
    }
  }
}