randomly drawCircle

by PAPER104
♥0 | Line 29 | Modified 2011-05-20 01:40:52 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.MovieClip;
    public class Index extends MovieClip {
        public function Index() {
            var count:int = Math.ceil(Math.random()*15);
            for(var i:int = 0; i < count; i++){
                var centerX:Number = Math.round(Math.random()*300 + 100);
                var centerY:Number = Math.round(Math.random()*250 + 100);;
                var r:Number = Math.ceil(Math.random()*100 + 10);
                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(4, 0xFF0000);
        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);
        }
    }