forked from: flash on 2010-2-7

by sheep forked from flash on 2010-2-7 (diff: 1)
♥0 | Line 40 | Modified 2010-02-17 23:45:52 | 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/tfsa
 */

// forked from sheep's flash on 2010-2-7
package {
    import flash.display.Sprite;
    public class drawCircle3 extends Sprite {
        public function drawCircle3() {
            // write as3 code here..
            var centerX:Number = 100;
            var centerY:Number = 200;
            var r:Number = 50;
            
            //Y軸をひく
            var g1:LineDrawer=new LineDrawer();
            addChild(g1);
            g1.x=centerX;
            
            //X軸を引く
            var g2:LineDrawer2=new LineDrawer2();
            addChild(g2);
            g2.y=centerY;
            
            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);
             
        }
    }
}
//Y軸200
import flash.display.Sprite;
class LineDrawer extends Sprite{
	public function LineDrawer(){
	graphics.lineStyle(1,0xCCCCCC);
	graphics.lineTo(0,400);
	}
}
//x軸100
import flash.display.Sprite;
class LineDrawer2 extends Sprite{
	public function LineDrawer2(){
	graphics.lineStyle(1,0xCCCCCC);
	graphics.lineTo(400,0);
	}
}