Abedron
2/21/2014 - 10:00 PM

Randomize generation sprite in circle shape

Randomize generation sprite in circle shape

public function randomCircleFill(target:Sprite, radius:Number, offset:Point = null):void {
    for(var i:int = 0; i < 1000; i++){
        var len:Number = Math.sqrt(Math.random()) * radius;
        var angle:Number = (Math.random()*360) * Math.PI / 180;

        var circleAnchorPoint:Point = Point.polar(len, angle);
        if (offset !== null) {
            circleAnchorPoint.offset(offset.x, offset.y);
        }

        target.graphics.beginFill(0xff0000);
        target.graphics.drawRect(circleAnchorPoint.x, circleAnchorPoint.y, 5, 5);
        target.graphics.endFill();
    }
}