From 17f29984e5df2e15fefc0f944070846295b2e9e8 Mon Sep 17 00:00:00 2001 From: make-ing Date: Tue, 16 Feb 2016 12:53:20 +0100 Subject: [PATCH 1/5] fixed image bug with missing {} --- src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js b/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js index dce7235a..478c638e 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js +++ b/src/octoprint/plugins/svgtogcode/static/js/matrix_oven.js @@ -70,12 +70,14 @@ 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 (!isFinite(x)) + if (!isFinite(x)) { console.log('No attribute "x" in image tag. Assuming 0.') x = 0; - if (!isFinite(y)) + } + if (!isFinite(y)) { console.log('No attribute "y" in image tag. Assuming 0.') y = 0; + } var transform = elem.transform(); var matrix = transform['totalMatrix']; var transformedX = matrix.x(x, y); From 94effaeda7b8db8c5256c65faf96f82fd074b2d1 Mon Sep 17 00:00:00 2001 From: make-ing Date: Tue, 16 Feb 2016 13:54:39 +0100 Subject: [PATCH 2/5] fixed wrong positioning if only x2 value was to out of bounds maybe also need to be tested for y direction --- src/octoprint/plugins/svgtogcode/static/js/working_area.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 24f4d498..108b3e4e 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -345,7 +345,7 @@ $(function(){ dx = -svgBB.x + 0.01; outside = true; } else if(svgBB.x2 > waBB.x2){ - dx = -svgBB.x2 + waBB.x2 - 0.01; + dx = -svgBB.x + 0.01; outside = true; } if(svgBB.y < waBB.y){ From 60fb13faa2364bbd818a5e26f9bd160a2a4781ec Mon Sep 17 00:00:00 2001 From: make-ing Date: Wed, 17 Feb 2016 16:17:45 +0100 Subject: [PATCH 3/5] fixed bug with embedded images in svg's --- src/octoprint/plugins/svgtogcode/static/js/working_area.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 108b3e4e..d0c44888 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -758,7 +758,7 @@ $(function(){ self._embedAllImages = function(svg, callback){ var allImages = svg.selectAll('image'); - var linkedImages = allImages.items.filter(function(i){ return !i.attr('href').startsWith('data:') }); + var linkedImages = allImages.items.filter(function(i){ return !i.attr('xlink:href').startsWith('data:') }); if(linkedImages.length > 0){ var callbackCounter = linkedImages.length; for (var i = 0; i < linkedImages.length; i++) { From 327ac869ced6321037516216831c8dcbe254ff9a Mon Sep 17 00:00:00 2001 From: make-ing Date: Mon, 22 Feb 2016 10:37:20 +0100 Subject: [PATCH 4/5] added support for embedded images in svg via "href" and "xlink:href" --- src/octoprint/plugins/svgtogcode/static/js/working_area.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 108b3e4e..035a6081 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -758,7 +758,12 @@ $(function(){ self._embedAllImages = function(svg, callback){ var allImages = svg.selectAll('image'); - var linkedImages = allImages.items.filter(function(i){ return !i.attr('href').startsWith('data:') }); + var linkedImages = allImages.items.filter(function(i){ + if(i.attr('xlink:href') != null) { + return !i.attr('xlink:href').startsWith('data:'); + } else if(i.attr('href') != null) { + return !i.attr('href').startsWith('data:'); + } if(linkedImages.length > 0){ var callbackCounter = linkedImages.length; for (var i = 0; i < linkedImages.length; i++) { From e54364a45cb6139ceec2ae819b63d8b093925640 Mon Sep 17 00:00:00 2001 From: make-ing Date: Mon, 22 Feb 2016 10:54:29 +0100 Subject: [PATCH 5/5] parenthesis bug fixed --- src/octoprint/plugins/svgtogcode/static/js/working_area.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugins/svgtogcode/static/js/working_area.js b/src/octoprint/plugins/svgtogcode/static/js/working_area.js index 035a6081..4b35b252 100644 --- a/src/octoprint/plugins/svgtogcode/static/js/working_area.js +++ b/src/octoprint/plugins/svgtogcode/static/js/working_area.js @@ -763,7 +763,7 @@ $(function(){ return !i.attr('xlink:href').startsWith('data:'); } else if(i.attr('href') != null) { return !i.attr('href').startsWith('data:'); - } + }}); if(linkedImages.length > 0){ var callbackCounter = linkedImages.length; for (var i = 0; i < linkedImages.length; i++) {