From d7cdbe16801eb3b312a348b3533e96f71cbef749 Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Wed, 13 Feb 2019 14:17:18 +0100 Subject: [PATCH] sparkles: Added support for offset and margin options --- packages/plugin-cutonfold/README.md | 6 ++++-- packages/plugin-cutonfold/src/index.js | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/plugin-cutonfold/README.md b/packages/plugin-cutonfold/README.md index 14b22f50068..a64b9337b9d 100644 --- a/packages/plugin-cutonfold/README.md +++ b/packages/plugin-cutonfold/README.md @@ -66,8 +66,8 @@ This plugin provides the `cutonfold` macro. ```js macro('cutonfold', { - from: points.cbNeck - , to: points.cbHips + from: points.cbNeck, + to: points.cbHips }); ``` @@ -75,6 +75,8 @@ macro('cutonfold', { - `to`: A point object at the start of the cut-on-fold indicator - `from`: A point object at the end of the cut-on-fold indicator + - `offset`: Distance in mm that the cut-on-fold line is offset from the line between `from` and `to`. Default: 50mm. + - `margin`: Percentange the cut-on-fold line will remain from the `from` and `to` points. Default: 5%. As all freesewing macros, bundle these parameters into a single object. diff --git a/packages/plugin-cutonfold/src/index.js b/packages/plugin-cutonfold/src/index.js index d7f26ed0d79..231b82c6ed0 100644 --- a/packages/plugin-cutonfold/src/index.js +++ b/packages/plugin-cutonfold/src/index.js @@ -15,13 +15,18 @@ export default { macros: { cutonfold: function(so) { let points = this.points; - points.cutonfoldFrom = so.to.shiftTowards(so.from, 30); - points.cutonfoldTo = so.from.shiftTowards(so.to, 30); + let so = { + offset: 50, + margin: 0.05, + ...so + }; + points.cutonfoldFrom = so.to.shiftFractionTowards(so.from, so.margin); + points.cutonfoldTo = so.from.shiftFractionTowards(so.to, so.margin); points.cutonfoldVia1 = so.to - .shiftTowards(so.from, 50) + .shiftTowards(so.from, so.offset) .rotate(-90, points.cutonfoldFrom); points.cutonfoldVia2 = so.from - .shiftTowards(so.to, 50) + .shiftTowards(so.to, so.offset) .rotate(90, points.cutonfoldTo); let text = so.grainline ? "cutOnFoldAndGrainline" : "cutOnFold"; this.paths.cutonfold = new this.Path()