From 589d4e6e73e34d9ae76e27dd91c1bf89a595ceab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 9 Dec 2012 18:04:56 -0800 Subject: [PATCH] Handle exporting of empty paths. --- examples/SVG Export/Empty Path Testing.html | 2 ++ src/svg/SvgExport.js | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/SVG Export/Empty Path Testing.html b/examples/SVG Export/Empty Path Testing.html index 7698f7f5..8bf2481a 100644 --- a/examples/SVG Export/Empty Path Testing.html +++ b/examples/SVG Export/Empty Path Testing.html @@ -18,6 +18,8 @@ var segments = [new Point(30, 90), new Point(100, 150)]; var path2 = new Path(segments); path2.strokeColor = 'yellow'; + + var path3 = new Path(); document.getElementById('svg').appendChild(project.exportSvg()); diff --git a/src/svg/SvgExport.js b/src/svg/SvgExport.js index 39b9603b..34afe7c0 100644 --- a/src/svg/SvgExport.js +++ b/src/svg/SvgExport.js @@ -182,9 +182,11 @@ new function() { return segments.length === 4 && path._closed && isColinear(0, 2) && isColinear(1, 3) ? 'rect' - : segments.length >= 3 - ? path._closed ? 'polygon' : 'polyline' - : 'line'; + : segments.length === 0 + ? 'empty' + : segments.length >= 3 + ? path._closed ? 'polygon' : 'polyline' + : 'line'; } else if (path._closed) { if (segments.length === 8 && isArc(0) && isArc(2) && isArc(4) && isArc(6) @@ -236,6 +238,8 @@ new function() { angle = determineAngle(path, segments, type, center), attrs; switch (type) { + case 'empty': + return null; case 'path': attrs = { d: getPath(path, segments)