Working with SVG polygon elements

前端 未结 4 634
暖寄归人
暖寄归人 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:59

    You can access the individual point values using the SVG DOM:

    var p = polygon.points.getItem(1);
    p.x = 150;
    p.y = 300;
    

    (Assuming that your UA implements this interface.) See SVGPolygonElement, SVGAnimatedPoints, SVGPointList and SVGPoint.

    I find though that using these SVG DOM interfaces (at least for me in Batik, in which I do most of my SVG stuff) is often not faster than just updating the attribute with string manipulation.

提交回复
热议问题