Working with SVG polygon elements

前端 未结 4 553
暖寄归人
暖寄归人 2021-02-05 09:39

I\'m trying to work with an SVG polygon and javascript. I create a polygon and set its initial point list like this:

var polygon = document.createElementNS(\'htt         


        
4条回答
  •  感情败类
    2021-02-05 09:47

    No way around it I'm afraid. You have to reconstruct the string again. But it's not difficult to wrap the whole thing in an object, something like:

    function Polygon () {
        var pointList = [];
        this.node = document.createElementNS('http://www.w3.org/2000/svg','polygon');
        function build (arg) {
            var res = [];
            for (var i=0,l=arg.length;i

    * not the best implementation but you get the idea.

提交回复
热议问题