From 4184e31ff748740cfbdb44b5835a7d61e45cf75c Mon Sep 17 00:00:00 2001 From: Wouter van Wageningen Date: Fri, 5 May 2023 20:10:19 +0000 Subject: [PATCH] first --- markdown/dev/reference/macros/crossbox/en.md | 75 ++++++++++++++++++++ markdown/dev/reference/macros/pleat/en.md | 47 ++++++++++++ plugins/plugin-annotations/src/crossbox.mjs | 6 +- 3 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 markdown/dev/reference/macros/crossbox/en.md create mode 100644 markdown/dev/reference/macros/pleat/en.md diff --git a/markdown/dev/reference/macros/crossbox/en.md b/markdown/dev/reference/macros/crossbox/en.md new file mode 100644 index 00000000000..db886d221ac --- /dev/null +++ b/markdown/dev/reference/macros/crossbox/en.md @@ -0,0 +1,75 @@ +--- +title: crossbox +--- + +The `crossbox` macro is used to mark a feature on a sewing pattern +to attach and reinforce an attachment between two pieces. +This is regularly done by sewing along the outside of the pieces +that needs to be joined, and then sewing along the diagonals too. + +It is provided by [plugin-annotations](/reference/plugins/annotations/). + +## Signature + +```js +macro('crossbox', { + Point from, + Point to, + String text, +}) +``` + +## Example + + +```js +({ Point, points, Path, paths, macro, part }) => { + points.partTL = new Point(0,0) + points.partTR = new Point(0,70) + points.partBR = new Point(50,70) + points.partBL = new Point(50,0) + + paths.part = new Path() + .move(points.partTL) + .line(points.partTR) + .line(points.partBR) + .line(points.partBL) + .close() + + points.tl = new Point(5,5) + points.br = new Point(45,25) + + macro('crossbox', { + from: points.tl, + to: points.br, + text: 'attach here', + }) + + return part +} +``` + + +## Configuration + +| Property | Default | Type | Description | +|----------------:|----------|---------------------|-------------| +| `from` | | [Point](/reference/api/point) | The top left point of the crossbox | +| `to` | | [Point](/reference/api/point) | The bottom right point of the crossbox | +| `text` | | String | The text to go on the dimension if not the from-to horizontal distance | + +## Result + +| Generated Element | Description | +|-------------------|-------------| +| `points.${id}_boxTopLeft` | Point Top Left of the outer box | +| `points.${id}_boxTopRight` | Point Top Right of the outer box | +| `points.${id}_boxBottomLeft` | Point Bottom Left of the outer box | +| `points.${id}_boxBottomRight` | Point Bottom Right of the outer box | +| `points.${id}_topCrossTL` | Point Top Left of the inner box | +| `points.${id}_topCrossTR` | Point Top Right of the inner box | +| `points.${id}_topCrossBL` | Point Bottom Left of the inner box | +| `points.${id}_topCrossBR` | Point Bottom Right of the inner box | +| `points.${id}_textAnchor` | Point for the text | +| `paths.${id}crossBox` | Path for the outer box | +| `paths.${id}_topCross` | Path for the inner box and cross | diff --git a/markdown/dev/reference/macros/pleat/en.md b/markdown/dev/reference/macros/pleat/en.md new file mode 100644 index 00000000000..0df810df107 --- /dev/null +++ b/markdown/dev/reference/macros/pleat/en.md @@ -0,0 +1,47 @@ +--- +title: pleat +--- + +The `pleat` macro is used to mark a sewing pattern to attach and reinforce +and attachment between two pieces. This is regularly done by sewing along +the outside of the pieces that needs to be joined, and then sewing along the +diagonals too. + +It is provided by [plugin-annotations](/reference/plugins/annotations/). + +## Signature + +```js +macro('pleat', { + Point from, + Point to, + String Prefix = 'pleat', + Number margin = 35, + Boolean reverse = false, +}) +``` + +## Example + + +```js +({ Point, points, Path, paths, macro, part }) => { + points.seamTL = new Point(0,0) + points.seamTR = new Point(70,0) + + paths.seam = new Path() + .move(points.seamTL) + .line(points.seamTR) + + points.from = new Point(30,0) + points.t0 = new Point(40,0) + + macro('pleat', { + from: points.from, + to: points.to, + }) + + return part +} +``` + diff --git a/plugins/plugin-annotations/src/crossbox.mjs b/plugins/plugin-annotations/src/crossbox.mjs index 1a99225e331..3909224327d 100644 --- a/plugins/plugin-annotations/src/crossbox.mjs +++ b/plugins/plugin-annotations/src/crossbox.mjs @@ -1,8 +1,8 @@ // Export macros export const crossboxMacros = { crossbox: function (so, { points, Point, paths, Path, getId }) { - let id = getId() - let shiftFraction = 0.1 + const id = getId() + const shiftFraction = 0.1 points[id + '_boxTopLeft'] = so.from.copy() points[id + '_boxBottomRight'] = so.to.copy() points[id + '_boxTopRight'] = new Point(so.to.x, so.from.y) @@ -44,7 +44,7 @@ export const crossboxMacros = { .line(points[id + '_topCrossBL']) .attr('class', 'lining dotted stroke-sm') if (typeof so.text === 'string') { - points.textAnchor = points[id + '_boxTopLeft'] + points[id + '_textAnchor'] = points[id + '_boxTopLeft'] .shiftFractionTowards(points[id + '_boxBottomRight'], 0.5) .attr('data-text', so.text) .attr('data-text-class', 'center')