forked from: forked from: flash on 2010-2-20

by mhayashi forked from forked from: flash on 2010-2-20 (diff: 13)
♥0 | Line 53 | Modified 2010-02-20 13:19:23 | MIT License
play

ActionScript3 source code

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

// forked from masahirohayashi's forked from: flash on 2010-2-20
// forked from masahirohayashi's flash on 2010-2-20
package {
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            var xList:Array = [100, 200, 150, 80, 190];
            var yList:Array = [100, 100, 10, 230, 130];
            var rList:Array = [10, 20, 40, 80, 160];
            
            for(var i = 0; i < xList.length; i++ ){
            		var circle:DrawCircle = new DrawCircle(xList[i], yList[i], rList[i]);
            		addChild(circle);
            }
        }
    }
}

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);

        		// 8つの弧をつなげる(時計回り?)        		
        		graphics.curveTo(r+centerX,							//control point x
        						Math.tan(Math.PI/8)*r+centerY,     	//control point y
        						Math.sin(Math.PI/4)*r+centerX,		//anchor x
        						Math.cos(Math.PI/4)*r+centerY);		//anchor y

        		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.cos(Math.PI/4)*r+centerX,
        						Math.sin(Math.PI/4)*r+centerY);
        						
        		graphics.curveTo(-r+centerX,							//control point x
        						Math.tan(Math.PI/8)*r+centerY,     	//control point y
        						-r+centerX,
        						centerY);		//anchor y

        		graphics.curveTo(-r+centerX,							//control point x
        						-Math.tan(Math.PI/8)*r+centerY,     	//control point y
        						-Math.cos(Math.PI/4)*r+centerX,
        						-Math.sin(Math.PI/4)*r+centerY);		//anchor y
        						
        		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.cos(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);
        }
}