import PathNode from './path-node';
import NODE_MAP from './node-map';

var CircleNode = (function (PathNode) {
    function CircleNode () {
        PathNode.apply(this, arguments);
    }

    if ( PathNode ) CircleNode.__proto__ = PathNode;
    CircleNode.prototype = Object.create( PathNode && PathNode.prototype );
    CircleNode.prototype.constructor = CircleNode;

    CircleNode.prototype.geometryChange = function geometryChange () {
        var center = this.center();
        this.attr("cx", center.x);
        this.attr("cy", center.y);
        this.attr("r", this.radius());
        this.invalidate();
    };

    CircleNode.prototype.center = function center () {
        return this.srcElement.geometry().center;
    };

    CircleNode.prototype.radius = function radius () {
        return this.srcElement.geometry().radius;
    };

    CircleNode.prototype.template = function template () {
        return "<circle " + (this.renderId()) + " " + (this.renderStyle()) + " " + (this.renderOpacity()) +
                    "cx='" + (this.center().x) + "' cy='" + (this.center().y) + "' r='" + (this.radius()) + "'" +
                    (this.renderStroke()) + " " + (this.renderFill()) + " " + (this.renderDefinitions()) +
                    (this.renderTransform()) + " ></circle>";
    };

    return CircleNode;
}(PathNode));

NODE_MAP.Circle = CircleNode;

export default CircleNode;