textile_10
see http://gihyo.jp/design/feature/01/frocessing/0002
/**
* Copyright makishima ( http://wonderfl.net/user/makishima )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/hNid
*/
// forked from makishima's textile_09
// forked from makishima's textile_08
// forked from makishima's textile_07
// forked from nutsu's FractalSample
// see http://gihyo.jp/design/feature/01/frocessing/0002
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-250, 465/2+550);
//シェイプの大きさ
shape_size = 700;
//三角形の座標パラメータ
r1 = shape_size;
r2 = r1/2;
r3 = r2*Math.sqrt(3);
//フラクタルの描画(再帰回数を指定)
draw_shapes(7);
}
private function draw_shapes( n:int ):void
{
if ( n-- <= 0 ) return;
var rn:int = 4;
//キャンバスのサイズを半分に
scale( 0.5 );
rotate( -2*Math.PI/rn/3.5);
for ( var i:int = 0; i < rn; i++ ) {
pushMatrix();
//Y方向に-r移動
translate( -i*100, -shape_size );
//正三角形の描画
fill( 4-i , 0, 0);
triangle( 0, -r1, r3/20, r2*2, -r3/20, r2*2);
//再帰的に描画
draw_shapes( n );
popMatrix();
//360/rn 度回転
rotate( 2*Math.PI/rn/3.5);
}
}
}
}