From 88c64b4780ada93d7cc5457c0440452f95f81889 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sun, 16 Mar 2025 18:46:07 -0400 Subject: [PATCH] fix shaper path output and add shaper xmlns --- src/kiri-mode/laser/driver.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/kiri-mode/laser/driver.js b/src/kiri-mode/laser/driver.js index 341707f5..3d3cf24f 100644 --- a/src/kiri-mode/laser/driver.js +++ b/src/kiri-mode/laser/driver.js @@ -701,13 +701,18 @@ function exportSVG(settings, data, cut_color) { my = max.y; lines.push(''); lines.push(''); + let svg = ['`); + svg.push(`width="${width}in" height="${height}in" viewBox="0 0 ${width} ${height}"`); } else { - lines.push(``); + svg.push(`width="${width}mm" height="${height}mm" viewBox="0 0 ${width} ${height}"`); } + lines.push(svg.join(' ') + ' version="1.1">'); }, function(poly, color, thick) { let cout = zcolor || colors[((color-1) % colors.length)]; @@ -726,7 +731,7 @@ function exportSVG(settings, data, cut_color) { def.push(`z="${z}"`); } let path = poly.map((xy, i) => i > 0 ? `L${xy}` : `M${xy}`); - lines.push(`<${def.join(' ')} B="${path.join(' ')}" fill="none" stroke="${cout}" stroke-width="${swidth}" />`); + lines.push(`<${def.join(' ')} d="${path.join(' ')}" fill="none" stroke="${cout}" stroke-width="${swidth}" />`); } else { let def = ["polyline"]; if (z !== undefined) def.push(`z="${z}"`); @@ -738,7 +743,7 @@ function exportSVG(settings, data, cut_color) { lines.push(""); }, function(point) { - z = point.zi ?? point.z; + z = ctOutStack ? (point.zi ?? point.z) : undefined; let px = point.x - dx; let py = my - point.y - dy; // convert to imperial for stacked