summaryrefslogtreecommitdiff
path: root/embroider_input.py
diff options
context:
space:
mode:
Diffstat (limited to 'embroider_input.py')
-rw-r--r--embroider_input.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/embroider_input.py b/embroider_input.py
index e3a7b0c2..04d79d4f 100644
--- a/embroider_input.py
+++ b/embroider_input.py
@@ -37,12 +37,12 @@ def main(embroidery_file):
stop=stitch.flags & STOP,
trim=stitch.flags & TRIM)
- dimensions = stitch_plan.dimensions
+ extents = stitch_plan.extents
svg = etree.Element("svg", nsmap=inkex.NSS, attrib=
{
- "width": "%s" % dimensions[0],
- "height": "%s" % dimensions[1],
- "viewBox": "0 0 %s %s" % dimensions,
+ "width": str(extents[0] * 2),
+ "height": str(extents[1] * 2),
+ "viewBox": "0 0 %s %s" % (extents[0] * 2, extents[1] * 2),
})
render_stitch_plan(svg, stitch_plan)
@@ -51,6 +51,10 @@ def main(embroidery_file):
layer.set(INKSCAPE_LABEL, os.path.basename(embroidery_file))
layer.attrib.pop('id')
+ # Shift the design so that its origin is at the center of the canvas
+ # Note: this is NOT the same as centering the design in the canvas!
+ layer.set('transform', 'translate(%s,%s)' % (extents[0], extents[1]))
+
print etree.tostring(svg)
if __name__ == '__main__':