From ac2161c6d926aabe97739d6316bb90d46ac69085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 2 Mar 2014 01:02:33 +0100 Subject: [PATCH] Fix importPoly() on Node.js Closes #390 --- src/svg/SVGImport.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/svg/SVGImport.js b/src/svg/SVGImport.js index fb7a84be..03c5b32e 100644 --- a/src/svg/SVGImport.js +++ b/src/svg/SVGImport.js @@ -116,11 +116,14 @@ new function() { } function importPoly(node, type) { - var path = new Path(), - points = node.points; - path.moveTo(points.getItem(0)); - for (var i = 1, l = points.numberOfItems; i < l; i++) - path.lineTo(points.getItem(i)); + var coords = node.getAttribute('points').match( + /[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g), + points = []; + for (var i = 0, l = coords.length; i < l; i += 2) + points.push(new Point( + parseFloat(coords[i]), + parseFloat(coords[i + 1]))); + var path = new Path(points); if (type === 'polygon') path.closePath(); return path;