ランダムな円 2010-2-7

by sheep forked from forked from: forked from: flash on 2010-2-7 (diff: 10)
ランダムに円を描く
♥0 | Line 29 | Modified 2010-02-07 14:42:10 | MIT License
play

ActionScript3 source code

/**
 * Copyright sheep ( http://wonderfl.net/user/sheep )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/1fbq
 */

//ランダムに円を描く
// forked from sheep's forked from: forked from: flash on 2010-2-7
// forked from sheep's forked from: flash on 2010-2-7
// forked from sheep's flash on 2010-2-7
package {
    import flash.display.MovieClip
    public class Index extends MovieClip {
        public function Index() {
        		var repeatCount:int = 5;
        		
        		for(var i=0; i < repeatCount; i++){
        			var centerX:Number = Math.round(Math.random()*400) + 50;
        			var centerY:Number = Math.round(Math.random()*400) + 50;
        			var r:Number = Math.ceil(Math.random()*100);
        			addChild(new DrawCircle(centerX, centerY, r));
        		}
        }
    }
}
	//クラスにすることでひとつひとつをインスタンスとして扱うことが出来る
    import flash.display.MovieClip;
    class DrawCircle extends MovieClip {
        public function DrawCircle(centerX:Number, centerY:Number, r:Number) {
       
            graphics.lineStyle(2, 0xFF0006);
            graphics.moveTo(centerX+r, centerY);
            /*y = Math.tan(-)*r */
            /* grahics.curveTo(コントロールポイントのx,y, 終点x,y) */
            //右下
            graphics.curveTo(r+centerX, Math.tan(Math.PI/8)*r+centerY, Math.sin(Math.PI/4)*r+centerX, Math.sin(Math.PI/4)*r+centerY);
            graphics.curveTo(Math.tan(Math.PI/8)*r+centerX, r+centerY, centerX, r+centerY);
            //左下
            graphics.curveTo(-Math.tan(Math.PI/8)*r+centerX, r+centerY, -Math.sin(Math.PI/4)*r+centerX, Math.sin(Math.PI/4)*r+centerY);
            graphics.curveTo(-r+centerX, Math.tan(Math.PI/8)*r+centerY, -r+centerX, centerY);
            //左上
            graphics.curveTo(-r+centerX, -Math.tan(Math.PI/8)*r+centerY, -Math.sin(Math.PI/4)*r+centerX, -Math.sin(Math.PI/4)*r+centerY);
            graphics.curveTo(-Math.tan(Math.PI/8)*r+centerX, -r+centerY, centerX, -r+centerY);
            //右上
            graphics.curveTo(Math.tan(Math.PI/8)*r+centerX, -r+centerY, Math.sin(Math.PI/4)*r+centerX, -Math.sin(Math.PI/4)*r+centerY);
            graphics.curveTo(r+centerX, -Math.tan(Math.PI/8)*r+centerY, r+centerX, centerY);
             
        }
    }