From 16baa11dc6bd0e22fa69fef41d73c1280e291c44 Mon Sep 17 00:00:00 2001 From: woutervdub Date: Tue, 31 Oct 2023 18:41:09 +0000 Subject: [PATCH] Fix bugs in #5336 --- designs/sandy/src/curved-waistband.mjs | 2 +- designs/sandy/src/skirt.mjs | 54 +++++++++++-------- .../dev/reference/macros/ringsector/en.md | 6 +-- plugins/plugin-ringsector/src/index.mjs | 14 ++--- 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/designs/sandy/src/curved-waistband.mjs b/designs/sandy/src/curved-waistband.mjs index c2cad07de0c..dd16c5a3541 100644 --- a/designs/sandy/src/curved-waistband.mjs +++ b/designs/sandy/src/curved-waistband.mjs @@ -50,7 +50,7 @@ export function draftCurvedWaistband({ if (points[uid + 'Rotated']) points[shortId + 'Rotated'] = points[uid + 'Rotated'].copy() } - if (sa) paths.sa = paths.seam.offset(sa * -1).addClass('fabric sa') + if (sa) paths.sa = paths.seam.offset(sa).addClass('fabric sa') /* * Annotations diff --git a/designs/sandy/src/skirt.mjs b/designs/sandy/src/skirt.mjs index adcca37b83f..4332ebbb051 100644 --- a/designs/sandy/src/skirt.mjs +++ b/designs/sandy/src/skirt.mjs @@ -111,40 +111,41 @@ function sandySkirt({ if (sa) { paths.hemBase = new Path() - .move(points.ex2) - .curve(points.ex2c, points.ex1c, points.ex1) - .curve(points.ex1cFlipped, points.ex2cFlipped, points.ex2Flipped) - .offset(store.get('fullLength') * options.lengthBonus * options.hemWidth * -1) + .move(points.ex2Flipped) + .curve(points.ex2cFlipped, points.ex1cFlipped, points.ex1) + .curve(points.ex1c, points.ex2c, points.ex2) + .offset(store.get('fullLength') * options.lengthBonus * options.hemWidth) paths.saBase = new Path() - .move(points.in2Flipped) - .curve(points.in2cFlipped, points.in1cFlipped, points.in1) - .curve(points.in1c, points.in2c, points.in2) + .move(points.in2) + .curve(points.in2c, points.in1c, points.in1) + .curve(points.in1cFlipped, points.in2cFlipped, points.in2Flipped) - if (!options.seamlessFullCircle) paths.saBase = paths.saBase.line(points.ex2) - paths.saBase = paths.saBase.offset(sa * -1) + if (!options.seamlessFullCircle) + paths.saBase = new Path().move(points.ex2).line(points.ex2).join(paths.saBase) + paths.saBase = paths.saBase.offset(sa) paths.hemBase.hide() paths.saBase.hide() if (options.seamlessFullCircle) { paths.sa = new Path() - .move(points.in2Flipped) - .line(paths.saBase.start()) - .join(paths.saBase) - .line(points.in2) - .move(points.ex2) + .move(points.ex2Flipped) .line(paths.hemBase.start()) .join(paths.hemBase) - .line(points.ex2Flipped) + .line(points.ex2) + .move(points.in2) + .line(paths.saBase.start()) + .join(paths.saBase) + .line(points.in2Flipped) .attr('class', 'fabric sa') } else { paths.sa = new Path() - .move(points.in2Flipped) - .line(paths.saBase.start()) - .join(paths.saBase) + .move(points.ex2Flipped) .line(paths.hemBase.start()) .join(paths.hemBase) - .line(points.ex2Flipped) + .line(paths.saBase.start()) + .join(paths.saBase) + .line(points.in2Flipped) .attr('class', 'fabric sa') } } @@ -171,15 +172,24 @@ function sandySkirt({ } // Logo - points.logo = points.in2FlippedRotated.shiftFractionTowards(points.ex2FlippedRotated, 0.3) + points.logo = points.in2FlippedRotated.shiftFractionTowards( + points.ex2FlippedRotated, + options.seamlessFullCircle ? 0.3 : 0.1 + ) snippets.logo = new Snippet('logo', points.logo) // Title - points.title = points.in2FlippedRotated.shiftFractionTowards(points.ex2FlippedRotated, 0.5) + points.title = points.in2FlippedRotated.shiftFractionTowards( + points.ex2FlippedRotated, + options.seamlessFullCircle ? 0.5 : 0.25 + ) macro('title', { at: points.title, nr: 1, title: 'skirt' }) // Scalebox - points.scalebox = points.in2FlippedRotated.shiftFractionTowards(points.ex2FlippedRotated, 0.7) + points.scalebox = points.in2FlippedRotated.shiftFractionTowards( + points.ex2FlippedRotated, + options.seamlessFullCircle ? 0.7 : 0.45 + ) macro('scalebox', { at: points.scalebox }) // Notches diff --git a/markdown/dev/reference/macros/ringsector/en.md b/markdown/dev/reference/macros/ringsector/en.md index 5b757b9a56d..fb850181e52 100644 --- a/markdown/dev/reference/macros/ringsector/en.md +++ b/markdown/dev/reference/macros/ringsector/en.md @@ -26,7 +26,6 @@ macro('ringsector', { Number insideRadius, Number outsideRadius, Boolean rotate = false, - String id='ringsector', }) ``` @@ -51,18 +50,19 @@ macro('ringsector', { | Property | Default | Type | Description | |---------------:|-------------------|------------|-------------| -| `id` | `ringsector` | `string` | The ID of this macro instance | +| `id` | `ringsector` | String | The id to use in auto-generate macro points and paths | | `center` | `new Point(0,0)` | [Point][1] | The center point of the ring sector | | `angle` | | Number | The angle the ring sector should cover | | `insideRadius` | | Number | The inside radius of the ring sector | | `outsideRadius` | | Number | The outside radius of the ring sector | | `rotate` | `false` | Boolean | Whether or not to rotate the ringsector so one of its sides is vertical (see [example below](#example-when-rotatetrue)) | -| `id` | `ringsector` | String | The id to use in auto-generate macro points and paths | [1]: /reference/api/point ## Notes +The `ringsector` macro creates a `path` that can be used as a seam path for a part. If doing so, the left side of the path assumes a `cutOnFold`, as the `sa` is not offset here like it is along the rest of the `path`. + ### Example when rotate=true diff --git a/plugins/plugin-ringsector/src/index.mjs b/plugins/plugin-ringsector/src/index.mjs index 533108e1c00..88629c69614 100644 --- a/plugins/plugin-ringsector/src/index.mjs +++ b/plugins/plugin-ringsector/src/index.mjs @@ -126,7 +126,7 @@ export const plugin = { // Flip all the points to generate the full ring sector for (const id of ['in2', 'in2c', 'in1c', 'ex1c', 'ex2c', 'ex2']) { - points[ids[id + 'Flipped']] = points[ids[id]].flipX() + points[ids[id + 'Flipped']] = points[ids[id]].flipX(center) } // Rotate all the points angle/2 @@ -147,12 +147,12 @@ export const plugin = { } // Construct the path of the full ring sector paths[pathIds.path] = new Path() - .move(points[ids.in2Flipped]) - .curve(points[ids.in2cFlipped], points[ids.in1cFlipped], points[ids.in1]) - .curve(points[ids.in1c], points[ids.in2c], points[ids.in2]) - .line(points[ids.ex2]) - .curve(points[ids.ex2c], points[ids.ex1c], points[ids.ex1]) - .curve(points[ids.ex1cFlipped], points[ids.ex2cFlipped], points[ids.ex2Flipped]) + .move(points[ids.ex2Flipped]) + .curve(points[ids.ex2cFlipped], points[ids.ex1cFlipped], points[ids.ex1]) + .curve(points[ids.ex1c], points[ids.ex2c], points[ids.ex2]) + .line(points[ids.in2]) + .curve(points[ids.in2c], points[ids.in1c], points[ids.in1]) + .curve(points[ids.in1cFlipped], points[ids.in2cFlipped], points[ids.in2Flipped]) .close() /*