From 9a9afa3be380fcaded1d333154a764715ff2eb81 Mon Sep 17 00:00:00 2001 From: Teja Date: Thu, 7 Jan 2016 11:04:12 +0100 Subject: [PATCH] bugfix. added default coordinates for circle / ellipse elements as corel omits them sometimes. --- .../plugins/svgtogcode/static/js/matrix_oven.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js b/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js index baba7d8d..05b4ffb7 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js +++ b/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js @@ -419,7 +419,13 @@ Snap.plugin(function (Snap, Element, Paper, global) { if (tag === 'circle') { rx = ry = +old_element.attr('r'); } - + + // If 'x' and 'y' are not specified, then set both to 0. // CorelDraw is creating that sometimes + if (!validCoordinate(cx)) + cx = 0; + if (!validCoordinate(cy)) + cy = 0; + d += _convertToString([ ['M', (cx - rx), (cy)], ['C', (cx - rx), (cy - ry / num), (cx - rx / num), (cy - ry), (cx), (cy - ry)], @@ -456,8 +462,10 @@ Snap.plugin(function (Snap, Element, Paper, global) { // Validity checks from http://www.w3.org/TR/SVG/shapes.html#RectElement: // If 'x' and 'y' are not specified, then set both to 0. // CorelDraw is creating that sometimes - if (!validCoordinate(x) && !validCoordinate(y)) - x = y = 0; + if (!validCoordinate(x)) + x = 0; + if (!validCoordinate(y)) + y = 0; // If neither ‘rx’ nor ‘ry’ are properly specified, then set both rx and ry to 0. (This will result in square corners.) if (!validRadius(rx) && !validRadius(ry)) { rx = ry = 0;