Modifying an SVG polygon element

DJ_AM_Juicebox
DJ_AM_Juicebox used Ask the Experts™
on
Hi,

How are we supposed to modify elements of an SVG polygon? For example, I make a polygon like this:

  var polygon = document.createElementNS('http://www.w3.org/2000/svg','polygon');
  polygon.setAttribute("points", "0,0  100,100 200,200");

now what do I do if I want to modify the 2nd point (100,100)? Right now I'm basically reconstructing the whole string again. But can we address "polygon.points" as an array somehow, or is it really just a plain simple string?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Am I missing it, or does the article not show how to modify points in a polygon element? I'm curious as to how others are doing this. I can get it done, but it seems horribly inefficient to reconstruct the entire "points" attribute every time you want to modify a single point pair.

Thanks
<<Am I missing it, or does the article not show how to modify points in a polygon element?>>
Please check in the 'Interactive' Section

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial