curveToで円を書く

by plus-tic
♥0 | Line 52 | Modified 2010-01-24 00:54:23 | MIT License
play

ActionScript3 source code

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

// forked from TFB's curv Toを使って円を書く
package {
    import flash.display.Sprite;
    public class drawCircle3 extends Sprite {
        public function drawCircle3() {
            var centerX:Number = 100;
            var centerY:Number = 200;
            var r:Number = 50;
            
            graphics.lineStyle(2,0xff0006);
            graphics.moveTo(centerX+r, 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);
        		
        		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);
        }
    }
}