diff --git a/src/part.js b/src/part.js
index d2139d40aa0..e434bae5f5b 100644
--- a/src/part.js
+++ b/src/part.js
@@ -110,9 +110,11 @@ Part.prototype.boundary = function() {
if (topLeft.y === Infinity) topLeft.y = 0;
if (bottomRight.x === -Infinity) bottomRight.x = 0;
if (bottomRight.y === -Infinity) bottomRight.y = 0;
- // Add 10mm margin
- this.topLeft = new Point(topLeft.x - 10, topLeft.y - 10);
- this.bottomRight = new Point(bottomRight.x + 10, bottomRight.y + 10);
+ // Add margin
+ let margin = this.context.settings.margin;
+ if (this.context.settings.paperless && margin < 10) margin = 10;
+ this.topLeft = new Point(topLeft.x - margin, topLeft.y - margin);
+ this.bottomRight = new Point(bottomRight.x + margin, bottomRight.y + margin);
this.width = this.bottomRight.x - this.topLeft.x;
this.height = this.bottomRight.y - this.topLeft.y;
diff --git a/src/pattern.js b/src/pattern.js
index 9339a111f92..b324591cd96 100644
--- a/src/pattern.js
+++ b/src/pattern.js
@@ -24,7 +24,8 @@ export default function Pattern(config = false) {
mode: "draft",
idPrefix: "fs-",
locale: "en",
- units: "metric"
+ units: "metric",
+ margin: 2
};
this.options = {};
this.store = new Store();
diff --git a/src/svg.js b/src/svg.js
index c4789530482..bdb7cd35aeb 100644
--- a/src/svg.js
+++ b/src/svg.js
@@ -147,7 +147,7 @@ Svg.prototype.renderPart = function(part) {
}
for (let key in part.snippets) {
let snippet = part.snippets[key];
- svg += this.renderSnippet(snippet);
+ svg += this.renderSnippet(snippet, part);
}
return svg;
@@ -232,9 +232,21 @@ Svg.prototype.renderCircle = function(point) {
};
/** Returns SVG code for a snippet */
-Svg.prototype.renderSnippet = function(snippet) {
+Svg.prototype.renderSnippet = function(snippet, part) {
+ let x = snippet.anchor.x;
+ let y = snippet.anchor.y;
+ let scale = snippet.attributes.get("data-scale");
+ if (scale) {
+ snippet.attributes.add("transform", `translate(${x}, ${y})`);
+ snippet.attributes.add("transform", `scale(${scale})`);
+ snippet.attributes.add("transform", `translate(${x * -1}, ${y * -1})`);
+ }
+ let rotate = snippet.attributes.get("data-rotate");
+ if (rotate) {
+ snippet.attributes.add("transform", `rotate(${rotate}, ${x}, ${y})`);
+ }
let svg = this.nl();
- svg += `";
diff --git a/tests/fixtures/render.js b/tests/fixtures/render.js
index 4155c019e45..fb47f157d98 100644
--- a/tests/fixtures/render.js
+++ b/tests/fixtures/render.js
@@ -93,7 +93,7 @@ var render = {