From 5dc740130894546ffbed98fbd313215e8cc4ee0d Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Sun, 18 Sep 2022 17:01:19 +0200 Subject: [PATCH] chore(core): Use hide, not render --- designs/aaron/src/front.mjs | 2 +- designs/bee/src/band-tie.mjs | 4 +- designs/bee/src/neck-tie.mjs | 4 +- designs/benjamin/src/base.mjs | 3 +- designs/benjamin/src/bow2.mjs | 5 +- designs/benjamin/src/bow3.mjs | 5 +- designs/benjamin/src/ribbon.mjs | 5 +- designs/breanna/src/back.mjs | 2 +- designs/breanna/src/front.mjs | 2 +- designs/breanna/src/sleeve.mjs | 2 +- designs/brian/src/front.mjs | 14 ++-- designs/brian/src/sleeve.mjs | 2 +- designs/bruce/src/front.mjs | 6 +- designs/bruce/src/side.mjs | 4 +- designs/carlton/src/belt.mjs | 2 - designs/carlton/src/front.mjs | 4 +- designs/carlton/src/topsleeve.mjs | 1 - designs/carlton/src/undersleeve.mjs | 1 - designs/cathrin/src/base.mjs | 4 +- designs/cathrin/src/panels.mjs | 2 +- designs/diana/src/front.mjs | 4 +- designs/diana/src/sleeve.mjs | 4 +- designs/examples/src/plugins.mjs | 7 +- designs/florent/src/briminterfacing.mjs | 4 +- designs/florent/src/side.mjs | 2 +- designs/florent/src/top.mjs | 2 +- designs/holmes/src/gore.mjs | 5 +- designs/huey/src/back.mjs | 4 +- designs/huey/src/front.mjs | 4 +- designs/huey/src/sleeve.mjs | 4 +- designs/hugo/src/back.mjs | 2 +- designs/hugo/src/front.mjs | 5 +- designs/hugo/src/pocket.mjs | 8 +-- designs/jaeger/src/back.mjs | 10 +-- designs/jaeger/src/front.mjs | 4 +- designs/jaeger/src/side.mjs | 1 - designs/jaeger/src/undercollar.mjs | 4 +- designs/noble/src/backinside.mjs | 4 +- designs/noble/src/backpoints.mjs | 2 +- designs/noble/src/frontpoints.mjs | 29 ++++----- designs/paco/src/backpocketbag.mjs | 5 +- designs/paco/src/backpocketwelt.mjs | 5 +- .../paco/src/backpocketweltinterfacing.mjs | 5 +- designs/paco/src/cuff.mjs | 5 +- designs/paco/src/frontpocketbag.mjs | 5 +- designs/penelope/src/waistband.mjs | 5 +- designs/plugintest/src/plugin-gore.mjs | 1 - designs/plugintest/src/plugin-round.mjs | 4 +- designs/sandy/src/skirt.mjs | 4 +- designs/shin/src/back.mjs | 4 +- designs/shin/src/front.mjs | 4 +- designs/simon/src/back.mjs | 14 ++-- designs/simon/src/front.mjs | 8 +-- designs/simon/src/sleeve.mjs | 8 +-- designs/simon/src/yoke.mjs | 4 +- designs/simone/src/fba-front.mjs | 10 +-- designs/sven/src/frontback.mjs | 4 +- designs/sven/src/sleeve.mjs | 4 +- designs/teagan/src/front.mjs | 6 +- designs/titan/src/back.mjs | 4 +- designs/titan/src/front.mjs | 4 +- designs/tutorial/src/step5-8.mjs | 4 -- designs/tutorial/src/step9-11.mjs | 2 - designs/wahid/src/back.mjs | 8 +-- designs/wahid/src/front.mjs | 6 +- designs/wahid/src/pocketbag.mjs | 4 +- designs/wahid/src/pocketfacing.mjs | 4 +- designs/waralee/src/cutout.mjs | 5 +- designs/waralee/src/mini.mjs | 10 ++- designs/waralee/src/pants.mjs | 10 ++- designs/waralee/src/pantsproto.mjs | 44 ++++++------- designs/yuri/src/back.mjs | 12 ++-- designs/yuri/src/front.mjs | 12 ++-- designs/yuri/src/sleeve.mjs | 10 +-- packages/core/src/part.mjs | 65 ++++++++++++++++--- packages/core/src/path.mjs | 59 +++++++++++++---- packages/core/src/pattern.mjs | 21 ++++-- packages/core/src/svg.mjs | 39 +++++++---- packages/core/tests/path.test.mjs | 6 +- plugins/plugin-gore/src/index.mjs | 6 +- plugins/plugin-round/src/index.mjs | 5 +- plugins/plugin-theme/src/index.mjs | 2 +- 82 files changed, 337 insertions(+), 293 deletions(-) diff --git a/designs/aaron/src/front.mjs b/designs/aaron/src/front.mjs index e51707831ed..7e7d46d49ab 100644 --- a/designs/aaron/src/front.mjs +++ b/designs/aaron/src/front.mjs @@ -44,7 +44,7 @@ export const front = { part, }) => { // Hide Brian paths - for (let key of Object.keys(paths)) paths[key].render = false + for (let key of Object.keys(paths)) paths[key].hide() // Handle stretch for (let i in points) points[i].x = points[i].x * (1 - options.stretchFactor) diff --git a/designs/bee/src/band-tie.mjs b/designs/bee/src/band-tie.mjs index 8084e3337a0..6d82f1f7222 100644 --- a/designs/bee/src/band-tie.mjs +++ b/designs/bee/src/band-tie.mjs @@ -38,9 +38,7 @@ export const bandTie = { }) => { // band tie if (!options.ties) { - if (!options.crossBackTies) { - part.render = false - } + if (!options.crossBackTies) part.hide() } let bandTieLength if (options.crossBackTies) diff --git a/designs/bee/src/neck-tie.mjs b/designs/bee/src/neck-tie.mjs index 3ce80eef748..5d75b2678bc 100644 --- a/designs/bee/src/neck-tie.mjs +++ b/designs/bee/src/neck-tie.mjs @@ -40,9 +40,7 @@ export const neckTie = { part, }) => { // neck tie - if (!options.ties) { - part.render = false - } + if (!options.ties) part.hide() let neckTieLength if (options.crossBackTies) neckTieLength = diff --git a/designs/benjamin/src/base.mjs b/designs/benjamin/src/base.mjs index dbb3da2687d..084a1798204 100644 --- a/designs/benjamin/src/base.mjs +++ b/designs/benjamin/src/base.mjs @@ -65,7 +65,7 @@ function draftBenjaminBase({ points.titleAnchor = new Point(points.tip1Top.x, 0) // Paths - paths.cap = new Path().move(points.tip2Bottom) + paths.cap = new Path().hide().move(points.tip2Bottom) if (options.endStyle === 'straight') { paths.cap = new Path().move(points.tip2Bottom).line(points.tip2Top) } else if (options.endStyle === 'pointed') { @@ -87,7 +87,6 @@ function draftBenjaminBase({ }) paths.cap = paths.bottomRounded.join(paths.topRounded) } - paths.cap.render = false if (options.bowStyle === 'diamond' || options.bowStyle === 'butterfly') { const cpl = options.bowStyle === 'diamond' ? bow / 10 : bow / 4 diff --git a/designs/benjamin/src/bow2.mjs b/designs/benjamin/src/bow2.mjs index ac66bd7aa23..c520e6b498e 100644 --- a/designs/benjamin/src/bow2.mjs +++ b/designs/benjamin/src/bow2.mjs @@ -13,10 +13,7 @@ function draftBenjaminBow2({ paperless, part, }) { - if (!options.adjustmentRibbon) { - part.render = false - return part - } + if (!options.adjustmentRibbon) return part.hide() points.bandBottomLeft = points.bandBottomLeft.shift(180, 90) points.bandTopLeft = points.bandBottomLeft.flipY() diff --git a/designs/benjamin/src/bow3.mjs b/designs/benjamin/src/bow3.mjs index 73dcc537d65..e25043eb46f 100644 --- a/designs/benjamin/src/bow3.mjs +++ b/designs/benjamin/src/bow3.mjs @@ -13,10 +13,7 @@ function draftBenjaminBow3({ paperless, part, }) { - if (!options.adjustmentRibbon) { - part.render = false - return part - } + if (!options.adjustmentRibbon) return part.hide() points.bandBottomLeft = points.bandBottomLeft.shift(180, 290) points.bandTopLeft = points.bandBottomLeft.flipY() diff --git a/designs/benjamin/src/ribbon.mjs b/designs/benjamin/src/ribbon.mjs index bf9d2aad62c..f133dbfe4f1 100644 --- a/designs/benjamin/src/ribbon.mjs +++ b/designs/benjamin/src/ribbon.mjs @@ -12,10 +12,7 @@ function draftBenjaminRibbon({ paperless, part, }) { - if (options.adjustmentRibbon) { - part.render = false - return part - } + if (options.adjustmentRibbon) return part.hide() // Points points.bottomLeft = new Point(0, 0.5 * store.get('ribbonWidth')) diff --git a/designs/breanna/src/back.mjs b/designs/breanna/src/back.mjs index 25b09633b70..03620c95131 100644 --- a/designs/breanna/src/back.mjs +++ b/designs/breanna/src/back.mjs @@ -128,7 +128,7 @@ function draftBreannaBack({ paths.seam.close().attr('class', 'fabric') paths.saBase.close() - paths.saBase.render = false + paths.saBase.hide() // Store data if (options.shoulderDart) { diff --git a/designs/breanna/src/front.mjs b/designs/breanna/src/front.mjs index 6ccf7174917..c08f7b3d00a 100644 --- a/designs/breanna/src/front.mjs +++ b/designs/breanna/src/front.mjs @@ -140,7 +140,7 @@ function draftBreannaFront({ // All done. Just set final path properties before we get to SA/final/paperless paths.seam.close().attr('class', 'fabric') - paths.saBase.close().render = false + paths.saBase.close().hide() // Anchor point points.gridAnchor = points.cfNeck.clone() diff --git a/designs/breanna/src/sleeve.mjs b/designs/breanna/src/sleeve.mjs index 951eabcbd3c..116d0912eb4 100644 --- a/designs/breanna/src/sleeve.mjs +++ b/designs/breanna/src/sleeve.mjs @@ -39,7 +39,7 @@ function draftBreannaSleeve(params) { ) // Paths - paths.sleevecap.render = false + paths.sleevecap.hide() paths.seam = new Path() .move(points.bicepsLeft) .line(points.wristLeft) diff --git a/designs/brian/src/front.mjs b/designs/brian/src/front.mjs index d274f4ed1fb..56287becb66 100644 --- a/designs/brian/src/front.mjs +++ b/designs/brian/src/front.mjs @@ -32,7 +32,7 @@ export const front = { paths.frontCollar = new Path() .move(points.hps) .curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck) - .setRender(false) + .hide() } else if (options.s3Collar > 0) { // Shift shoulder seam forward on the collar side points.s3CollarSplit = utils.curveIntersectsY( @@ -46,7 +46,7 @@ export const front = { .move(points.hps) .curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck) .split(points.s3CollarSplit)[1] - .setRender(false) + .hide() } else if (options.s3Collar < 0) { // Shift shoulder seam backward on the collar side points.s3CollarSplit = utils.curveIntersectsY( @@ -64,14 +64,14 @@ export const front = { .join( new Path().move(points.hps).curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck) ) - .setRender(false) + .hide() } if (options.s3Armhole < 0.1 && options.s3Armhole > -0.1) { points.s3ArmholeSplit = points.shoulder paths.frontArmhole = new Path() .move(points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) - .setRender(false) + .hide() } else if (options.s3Armhole > 0) { // Shift shoulder seam forward on the armhole side points.s3ArmholeSplit = utils.curveIntersectsY( @@ -85,7 +85,7 @@ export const front = { .move(points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) .split(points.s3ArmholeSplit)[0] - .setRender(false) + .hide() } else if (options.s3Armhole < 0) { // Shift shoulder seam forward on the armhole side points.s3ArmholeSplit = utils.curveIntersectsY( @@ -108,7 +108,7 @@ export const front = { ) .split(points.s3ArmholeSplit)[0] ) - .setRender(false) + .hide() } // Rename cb (center back) to cf (center front) @@ -130,7 +130,7 @@ export const front = { .line(points.s3CollarSplit) .join(paths.frontCollar) - paths.saBase.render = false + paths.saBase.hide() paths.seam = new Path() .move(points.cfNeck) .line(points.cfHem) diff --git a/designs/brian/src/sleeve.mjs b/designs/brian/src/sleeve.mjs index 5de02cfd6af..b8eaa91571e 100644 --- a/designs/brian/src/sleeve.mjs +++ b/designs/brian/src/sleeve.mjs @@ -43,7 +43,7 @@ export const sleeve = { points.wristLeft = points.wristRight.rotate(180, points.centerWrist) // Paths - paths.sleevecap.render = false + paths.sleevecap.hide() paths.seam = new Path() .move(points.bicepsLeft) .move(points.wristLeft) diff --git a/designs/bruce/src/front.mjs b/designs/bruce/src/front.mjs index b60a3e81d87..295e80d14e3 100644 --- a/designs/bruce/src/front.mjs +++ b/designs/bruce/src/front.mjs @@ -130,9 +130,9 @@ function draftBruceFront({ .move(points.leftTuskRight) .line(points.leftTuskLeft) .curve(points.curveLeftCpBottom, points.curveLeftCpTop, points.midLeft) - paths.seamStart.render = false - paths.trimBase.render = false - paths.seamEnd.render = false + paths.seamStart.hide() + paths.trimBase.hide() + paths.seamEnd.hide() paths.seam = paths.seamStart.join(paths.trimBase).join(paths.seamEnd) } else { paths.seam = new Path() diff --git a/designs/bruce/src/side.mjs b/designs/bruce/src/side.mjs index 16e9b6b50c4..e5c33c1f1e2 100644 --- a/designs/bruce/src/side.mjs +++ b/designs/bruce/src/side.mjs @@ -53,8 +53,8 @@ function draftBruceSide({ .line(points.topRight) .line(points.bottomRight) paths.hemBase = new Path().move(points.bottomRight).line(points.bottomLeft) - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.seam = paths.saBase.join(paths.hemBase).close().attr('class', 'fabric') // Anchor point for sampling diff --git a/designs/carlton/src/belt.mjs b/designs/carlton/src/belt.mjs index 01339a78079..0701ad78d50 100644 --- a/designs/carlton/src/belt.mjs +++ b/designs/carlton/src/belt.mjs @@ -28,7 +28,6 @@ function draftCarltonBelt({ via: points.topLeft, prefix: 'roundTop', radius: width / 4, - render: true, }) macro('round', { from: points.topLeft, @@ -36,7 +35,6 @@ function draftCarltonBelt({ via: points.bottomLeft, prefix: 'roundBottom', radius: width / 4, - render: true, }) // Paths diff --git a/designs/carlton/src/front.mjs b/designs/carlton/src/front.mjs index d78651d4267..951fd58db2a 100644 --- a/designs/carlton/src/front.mjs +++ b/designs/carlton/src/front.mjs @@ -222,8 +222,8 @@ function draftCarltonFront({ .line(points.hemEdge) .line(points.flbHem) paths.hemBase = new Path().move(points.flbHem).line(points.hem) - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.seam = paths.saBase.join(paths.hemBase).close().attr('class', 'fabric') paths.rollLine = new Path() diff --git a/designs/carlton/src/topsleeve.mjs b/designs/carlton/src/topsleeve.mjs index 9326a3ba462..468053ae0d0 100644 --- a/designs/carlton/src/topsleeve.mjs +++ b/designs/carlton/src/topsleeve.mjs @@ -26,7 +26,6 @@ function draftCarltonTopSleeve({ from: points.cuffBottomLeft, via: points.cuffBottomRight, radius: length / 3, - render: true, prefix: 'round', }) store.set('topCuffWidth', points.tsWristLeft.dist(points.tsWristRight)) diff --git a/designs/carlton/src/undersleeve.mjs b/designs/carlton/src/undersleeve.mjs index 613033369ba..41264b79840 100644 --- a/designs/carlton/src/undersleeve.mjs +++ b/designs/carlton/src/undersleeve.mjs @@ -25,7 +25,6 @@ function draftCarltonUnderSleeve({ from: points.cuffBottomLeft, via: points.cuffBottomRight, radius: length / 3, - render: true, prefix: 'round', }) store.set('underCuffWidth', points.usWristLeft.dist(points.usWristRight)) diff --git a/designs/cathrin/src/base.mjs b/designs/cathrin/src/base.mjs index 7829b2a3631..0d330607edf 100644 --- a/designs/cathrin/src/base.mjs +++ b/designs/cathrin/src/base.mjs @@ -72,8 +72,8 @@ function draftCathrinBase({ measurements, options, store, points, paths, Point, .line(points.bottomSide) .line(points.waistCF) .line(points.waistCB) - paths.help1.render = false - paths.help2.render = false + paths.help1.hide() + paths.help2.hide() paths.outline = new Path() .move(points.bottomCF) diff --git a/designs/cathrin/src/panels.mjs b/designs/cathrin/src/panels.mjs index 65804375b38..4344cdc0fb3 100644 --- a/designs/cathrin/src/panels.mjs +++ b/designs/cathrin/src/panels.mjs @@ -136,7 +136,7 @@ function draftCathrinPanels({ measurements, options, store, points, paths, Point .close() .attr('class', 'fabric') - paths.outline.render = false + paths.outline.hide() return part } diff --git a/designs/diana/src/front.mjs b/designs/diana/src/front.mjs index d2655af1d43..bb8df59e043 100644 --- a/designs/diana/src/front.mjs +++ b/designs/diana/src/front.mjs @@ -76,8 +76,8 @@ export function draftDianaFrontOrBack({ paths.hemBase = new Path().move(points.cHem).line(points.hem) - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.seam = paths.hemBase.join(paths.saBase).line(points.cHem) diff --git a/designs/diana/src/sleeve.mjs b/designs/diana/src/sleeve.mjs index f790e9e47b5..a5904bd62cd 100644 --- a/designs/diana/src/sleeve.mjs +++ b/designs/diana/src/sleeve.mjs @@ -25,8 +25,8 @@ function draftDianaSleeve({ sa, points, paths, Path, complete, paperless, macro, .join(paths.sleevecap) .line(points.wristLeft) paths.hemBase = new Path().move(points.wristLeft).line(points.wristRight) - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.sa = paths.saBase.offset(sa).join(paths.hemBase.offset(sa * 3)) paths.sa.line(paths.sa.start()).close().attr('class', 'fabric sa') } diff --git a/designs/examples/src/plugins.mjs b/designs/examples/src/plugins.mjs index 10faf4655f3..0256216ac74 100644 --- a/designs/examples/src/plugins.mjs +++ b/designs/examples/src/plugins.mjs @@ -45,7 +45,7 @@ export const plugin_bartackalong = { points.e = new Point(20, 10) points.f = new Point(30, 10) - paths.a = new Path().move(points.a).curve(points.b, points.c, points.d).setRender(false) + paths.a = new Path().move(points.a).curve(points.b, points.c, points.d).hide() macro('bartackAlong', { path: paths.a, @@ -70,7 +70,7 @@ export const plugin_bartackfractionalong = { points.e = new Point(20, 10) points.f = new Point(30, 10) - paths.a = new Path().move(points.a).curve(points.b, points.c, points.d).setRender(false) + paths.a = new Path().move(points.a).curve(points.b, points.c, points.d).hide() macro('bartackFractionAlong', { path: paths.a, @@ -187,7 +187,6 @@ export const plugin_gore = { radius: 60, gores: 5, extraLength: 20, - render: true, }) return part @@ -278,7 +277,6 @@ export const plugin_round = { via: points.bottomLeft, radius: 10, prefix: 'bl', - render: true, }) macro('round', { from: points.bottomRight, @@ -286,7 +284,6 @@ export const plugin_round = { via: points.topRight, radius: 20, prefix: 'tr', - render: true, }) return part diff --git a/designs/florent/src/briminterfacing.mjs b/designs/florent/src/briminterfacing.mjs index e23d78cbfde..d5217824250 100644 --- a/designs/florent/src/briminterfacing.mjs +++ b/designs/florent/src/briminterfacing.mjs @@ -29,8 +29,8 @@ function draftFlorentBrimInterfacing({ points.insetStart = paths.inset.shiftAlong(5) points.insetEnd = paths.inset.reverse().shiftAlong(5) paths.inset = paths.inset.split(points.insetStart).pop().split(points.insetEnd).shift() - paths.inset.render = false - paths.outset.render = false + paths.inset.hide() + paths.outset.hide() paths.hint = paths.seam.clone().attr('class', 'dashed stroke-sm') paths.seam = paths.outset diff --git a/designs/florent/src/side.mjs b/designs/florent/src/side.mjs index 1f9825aeb2b..52b6d394641 100644 --- a/designs/florent/src/side.mjs +++ b/designs/florent/src/side.mjs @@ -19,7 +19,7 @@ function draftFlorentSide({ } paths.seam = paths.side.clone().line(points.foldTop).attr('class', 'fabric') - paths.seam.render = true + paths.seam.unhide() if (complete) { if (points.__miniscaleMetric) delete points.__miniscaleMetric diff --git a/designs/florent/src/top.mjs b/designs/florent/src/top.mjs index b24934d37e9..1bb240c30d1 100644 --- a/designs/florent/src/top.mjs +++ b/designs/florent/src/top.mjs @@ -135,7 +135,7 @@ function draftFlorentTop({ .attr('class', 'fabric') // Uncomment to see the side part here - paths.side.render = false + paths.side.hide() if (complete) { points.title = new Point(points.midMid.x, points.midFrontCp2.y) diff --git a/designs/holmes/src/gore.mjs b/designs/holmes/src/gore.mjs index f23cf3c64cf..cef0cb84310 100644 --- a/designs/holmes/src/gore.mjs +++ b/designs/holmes/src/gore.mjs @@ -27,7 +27,6 @@ function draftHolmesGore({ gores: options.gores, extraLength: ((options.lengthRatio - 0.5) * headCircumference) / 2, prefix: 'gore_', - render: true, }) // Complete? @@ -47,13 +46,13 @@ function draftHolmesGore({ .move(points.gore_p1) .curve(points.gore_Cp1, points.gore_Cp2, points.gore_p2) .offset(sa) - .setRender(false) + .hide() points.sa1 = new Point(points.gore_p3.x - sa * 2, points.gore_p3.y - sa) paths.saBase = new Path() .move(points.gore_p3) .line(points.p0) .offset(sa * 2) - .setRender(false) + .hide() paths.sa = new Path() .move(points.gore_p1) .line(points.gore_p1.shift(0, sa)) diff --git a/designs/huey/src/back.mjs b/designs/huey/src/back.mjs index fe4f0e87593..427cb805735 100644 --- a/designs/huey/src/back.mjs +++ b/designs/huey/src/back.mjs @@ -50,8 +50,8 @@ function draftHueyBack({ .join(paths.backCollar) .attr('class', 'note stroke-xxl') paths.hemBase = new Path().move(points.cbHem).line(points.hem).attr('class', 'note stroke-xxl') - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.seam = paths.saBase .clone() diff --git a/designs/huey/src/front.mjs b/designs/huey/src/front.mjs index fc8d8519cee..f9098409ffc 100644 --- a/designs/huey/src/front.mjs +++ b/designs/huey/src/front.mjs @@ -70,8 +70,8 @@ function draftHueyFront({ .line(points.cfHem) .attr('class', 'note stroke-xxl') paths.hemBase = new Path().move(points.cfHem).line(points.hem).attr('class', 'note stroke-xxl') - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.seam = paths.saBase.clone().join(paths.hemBase).close().attr('class', 'fabric') diff --git a/designs/huey/src/sleeve.mjs b/designs/huey/src/sleeve.mjs index 4e496c2f06a..a2caef714e3 100644 --- a/designs/huey/src/sleeve.mjs +++ b/designs/huey/src/sleeve.mjs @@ -36,8 +36,8 @@ function draftHueySleeve({ .move(points.wristLeft) .line(points.wristRight) .attr('class', 'various stroke-xxl') - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.seam = paths.saBase.join(paths.hemBase).close().attr('class', 'fabric') diff --git a/designs/hugo/src/back.mjs b/designs/hugo/src/back.mjs index 9b30b7b85bb..55cf9dd68ae 100644 --- a/designs/hugo/src/back.mjs +++ b/designs/hugo/src/back.mjs @@ -46,7 +46,7 @@ function hugoBack({ .line(points.raglanTipBack) .join(neckOpeningParts[0].reverse()) paths.seam = paths.saBase.clone().close().attr('class', 'fabric') - paths.saBase.render = false + paths.saBase.hide() // Store neck opening path store.set('neckOpeningPartBack', neckOpeningParts[1]) diff --git a/designs/hugo/src/front.mjs b/designs/hugo/src/front.mjs index f0033445328..3fcef579843 100644 --- a/designs/hugo/src/front.mjs +++ b/designs/hugo/src/front.mjs @@ -88,7 +88,7 @@ function hugoFront({ .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) .line(points.raglanTipFront) .join(neckOpeningParts[0].reverse()) - paths.saBase.render = false + paths.saBase.hide() paths.seam = paths.saBase.clone().close().attr('class', 'fabric') // FIXME: This pocket path is not getting set on the paths object // It's something to do with the paths proxy which -- I assume -- is proxying the wrong object? @@ -98,7 +98,7 @@ function hugoFront({ .curve(points.pocketTip, points.pocketTopCp, points.pocketTop) .line(points.pocketCf) .attr('class', 'fabric help') - .setRender(false) + .hide() // Store shoulder seam length, neck opening path, shoulder slope and raglan length store.set('shoulderLength', points.neck.dist(points.shoulder)) store.set('neckOpeningPartFront', neckOpeningParts[1]) @@ -117,7 +117,6 @@ function hugoFront({ // Complete pattern? if (complete) { - //paths.pocket.setRender(true) macro('cutonfold', { from: points.cfNeck, to: points.cfRibbing, diff --git a/designs/hugo/src/pocket.mjs b/designs/hugo/src/pocket.mjs index 299374ce790..8ef02ff8dc5 100644 --- a/designs/hugo/src/pocket.mjs +++ b/designs/hugo/src/pocket.mjs @@ -24,7 +24,7 @@ function hugoPocket({ .line(points.pocketHem) .close() .attr('class', 'fabric', true) - paths.seam.render = true + paths.seam.unhide() paths.saBase = new Path() .move(points.cfRibbing) @@ -32,7 +32,7 @@ function hugoPocket({ .line(points.pocketTip) ._curve(points.pocketTopCp, points.pocketTop) .line(points.pocketCf) - .setRender(false) + .hide() store.set('facingWidth', points.pocketHem.dist(points.pocketTip) / 2) @@ -53,11 +53,11 @@ function hugoPocket({ .line(facing.start()) .join(facing) .attr('class', ' fabric help') - paths.facing.render = false + paths.facing.hide() // Complete pattern? if (complete) { - paths.facing.render = true + paths.facing.unhide() macro('cutonfold', { from: points.pocketCf, to: points.cfRibbing, diff --git a/designs/jaeger/src/back.mjs b/designs/jaeger/src/back.mjs index 62a16e18b83..b4033a232f9 100644 --- a/designs/jaeger/src/back.mjs +++ b/designs/jaeger/src/back.mjs @@ -37,7 +37,7 @@ function jaegerBack({ .pop() .line(points.cbHem) paths.vent = paths.ventBase.offset(measurements.neck / 10) - paths.vent.render = false + paths.vent.hide() points.ventSlopeStart = utils.lineIntersectsCurve( paths.vent.start(), paths.vent.start().shift(10, measurements.neck / 5), @@ -63,7 +63,7 @@ function jaegerBack({ .pop() .line(points.hem) paths.vent = paths.ventBase.offset(measurements.neck / -10) - paths.vent.render = false + paths.vent.hide() points.ventSlopeStart = utils.lineIntersectsCurve( paths.vent.start(), paths.vent.start().shift(170, measurements.neck / 5), @@ -94,7 +94,7 @@ function jaegerBack({ .split(points.ventSlopeStart) .pop() ) - paths.saBase.render = true + paths.saBase.unhide() } else { paths.saBase = new Path() .move(points.hem) @@ -126,13 +126,13 @@ function jaegerBack({ } else { paths.saBase.curve(points.cbWaistCp2, points.cbHipsCp1, points.cbHips).line(points.cbHem) } - paths.saBase.render = false + paths.saBase.hide() if (options.backVent === 2) paths.hemBase = new Path().move(points.cbHem).line(paths.vent.end()) else if (options.backVent === 1) paths.hemBase = new Path().move(paths.vent.end()).line(points.hem) else paths.hemBase = new Path().move(points.cbHem).line(points.hem) - paths.hemBase.render = false + paths.hemBase.hide() paths.seam = paths.saBase.join(paths.hemBase).attr('class', 'fabric') diff --git a/designs/jaeger/src/front.mjs b/designs/jaeger/src/front.mjs index dfa367d04ec..e03477429ec 100644 --- a/designs/jaeger/src/front.mjs +++ b/designs/jaeger/src/front.mjs @@ -334,10 +334,10 @@ function jaegerFront({ .line(points.cutawayPoint) .curve(points.cutawayPointCp2, points.roundStartCp1, points.roundStart) .curve(points.roundCp1, points.roundCp2, points.roundEnd) - paths.saBase.render = false + paths.saBase.hide() paths.hemBase = new Path().move(points.roundEnd).line(points.hem) - paths.hemBase.render = false + paths.hemBase.hide() paths.seam = paths.saBase.clone().join(paths.hemBase).attr('class', 'fabric') diff --git a/designs/jaeger/src/side.mjs b/designs/jaeger/src/side.mjs index f51df751c6f..53e5792f080 100644 --- a/designs/jaeger/src/side.mjs +++ b/designs/jaeger/src/side.mjs @@ -35,7 +35,6 @@ function jaegerSide({ .pop() .line(points.bsHem) paths.vent = paths.ventBase.offset(measurements.neck / -10) - //paths.vent.render = false; points.ventSlopeStart = utils.lineIntersectsCurve( paths.vent.start(), paths.vent.start().shift(170, measurements.neck / 5), diff --git a/designs/jaeger/src/undercollar.mjs b/designs/jaeger/src/undercollar.mjs index 19be11e0fb6..bc2ae1a2131 100644 --- a/designs/jaeger/src/undercollar.mjs +++ b/designs/jaeger/src/undercollar.mjs @@ -58,8 +58,8 @@ function jaegerUnderCollar({ .line(paths.sa1.end()) .line(points.collarCbTop) .attr('class', 'various sa') - paths.sa1.render = false - paths.sa2.render = false + paths.sa1.hide() + paths.sa2.hide() } if (paperless) { diff --git a/designs/noble/src/backinside.mjs b/designs/noble/src/backinside.mjs index 882580e2408..c00c09ec9b9 100644 --- a/designs/noble/src/backinside.mjs +++ b/designs/noble/src/backinside.mjs @@ -14,10 +14,10 @@ function nobleBackInside({ part, }) { if (options.dartPosition != 'shoulder') { - paths.insideSeam = paths.seam.clone().setRender(true) + paths.insideSeam = paths.seam.clone().unhide() } else { // Hide Bella paths - for (let key of Object.keys(paths)) paths[key].render = false + for (let key of Object.keys(paths)) paths[key].hide() for (let i in snippets) delete snippets[i] paths.insideSeam = new Path() diff --git a/designs/noble/src/backpoints.mjs b/designs/noble/src/backpoints.mjs index 44b7988cb45..807f8de6906 100644 --- a/designs/noble/src/backpoints.mjs +++ b/designs/noble/src/backpoints.mjs @@ -3,7 +3,7 @@ import * as options from './options.mjs' function nobleBackPoints({ points, Path, paths, options, snippets, log, part }) { // Hide Bella paths - for (let key of Object.keys(paths)) paths[key].render = false + for (let key of Object.keys(paths)) paths[key].hide() for (let i in snippets) delete snippets[i] delete points.__titleNr diff --git a/designs/noble/src/frontpoints.mjs b/designs/noble/src/frontpoints.mjs index d27b75f8305..0ae67705b99 100644 --- a/designs/noble/src/frontpoints.mjs +++ b/designs/noble/src/frontpoints.mjs @@ -5,7 +5,7 @@ function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, const bCircle = 0.552284749831 // Hide Bella paths - for (let key of Object.keys(paths)) paths[key].render = false + for (let key of Object.keys(paths)) paths[key].hide() for (let i in snippets) delete snippets[i] // Remove macros from Bella @@ -30,11 +30,10 @@ function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, points.armholeDartInside = armholePath.shiftFractionAlong(options.armholeDartPosition) points.armholeDartOutside = points.armholeDartInside.clone() - // paths.armholeTemp = armholePath.clone().setRender(true).attr('class', 'lining') let armholePaths = armholePath.split(points.armholeDartInside) - let armholePathInside = armholePaths[0].clone().setRender(false) - let armholePathOutside = armholePaths[1].clone().setRender(false) + let armholePathInside = armholePaths[0].clone().hide() + let armholePathOutside = armholePaths[1].clone().hide() let armholeDartAngle = armholePathInside.reverse().shiftAlong(1).angle(armholePathOutside.shiftAlong(1)) - 90 @@ -78,13 +77,13 @@ function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, paths.armholeInside = new Path() .move(points.armholeDartInside) .curve(points.armholeInsidePitchCp2, points.shoulderCp1, points.shoulder) - .setRender(false) + .hide() } else { paths.armholeInside = new Path() .move(points.armholeDartInside) .curve(points.armholeDartInsideCp2, points.armholeInsidePitchCp1, points.armholeInsidePitch) .curve(points.armholeInsidePitchCp2, points.shoulderCp1, points.shoulder) - .setRender(false) + .hide() } let rotateAngle = @@ -145,7 +144,7 @@ function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, paths.armholeOutside = new Path() .move(points.armholeDartOutside) .curve(points.armholeDartOutsideCp1, points.armholeOutsidePitchCp2, points.armhole) - .setRender(false) + .hide() } else { paths.armholeOutside = new Path() .move(points.armholeDartOutside) @@ -155,14 +154,14 @@ function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, points.armholeOutsidePitch ) .curve(points.armholeOutsidePitchCp1, points.armholeCp2, points.armhole) - .setRender(false) + .hide() } paths.armholeTempDart = new Path() .move(points.armholeDartOutside) ._curve(points.armholeDartCpBottom, points.armholeDartTip) .curve_(points.armholeDartCpTop, points.armholeDartInside) - .setRender(false) + .hide() points.shoulderDartTipCpDownOutside = points.shoulderDartOutside.shiftFractionTowards( points.bust, @@ -186,17 +185,17 @@ function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, .move(points.waistDartLeft) .curve(points.waistDartLeftCp, points.shoulderDartTipCpDownInside, points.shoulderDartTip) .line(points.shoulderDartInside) - .setRender(false) + .hide() paths.armholeInsideSeam = new Path() .move(points.waistDartLeft) .curve(points.waistDartLeftCp, points.armholeDartTipCpDownInside, points.armholeDartTip) - .setRender(false) + .hide() paths.sOutsideSeam = new Path() .move(points.waistDartRight) .curve(points.bustAcp, points.shoulderDartTipCpDownOutside, points.shoulderDartOutside) - .setRender(false) + .hide() points.waistDartRightCp = points.bustAcp.clone() @@ -204,7 +203,7 @@ function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, .move(points.waistDartLeft) .curve(points.waistDartLeftCp, points.shoulderDartTipCpDownInside, points.shoulderDartTip) .line(points.shoulderDartInside) - .setRender(false) + .hide() points.waistUpDartLeft = paths.armholeInsideSeam.shiftAlong( points.waistDartLeft.dist(points.armholeDartTip) * 0.5 @@ -293,7 +292,7 @@ function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, .move(points.armholeDartOutside) .curve(points.armholeCircleOutsideCp1, points.waistCircleOutsideCp1, points.waistUpDartRight) .curve(points.waistUpDartRightCpDown, points.waistCpUp, points.waistDartRight) - .setRender(false) + .hide() .attr('class', 'lining') paths.armholeTempCircleInside = new Path() .move(points.armholeDartInside) @@ -303,7 +302,7 @@ function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, points.armholeDartTipInside ) .curve(points.armholeDartTipCpDownInside, points.waistDartLeftCp, points.waistDartLeft) - .setRender(false) + .hide() .attr('class', 'lining') diff = paths.armholeTempCircleOutside.length() - paths.armholeTempCircleInside.length() diff --git a/designs/paco/src/backpocketbag.mjs b/designs/paco/src/backpocketbag.mjs index 6d6041854f3..3f8d45b429a 100644 --- a/designs/paco/src/backpocketbag.mjs +++ b/designs/paco/src/backpocketbag.mjs @@ -13,10 +13,7 @@ function pacoBackPocketBag({ part, }) { // Don't bother of we're not drafting back pockets - if (!options.backPockets) { - part.render = false - return part - } + if (!options.backPockets) return part.hide() // Clean up for (const path in paths) delete paths[path] diff --git a/designs/paco/src/backpocketwelt.mjs b/designs/paco/src/backpocketwelt.mjs index cf2c94e210f..abeb3eec0e5 100644 --- a/designs/paco/src/backpocketwelt.mjs +++ b/designs/paco/src/backpocketwelt.mjs @@ -14,10 +14,7 @@ function pacoBackPocketWelt({ part, }) { // Don't bother of we're not drafting back pockets - if (!options.backPockets) { - part.render = false - return part - } + if (!options.backPockets) return part.hide() // Clean up for (const path in paths) delete paths[path] diff --git a/designs/paco/src/backpocketweltinterfacing.mjs b/designs/paco/src/backpocketweltinterfacing.mjs index 74540a70f97..1aa1796d9d3 100644 --- a/designs/paco/src/backpocketweltinterfacing.mjs +++ b/designs/paco/src/backpocketweltinterfacing.mjs @@ -12,10 +12,7 @@ function pacoBackPocketWeltInterfacing({ part, }) { // Don't bother of we're not drafting back pockets - if (!options.backPockets) { - part.render = false - return part - } + if (!options.backPockets) return part.hide() // Clean up for (const path in paths) delete paths[path] diff --git a/designs/paco/src/cuff.mjs b/designs/paco/src/cuff.mjs index fa404025eaf..f26c22cb761 100644 --- a/designs/paco/src/cuff.mjs +++ b/designs/paco/src/cuff.mjs @@ -13,10 +13,7 @@ function pacoCuff({ macro, part, }) { - if (!options.elasticatedHem) { - part.render = false - return part - } + if (!options.elasticatedHem) return part.hide() let len = store.get('frontAnkle') + store.get('backAnkle') points.topLeft = new Point(0, 0) diff --git a/designs/paco/src/frontpocketbag.mjs b/designs/paco/src/frontpocketbag.mjs index bb3d0415c5d..d9b88930766 100644 --- a/designs/paco/src/frontpocketbag.mjs +++ b/designs/paco/src/frontpocketbag.mjs @@ -13,10 +13,7 @@ function pacoFrontPocketBag({ part, }) { // Don't bother of we're not drafting front pockets - if (!options.frontPockets) { - part.render = false - return part - } + if (!options.frontPockets) return part.hide() // Clean up for (const path in paths) delete paths[path] diff --git a/designs/penelope/src/waistband.mjs b/designs/penelope/src/waistband.mjs index d802ecbced4..c0649118df2 100644 --- a/designs/penelope/src/waistband.mjs +++ b/designs/penelope/src/waistband.mjs @@ -17,10 +17,7 @@ function penelopeWaistband({ store, part, }) { - if (!options.waistBand) { - part.render = false - return part - } + if (!options.waistBand) return part.hide() let waist = measurements.waist waist += measurements.waist * options.waistEase diff --git a/designs/plugintest/src/plugin-gore.mjs b/designs/plugintest/src/plugin-gore.mjs index 2205169f545..242cb60f9d4 100644 --- a/designs/plugintest/src/plugin-gore.mjs +++ b/designs/plugintest/src/plugin-gore.mjs @@ -9,7 +9,6 @@ const pluginGore = ({ points, Point, options, macro, part }) => { radius: options.goreRadius, gores: options.goreGoreNumber, extraLength: options.goreExtraLength, - render: true, }) } return part diff --git a/designs/plugintest/src/plugin-round.mjs b/designs/plugintest/src/plugin-round.mjs index f14b483aaed..82e33b18e9e 100644 --- a/designs/plugintest/src/plugin-round.mjs +++ b/designs/plugintest/src/plugin-round.mjs @@ -18,7 +18,7 @@ const pluginRound = ({ Point, points, Path, paths, macro, options, part }) => { const opts = { radius: options.roundRadius, - render: options.roundRender, + hide: options.roundHide, } macro('round', { @@ -45,7 +45,7 @@ export const round = { after: base, options: { roundRadius: { count: 10, min: 0, max: 50, menu: 'round' }, - roundRender: { bool: true, menu: 'round' }, + roundHide: { bool: false, menu: 'round' }, }, plugins: roundPlugin, draft: pluginRound, diff --git a/designs/sandy/src/skirt.mjs b/designs/sandy/src/skirt.mjs index 74a97c18a12..bfe4850142e 100644 --- a/designs/sandy/src/skirt.mjs +++ b/designs/sandy/src/skirt.mjs @@ -141,8 +141,8 @@ function sandySkirt({ if (!options.seamlessFullCircle) paths.saBase = paths.saBase.line(points.ex1Rotated) paths.saBase = paths.saBase.offset(sa * -1) - paths.hemBase.render = false - paths.saBase.render = false + paths.hemBase.hide() + paths.saBase.hide() if (options.seamlessFullCircle) { paths.sa = new Path() diff --git a/designs/shin/src/back.mjs b/designs/shin/src/back.mjs index 79148f0cd69..fb05ae93ed9 100644 --- a/designs/shin/src/back.mjs +++ b/designs/shin/src/back.mjs @@ -98,8 +98,8 @@ function shinBack({ .join(paths.saBase) paths.hemBase = new Path().move(points.legSide).curve_(points.legSideCp, points.reducedLegInner) - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.seam = paths.saBase.join(paths.hemBase).attr('class', 'fabric') diff --git a/designs/shin/src/front.mjs b/designs/shin/src/front.mjs index 8fdfb83b699..a822b0e3875 100644 --- a/designs/shin/src/front.mjs +++ b/designs/shin/src/front.mjs @@ -99,8 +99,8 @@ function shinFront({ .join(paths.saBase) paths.hemBase = new Path().move(points.legSide).curve_(points.legSideCp, points.reducedLegInner) - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.seam = paths.saBase.join(paths.hemBase).attr('class', 'fabric') diff --git a/designs/simon/src/back.mjs b/designs/simon/src/back.mjs index dd08b65862c..01adb22db3d 100644 --- a/designs/simon/src/back.mjs +++ b/designs/simon/src/back.mjs @@ -131,11 +131,11 @@ function simonBack({ } const [back, yoke] = paths.backArmhole.split(points.armholeYokeSplit) - paths.backArmholeYoke = yoke.setRender(false) + paths.backArmholeYoke = yoke.hide() // For 1/10 dolls with breasts, this path becomes non-existing so we put a dummy here paths.backArmholeBack = back.attributes - ? back.setRender(false) - : new Path().move(points.armholeYokeSplit).line(points.armholeYokeSplit).setRender(false) + ? back.hide() + : new Path().move(points.armholeYokeSplit).line(points.armholeYokeSplit).hide() // We'll re-use this const armholeToPitch = new Path() @@ -151,7 +151,7 @@ function simonBack({ paths.armhole = armholeToPitch if (options.yokeHeight === 0) paths.armhole = paths.armhole.join(paths.backArmhole) else paths.armhole = paths.armhole.join(paths.backArmholeBack) - paths.armhole.render = false + paths.armhole.hide() if (options.roundBack > 0) { points.cbTop = points.cbYoke.shift(90, points.armholePitch.x * options.roundBack) @@ -170,7 +170,7 @@ function simonBack({ points.boxPleatLeftBottom = new Point(points.boxPleatLeft.x, points.armholeHollowCp2.y) points.boxPleatMidBottom = new Point(points.boxPleatMid.x, points.armholeHollowCp2.y) points.boxPleatRightBottom = new Point(points.boxPleatRight.x, points.armholeHollowCp2.y) - paths.armhole.setRender(false) + paths.armhole.hide() paths.armhole = paths.armhole.translate(store.get('boxPleatFold') * 2, 0) for (const p of [ 'armholePitch', @@ -235,8 +235,8 @@ function simonBack({ else paths.saBase = paths.saBase.line(points.cbYoke) // Paths - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.seam = paths.hemBase.join(paths.saBase).close().attr('class', 'fabric') // Complete pattern? diff --git a/designs/simon/src/front.mjs b/designs/simon/src/front.mjs index 036083c362b..81d00227a6a 100644 --- a/designs/simon/src/front.mjs +++ b/designs/simon/src/front.mjs @@ -110,10 +110,10 @@ function simonFront({ } // Paths - paths.saBase.render = false - paths.saBaseFromHips.render = false - paths.saBaseFromArmhole.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.saBaseFromHips.hide() + paths.saBaseFromArmhole.hide() + paths.hemBase.hide() paths.seam = paths.hemBase .join(paths.saBase) .join(paths.saBaseFromArmhole) diff --git a/designs/simon/src/sleeve.mjs b/designs/simon/src/sleeve.mjs index 3f2c430a4b2..1c0fbd67fea 100644 --- a/designs/simon/src/sleeve.mjs +++ b/designs/simon/src/sleeve.mjs @@ -43,7 +43,7 @@ function simonSleeve({ .curve(points.capQ2Cp2, points.capQ3Cp1, points.capQ3) .curve(points.capQ3Cp2, points.capQ4Cp1, points.capQ4) .curve_(points.capQ4Cp2, points.bicepsLeft) - .setRender(false) + .hide() points.top = new Point(0, paths.sleevecap.edge('top').y) points.bottom = points.top.shift(-90, len) @@ -114,10 +114,10 @@ function simonSleeve({ .curve(points.capQ2Cp2, points.capQ3Cp1, points.capQ3) .curve(points.capQ3Cp2, points.capQ4Cp1, points.capQ4) .curve_(points.capQ4Cp2, points.bicepsLeft) - paths.frenchBase.render = false + paths.frenchBase.hide() paths.saBase = new Path().move(points.bicepsLeft).line(points.wristLeft) - paths.saBase.render = false + paths.saBase.hide() paths.cuffBase = new Path() .move(points.wristLeft) @@ -128,7 +128,7 @@ function simonSleeve({ paths.cuffBase._curve(points.cuffRightCuspCp1, points.cuffRightCusp) if (pleats === 2) paths.cuffBase.line(points.cuffPleat2Edge) paths.cuffBase.curve_(points.cuffRightCuspCp2, points.wristRight) - paths.cuffBase.render = false + paths.cuffBase.hide() paths.seam = paths.frenchBase .clone() diff --git a/designs/simon/src/yoke.mjs b/designs/simon/src/yoke.mjs index e153b731763..ba3936e0c02 100644 --- a/designs/simon/src/yoke.mjs +++ b/designs/simon/src/yoke.mjs @@ -31,10 +31,10 @@ function simonYoke({ clone: true, }) paths.saBase = paths.saBase.join(paths.mirroredSaBase.reverse()) - paths.mirroredSaBase.setRender(false) + paths.mirroredSaBase.hide() } paths.seam = paths.saBase.clone() - paths.saBase.render = false + paths.saBase.hide() paths.seam = paths.seam.close().attr('class', 'fabric') // Complete pattern? diff --git a/designs/simone/src/fba-front.mjs b/designs/simone/src/fba-front.mjs index b836d478ea1..cfb59c5480c 100644 --- a/designs/simone/src/fba-front.mjs +++ b/designs/simone/src/fba-front.mjs @@ -166,8 +166,8 @@ function simoneFbaFront({ .split(points.bustSideCut1_rot1) paths.fbaAboveDart = toSplit.pop() paths.fbaBelowDart = toSplit.pop() - paths.fbaAboveDart.render = false - paths.fbaBelowDart.render = false + paths.fbaAboveDart.hide() + paths.fbaBelowDart.hide() points.belowDartCpTop_rot1 = paths.fbaBelowDart.ops[1].cp2 points.belowDartCpBottom_rot1 = paths.fbaBelowDart.ops[1].cp1 points.aboveDartCpBottom_rot1 = paths.fbaAboveDart.ops[1].cp1 // (only one CP on this part @@ -392,9 +392,9 @@ function simoneFbaFront({ .join(paths.saBaseFromArmhole) .attr('class', 'fabric') - paths.saBaseFromHips.render = false - paths.saBaseFromArmhole.render = false - paths.saBase.render = false + paths.saBaseFromHips.hide() + paths.saBaseFromArmhole.hide() + paths.saBase.hide() if (complete && sa) { paths.saFrench = paths.saBase.offset(sa * options.ffsa).attr('class', 'fabric sa') diff --git a/designs/sven/src/frontback.mjs b/designs/sven/src/frontback.mjs index 8398c6ee14e..fd99903f1d7 100644 --- a/designs/sven/src/frontback.mjs +++ b/designs/sven/src/frontback.mjs @@ -45,8 +45,8 @@ function svenFrontBack({ if (front) paths.hemBase = new Path().move(points.cfHem).line(points.hem) else paths.hemBase = new Path().move(points.cbHem).line(points.hem) - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.seam = paths.hemBase.join(paths.saBase) if (front) paths.seam.line(points.cfHem) diff --git a/designs/sven/src/sleeve.mjs b/designs/sven/src/sleeve.mjs index ef757ee26f3..e952242af5d 100644 --- a/designs/sven/src/sleeve.mjs +++ b/designs/sven/src/sleeve.mjs @@ -31,8 +31,8 @@ function svenSleeve({ store, sa, points, paths, Path, complete, paperless, macro .join(paths.sleevecap) .line(points.wristLeft) paths.hemBase = new Path().move(points.wristLeft).line(points.wristRight) - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() paths.sa = paths.saBase.offset(sa).join(paths.hemBase.offset(sa * (options.ribbing ? 1 : 3))) paths.sa.line(paths.sa.start()).close().attr('class', 'fabric sa') } diff --git a/designs/teagan/src/front.mjs b/designs/teagan/src/front.mjs index a3950b5f8fe..99652904f5a 100644 --- a/designs/teagan/src/front.mjs +++ b/designs/teagan/src/front.mjs @@ -20,7 +20,7 @@ function teaganFront({ part, }) { // Hide Brian paths - for (let key of Object.keys(paths)) paths[key].render = false + for (let key of Object.keys(paths)) paths[key].hide() // Adapt fit to waist let width @@ -61,7 +61,7 @@ function teaganFront({ log.info(['fullLengthFromHps', units(points.hps.dy(points.hem))]) // Draw seamline - paths.hemBase = new Path().move(points.cfHem).line(points.hem).setRender(false) + paths.hemBase = new Path().move(points.cfHem).line(points.hem).hide() paths.saBase = new Path() .move(points.hem) .curve_(points.waistCp2, points.armhole) @@ -69,7 +69,7 @@ function teaganFront({ .curve(points.armholeHollowCp2, points.shoulderCp1, points.shoulder) .line(points.neck) .curve(points.neckCp2, points.cfNeckCp1, points.cfNeck) - .setRender(false) + .hide() paths.seam = new Path() .move(points.cfHem) .join(paths.hemBase) diff --git a/designs/titan/src/back.mjs b/designs/titan/src/back.mjs index b90ea042669..dadbf1bbace 100644 --- a/designs/titan/src/back.mjs +++ b/designs/titan/src/back.mjs @@ -403,8 +403,8 @@ function titanBack({ .join(paths.saBase.offset(sa)) .close() .attr('class', 'fabric sa') - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() } if (paperless && options.titanPaperless) { diff --git a/designs/titan/src/front.mjs b/designs/titan/src/front.mjs index 752f5b8e048..1a7a8e6d0f1 100644 --- a/designs/titan/src/front.mjs +++ b/designs/titan/src/front.mjs @@ -477,8 +477,8 @@ function titanFront({ .join(paths.saBase.offset(sa)) .close() .attr('class', 'fabric sa') - paths.saBase.render = false - paths.hemBase.render = false + paths.saBase.hide() + paths.hemBase.hide() } if (paperless && options.titanPaperless) { diff --git a/designs/tutorial/src/step5-8.mjs b/designs/tutorial/src/step5-8.mjs index 18926631d00..f0c36771a97 100644 --- a/designs/tutorial/src/step5-8.mjs +++ b/designs/tutorial/src/step5-8.mjs @@ -65,14 +65,12 @@ export const step7 = { to: points.tipRight, via: points.tipRightTop, prefix: 'tipRightTop', - render: true, }) macro('round', { from: points.tipRight, to: points.top, via: points.tipRightBottom, prefix: 'tipRightBottom', - render: true, }) return part @@ -111,14 +109,12 @@ export const step8 = { to: points.tipRight, via: points.tipRightTop, prefix: 'tipRightTop', - render: true, }) macro('round', { from: points.tipRight, to: points.top, via: points.tipRightBottom, prefix: 'tipRightBottom', - render: true, }) paths.rect = new Path() diff --git a/designs/tutorial/src/step9-11.mjs b/designs/tutorial/src/step9-11.mjs index e5cc05629b4..d3d504a65e9 100644 --- a/designs/tutorial/src/step9-11.mjs +++ b/designs/tutorial/src/step9-11.mjs @@ -50,7 +50,6 @@ export const step10 = { to: points.bottomRight, via: points.bottomLeft, radius: points.bottomRight.x / 4, - render: true, prefix: 'bottomLeft', }) macro('round', { @@ -58,7 +57,6 @@ export const step10 = { to: points.topRight, via: points.bottomRight, radius: points.bottomRight.x / 4, - render: true, prefix: 'bottomRight', }) diff --git a/designs/wahid/src/back.mjs b/designs/wahid/src/back.mjs index 2483f8c394d..35c2a6a1901 100644 --- a/designs/wahid/src/back.mjs +++ b/designs/wahid/src/back.mjs @@ -102,10 +102,10 @@ function wahidBack({ .join(paths.dart) .line(points.hem) .attr('class', 'fabric') - paths.saBase.render = false - paths.hemBase.render = false - paths.hemBase.render = false - paths.dart.render = false + paths.saBase.hide() + paths.hemBase.hide() + paths.hemBase.hide() + paths.dart.hide() if (complete) { //Grainline diff --git a/designs/wahid/src/front.mjs b/designs/wahid/src/front.mjs index 5d8b0fdf138..311c171d91b 100644 --- a/designs/wahid/src/front.mjs +++ b/designs/wahid/src/front.mjs @@ -252,9 +252,9 @@ function wahidFront({ } paths.dart = dartPath(part) paths.seam = paths.saBase.join(paths.dart).join(paths.hemBase).close().attr('class', 'fabric') - paths.saBase.render = false - paths.hemBase.render = false - paths.dart.render = false + paths.saBase.hide() + paths.hemBase.hide() + paths.dart.hide() if (complete) { // Pocket path paths.pocket = new Path() diff --git a/designs/wahid/src/pocketbag.mjs b/designs/wahid/src/pocketbag.mjs index cd17afeee0a..8adc10dc1e4 100644 --- a/designs/wahid/src/pocketbag.mjs +++ b/designs/wahid/src/pocketbag.mjs @@ -24,7 +24,7 @@ function wahidPocketbag({ to: points.bottomRight, via: points.bottomLeft, radius: pw / 8, - render: false, + hidden: true, prefix: 'roundLeft', }) macro('round', { @@ -32,7 +32,7 @@ function wahidPocketbag({ to: points.topRight, via: points.bottomRight, radius: pw / 8, - render: false, + hidden: true, prefix: 'roundRight', }) paths.seam = new Path() diff --git a/designs/wahid/src/pocketfacing.mjs b/designs/wahid/src/pocketfacing.mjs index 4d4eda64245..dda549a7c8f 100644 --- a/designs/wahid/src/pocketfacing.mjs +++ b/designs/wahid/src/pocketfacing.mjs @@ -27,7 +27,7 @@ function wahidPocketFacing({ to: points.bottomRight, via: points.bottomLeft, radius: pw / 8, - render: false, + hidden: true, prefix: 'roundLeft', }) macro('round', { @@ -35,7 +35,7 @@ function wahidPocketFacing({ to: points.topRight, via: points.bottomRight, radius: pw / 8, - render: false, + hidden: true, prefix: 'roundRight', }) paths.seam = new Path() diff --git a/designs/waralee/src/cutout.mjs b/designs/waralee/src/cutout.mjs index afe2906a1a6..9de37f8970f 100644 --- a/designs/waralee/src/cutout.mjs +++ b/designs/waralee/src/cutout.mjs @@ -29,7 +29,7 @@ function waraleeCutout({ .close() .attr('class', 'fabric') - paths.cutout.setRender(false) + paths.cutout.hide() // Complete? if (complete) { @@ -79,9 +79,8 @@ function waraleeCutout({ x: points.mWaist.x + 15, }) } - part.render = options.showMini - return part + return part.setHidden(!options.showMini) } export const cutout = { diff --git a/designs/waralee/src/mini.mjs b/designs/waralee/src/mini.mjs index bb959c1671a..2bc61f90f4b 100644 --- a/designs/waralee/src/mini.mjs +++ b/designs/waralee/src/mini.mjs @@ -38,17 +38,17 @@ function waraleeMini({ options, Path, points, paths, complete, sa, macro, store, .line(separateWaistband ? points.fWaistSideSeam : points.fWaistSide) .attr('class', 'help') - paths.seam.setRender(true) + paths.seam.unhide() // Complete? if (complete) { macro('scalebox', { at: points.mLeg.shift(-90, 35) }) if (options.frontPocket && 'welt' == options.frontPocketStyle) { - paths.frontPocket.setRender(true) + paths.frontPocket.unhide() } if (options.backPocket) { - paths.backPocket.setRender(true) + paths.backPocket.unhide() } if (sa) { @@ -151,9 +151,7 @@ function waraleeMini({ options, Path, points, paths, complete, sa, macro, store, } } - part.render = options.showMini - - return part + return part.setHidden(!options.showMini) } export const mini = { diff --git a/designs/waralee/src/pants.mjs b/designs/waralee/src/pants.mjs index 4880f855322..b8ae64d9b7b 100644 --- a/designs/waralee/src/pants.mjs +++ b/designs/waralee/src/pants.mjs @@ -35,7 +35,7 @@ function waraleePants({ paths.legFold = paths.leg.offset(-1 * store.get('hem')).attr('class', 'fabric stroke-sm') paths.backFold = paths.back.offset(-1 * store.get('hem')).attr('class', 'fabric stroke-sm') - paths.seam.setRender(true) + paths.seam.unhide() // Complete? if (complete) { @@ -56,10 +56,10 @@ function waraleePants({ } if (options.frontPocket && 'welt' == options.frontPocketStyle) { - paths.frontPocket.setRender(true) + paths.frontPocket.unhide() } if (options.backPocket) { - paths.backPocket.setRender(true) + paths.backPocket.unhide() } // Paperless? @@ -161,9 +161,7 @@ function waraleePants({ } } - part.render = options.showMini == false - - return part + return part.setHidden(options.showMini != false) } export const pants = { diff --git a/designs/waralee/src/pantsproto.mjs b/designs/waralee/src/pantsproto.mjs index 3389ceed47d..7e59d53fde1 100644 --- a/designs/waralee/src/pantsproto.mjs +++ b/designs/waralee/src/pantsproto.mjs @@ -122,10 +122,10 @@ function waraleePantsProto({ options, measurements, Point, Path, points, paths, .curve(points.bWaistCrotchCP, points.bHipCrotchCP, points.mHip) .split(points.bCutOutHip) - fPaths[0].setRender(false) - fPaths[1].setRender(false) - bPaths[0].setRender(false) - bPaths[1].setRender(false) + fPaths[0].hide() + fPaths[1].hide() + bPaths[0].hide() + bPaths[1].hide() points.fCutOutHipCp1 = fPaths[1].ops[1].cp1.shiftFractionTowards(points.fCutOutHip, 1.25) points.fCutOutHipCp2 = fPaths[1].ops[1].cp1.clone() @@ -137,20 +137,20 @@ function waraleePantsProto({ options, measurements, Point, Path, points, paths, paths.frontBottomCutOut = new Path() .move(points.mHip) .curve(points.mHipCp1, points.fCutOutHipCp2, points.fCutOutHip) - .setRender(false) + .hide() paths.backBottomCutOut = new Path() .move(points.bCutOutHip) .curve(points.bCutOutHipCp1, points.mHipCp2, points.mHip) - .setRender(false) + .hide() paths.frontTopCutOut = new Path() .move(points.fCutOutHip) .curve(points.fCutOutHipCp1, points.fWaistAdjusted, points.fWaistAdjusted) - .setRender(false) + .hide() paths.backTopCutOut = new Path() .move(points.bWaistAdjusted) .curve(points.bWaistAdjusted, points.bCutOutHipCp2, points.bCutOutHip) - .setRender(false) + .hide() points.fWaistSideHem = paths.frontTopCutOut.reverse().shiftAlong(waistBand) points.fWaistSideSeam = paths.frontTopCutOut.reverse().shiftAlong(waistBand * 2) @@ -187,7 +187,7 @@ function waraleePantsProto({ options, measurements, Point, Path, points, paths, paths.frontTopCutOut = new Path() .move(points.fCutOutHip) .curve(points.fCutOutHipCp1, points.fWaistSideCp2, points.fWaistSideSeam) - .setRender(false) + .hide() if (false == separateWaistband) { paths.frontTopCutOut.line(points.fWaistSideHem) paths.frontTopCutOut.line(points.fWaistSide) @@ -200,37 +200,35 @@ function waraleePantsProto({ options, measurements, Point, Path, points, paths, } else { paths.backTopCutOut = new Path().move(points.bWaistSideSeam) } - paths.backTopCutOut - .curve(points.bWaistSideCp1, points.bCutOutHipCp2, points.bCutOutHip) - .setRender(false) + paths.backTopCutOut.curve(points.bWaistSideCp1, points.bCutOutHipCp2, points.bCutOutHip).hide() paths.cutout = paths.backTopCutOut .join(paths.backBottomCutOut) .join(paths.frontBottomCutOut) .join(paths.frontTopCutOut) - .setRender(false) + .hide() paths.waistBack = new Path() .move(separateWaistband ? points.bWaistBackOverlapSeam : points.bWaistBackOverlap) .line(separateWaistband ? points.bWaistBackSeam : points.bWaistBack) // .line(points.bWaistSideTemp) // This is a trick to make the offset() call work. Without it, the offset is crossing the cutout line. .line(separateWaistband ? points.bWaistSideSeam : points.bWaistSide) - .setRender(false) + .hide() paths.waistFront = new Path() .move(separateWaistband ? points.fWaistSideSeam : points.fWaistSide) .line(separateWaistband ? points.fWaistFrontOverlapSeam : points.fWaistFrontOverlap) - .setRender(false) + .hide() paths.front = new Path() .move(separateWaistband ? points.fWaistFrontOverlapSeam : points.fWaistFrontOverlap) .line(points.fHipFrontOverlap) .line(points.fLegFrontOverlap) - .setRender(false) + .hide() paths.back = new Path() .move(points.bLegBackOverlap) .line(points.bHipBackOverlap) .line(separateWaistband ? points.bWaistBackOverlapSeam : points.bWaistBackOverlap) - .setRender(false) - paths.leg = new Path().move(points.fLegFrontOverlap).line(points.bLegBackOverlap).setRender(false) + .hide() + paths.leg = new Path().move(points.fLegFrontOverlap).line(points.bLegBackOverlap).hide() paths.seam = paths.waistFront .join(paths.front) @@ -240,7 +238,7 @@ function waraleePantsProto({ options, measurements, Point, Path, points, paths, .join(paths.cutout) .close() .attr('class', 'fabric') - .setRender(false) + .hide() if (options.frontPocket) { points.frontPocketTop = points.fWaistSideSeam @@ -266,7 +264,7 @@ function waraleePantsProto({ options, measurements, Point, Path, points, paths, .line(points.frontPocketTop2) .close() .attr('class', 'fabric') - .setRender(false) + .hide() } if (options.backPocket) { @@ -304,12 +302,10 @@ function waraleePantsProto({ options, measurements, Point, Path, points, paths, .line(points.backPocketRight) .close() .attr('class', 'fabric') - .setRender(false) + .hide() } - part.render = false - - return part + return part.hide() } export const pantsProto = { diff --git a/designs/yuri/src/back.mjs b/designs/yuri/src/back.mjs index 8008a9d0f57..f5bef15225e 100644 --- a/designs/yuri/src/back.mjs +++ b/designs/yuri/src/back.mjs @@ -42,7 +42,8 @@ function yuriBack({ paths.gussetBase = new Path() .move(points.bottom) .line(points.armhole) - .attr('class', 'note stroke-xxl') + .setClass('note stroke-xxl') + .hide() store.set('gussetLength', paths.gussetBase.length()) paths.saBase = new Path() .move(points.armhole) @@ -51,14 +52,13 @@ function yuriBack({ .join(paths.backArmhole) .line(points.s3CollarSplit) .join(paths.backCollar) - .attr('class', 'note stroke-xxl') + .setClass('note stroke-xxl') + .hide() paths.hemBase = new Path() .move(points.cbBottom) .line(points.bottom) - .attr('class', 'note stroke-xxl') - paths.gussetBase.render = false - paths.saBase.render = false - paths.hemBase.render = false + .setClass('note stroke-xxl') + .hide() paths.seam = paths.gussetBase .join(paths.saBase) diff --git a/designs/yuri/src/front.mjs b/designs/yuri/src/front.mjs index b8bb1649e17..a0f19510e8c 100644 --- a/designs/yuri/src/front.mjs +++ b/designs/yuri/src/front.mjs @@ -55,19 +55,19 @@ function yuriFront({ .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .join(paths.frontArmhole) .line(points.s3CollarSplit) - .attr('class', 'note stroke-xxl') + .setClass('note stroke-xxl') + .hide() paths.buttonBase = new Path() .move(points.s3CollarSplit) .line(points.button) .line(points.cfBottom) - .attr('class', 'note stroke-xxl') + .attr('note stroke-xxl') + .hide() paths.hemBase = new Path() .move(points.cfBottom) .line(points.bottom) - .attr('class', 'note stroke-xxl') - paths.saBase.render = false - paths.hemBase.render = false - paths.buttonBase.render = false + .setClass('note stroke-xxl') + .hide() paths.seam = paths.saBase .clone() diff --git a/designs/yuri/src/sleeve.mjs b/designs/yuri/src/sleeve.mjs index 0264a1181d5..52a22908644 100644 --- a/designs/yuri/src/sleeve.mjs +++ b/designs/yuri/src/sleeve.mjs @@ -12,15 +12,15 @@ function yuriSleeve({ Point, Path, points, paths, complete, sa, paperless, macro .line(points.bicepsRight) .join(paths.sleevecap) .line(points.wristLeft) - .attr('class', 'various stroke-xxl') + .setClass('various stroke-xxl') + .hide() paths.hemBase = new Path() .move(points.wristLeft) .line(points.wristRight) - .attr('class', 'various stroke-xxl') - paths.saBase.render = false - paths.hemBase.render = false + .setClass('various stroke-xxl') + .hide() - paths.seam = paths.saBase.join(paths.hemBase).close().attr('class', 'fabric') + paths.seam = paths.saBase.join(paths.hemBase).close().setClass('fabric') // Complete? if (complete) { diff --git a/packages/core/src/part.mjs b/packages/core/src/part.mjs index 703d5c8cf7f..9bb4c7f3c41 100644 --- a/packages/core/src/part.mjs +++ b/packages/core/src/part.mjs @@ -30,8 +30,7 @@ export function Part() { utils.__addNonEnumProp(this, 'hooks', new Hooks()) // Enumerable properties - this.render = true // FIXME: Replace render with hide - this.hide = false // FIXME: Replace render with hide + this.hidden = false this.attributes = new Attributes() this.points = {} this.paths = {} @@ -72,6 +71,41 @@ Part.prototype.getId = function (prefix = '') { return prefix + this.freeId } +/** + * Hide the part + * + * @return {Part} part - The Part instance + */ +Part.prototype.hide = function () { + this.hidden = true + + return this +} + +/** + * Reveal the part - alias for part.unhide() + * + * @return {Part} part - The Part instance + */ +Part.prototype.reveal = function () { + this.unhide() + + return this +} + +/** + * Set the hidden attribute + * + * @param {boolean} hidden - The value to set the hidden property to + * @return {Part} this - The Part instance + */ +Part.prototype.setHidden = function (hidden = false) { + if (hidden) this.hidden = true + else this.hidden = false + + return this +} + /** Returns an object with shorthand access for pattern design */ /** * Returns an object that will be passed to draft method to be destructured @@ -83,19 +117,19 @@ Part.prototype.shorthand = function () { const paperless = this.context.settings?.paperless === true ? true : false const sa = this.context.settings?.complete ? this.context.settings?.sa || 0 : 0 const shorthand = { + complete, + hide: this.hide, + log: this.context.store.log, + macro: this.__macroClosure(), + paperless, part: this, + reveal: this.reveal, sa, scale: this.context.settings?.scale, store: this.context.store, - macro: this.__macroClosure(), + unhide: this.unhide, units: this.__unitsClosure(), utils: utils, - complete, - paperless, - events: this.context.events, - log: this.context.store.log, - addCut: this.addCut, - removeCut: this.removeCut, } // Add top-level store methods and add a part name parameter const partName = this.name @@ -170,6 +204,17 @@ Part.prototype.shorthand = function () { return shorthand } +/** + * Unhide the part - alias for part.reveal() + * + * @return {Part} part - The Part instance + */ +Part.prototype.unhide = function () { + this.hidden = false + + return this +} + /** * Returns a value formatted for units set in settings * @@ -198,7 +243,7 @@ Part.prototype.__boundary = function () { for (let key in this.paths) { try { let path = this.paths[key].__boundary() - if (path.render) { + if (!path.hidden) { if (path.topLeft.x < topLeft.x) topLeft.x = path.topLeft.x if (path.topLeft.y < topLeft.y) topLeft.y = path.topLeft.y if (path.bottomRight.x > bottomRight.x) bottomRight.x = path.bottomRight.x diff --git a/packages/core/src/path.mjs b/packages/core/src/path.mjs index bcd7613a322..33af403e205 100644 --- a/packages/core/src/path.mjs +++ b/packages/core/src/path.mjs @@ -24,12 +24,11 @@ import { */ export function Path() { // Enumerable properties - this.hide = false + this.hidden = false this.ops = [] this.attributes = new Attributes() this.topLeft = false this.bottomRight = false - this.render = true return this } @@ -158,7 +157,7 @@ Path.prototype.bbox = function () { * @return {Path} clone - A clone of this Path instance */ Path.prototype.clone = function () { - let clone = new Path().__withLog(this.log).setRender(this.render) + let clone = new Path().__withLog(this.log).setHidden(this.hidden) if (this.topLeft) clone.topLeft = this.topLeft.clone() else clone.topLeft = false if (this.bottomRight) clone.bottomRight = this.bottomRight.clone() @@ -313,6 +312,17 @@ Path.prototype.end = function () { else return op.to } +/** + * Hide the path + * + * @return {Path} path - The Path instance + */ +Path.prototype.hide = function () { + this.hidden = true + + return this +} + /** * Replace a noop operation with the ops from path * @@ -521,6 +531,17 @@ Path.prototype.offset = function (distance) { return __pathOffset(this, distance, this.log) } +/** + * Reveal the path - alias for path.unhide() + * + * @return {Path} path - The Path instance + */ +Path.prototype.reveal = function () { + this.unhide() + + return this +} + /** * Returns a reversed version of this Path * @@ -590,10 +611,15 @@ Path.prototype.setClass = function (className = false) { return this } -/** FIXME: This should go */ -Path.prototype.setRender = function (render = true) { - if (render) this.render = true - else this.render = false +/** + * Set the hidden attribute + * + * @param {boolean} hidden - The value to set the hidden property to + * @return {object} this - The Path instance + */ +Path.prototype.setHidden = function (hidden = false) { + if (hidden) this.hidden = true + else this.hidden = false return this } @@ -833,6 +859,17 @@ Path.prototype.trim = function () { return this } +/** + * Unhide the path - alias for path.reveal() + * + * @return {Path} path - The Path instance + */ +Path.prototype.unhide = function () { + this.hidden = false + + return this +} + ////////////////////////////////////////////// // PRIVATE METHODS // ////////////////////////////////////////////// @@ -956,9 +993,6 @@ Path.prototype.__withLog = function (log = false) { return this } - - - ////////////////////////////////////////////// // PUBLIC STATIC METHODS // ////////////////////////////////////////////// @@ -1217,8 +1251,9 @@ function shiftAlongBezier(distance, bezier, steps = false) { .curve( new Point(...Object.values(bezier.points[1])), new Point(...Object.values(bezier.points[2])), - new Point(...Object.values(bezier.points[3])), - ).roughLength() + new Point(...Object.values(bezier.points[3])) + ) + .roughLength() if (rlen < 2) steps = 20 else if (rlen < 10) steps = 40 else if (rlen < 100) steps = 100 diff --git a/packages/core/src/pattern.mjs b/packages/core/src/pattern.mjs index 5bfeed58798..24ba8cfde1e 100644 --- a/packages/core/src/pattern.mjs +++ b/packages/core/src/pattern.mjs @@ -128,19 +128,19 @@ Pattern.prototype.draft = function () { } } else this.stores[set].log.error(`Unable to draft pattern. Part.draft() is not callable`) try { - this.parts[set][partName].render = - this.parts[set][partName].render === false ? false : this.__wants(partName, set) + this.parts[set][partName].hidden = + this.parts[set][partName].hidden === true ? true : !this.__wants(partName, set) } catch (err) { this.stores[set].log.error([ - `Unable to set \`render\` property on part \`${partName}\``, + `Unable to set \`hidden\` property on part \`${partName}\``, err, ]) } } else { this.stores[set].log.debug( - `Part \`${partName}\` is not needed. Skipping draft and setting render to \`false\`` + `Part \`${partName}\` is not needed. Skipping draft and setting hidden to \`true\`` ) - this.parts[set][partName].render = false + this.parts[set][partName].hidden = true } } this.__runHooks('postDraft') @@ -149,6 +149,15 @@ Pattern.prototype.draft = function () { return this } +/** + * Return the initialized configuration + * + * @return {object} config - The initialized config + */ +Pattern.prototype.getConfig = function () { + return this.init().config +} + /** Returns props required to render this pattern through * an external renderer (eg. a React component) * @@ -176,7 +185,7 @@ Pattern.prototype.getRenderProps = function () { })) props.parts = {} for (let p in this.parts) { - if (this.parts[p].render) { + if (!this.parts[p].hidden) { props.parts[p] = { paths: this.parts[p].paths, points: this.parts[p].points, diff --git a/packages/core/src/svg.mjs b/packages/core/src/svg.mjs index 5a57a3590b7..4bd8b395984 100644 --- a/packages/core/src/svg.mjs +++ b/packages/core/src/svg.mjs @@ -57,16 +57,16 @@ Svg.prototype.render = function (pattern) { this.tail = this.__renderTail() this.svg = '' this.layout = {} // Reset layout - for (let partId in pattern.parts) { - let part = pattern.parts[partId] - if (part.render) { - let partSvg = this.__renderPart(part) - this.layout[partId] = { - svg: partSvg, - transform: part.attributes.getAsArray('transform'), + for (let stackId in pattern.stacks) { + const stack = pattern.stacks[stackId] + if (!stack.hidden) { + const stackSvg = this.__renderStack(stack) + this.layout[stackId] = { + svg: stackSvg, + transform: stack.attributes.getAsArray('transform'), } - this.svg += this.__openGroup(`${this.idPrefix}part-${partId}`, part.attributes) - this.svg += partSvg + this.svg += this.__openGroup(`${this.idPrefix}stack-${stackId}`, stack.attributes) + this.svg += stackSvg this.svg += this.__closeGroup() } } @@ -279,11 +279,11 @@ Svg.prototype.__renderPathText = function (path) { * @param {Part} part - The Part instance to render * @return {string} svg - The SVG markup for the Part object */ -Svg.prototype.__renderPart = function (part) { - let svg = '' +Svg.prototype.__renderPart = function (part, partId) { + let svg = this.__openGroup(`${this.idPrefix}part-${partId}`, part.attributes) for (let key in part.paths) { let path = part.paths[key] - if (path.render) svg += this.__renderPath(path) + if (!path.hidden) svg += this.__renderPath(path) } for (let key in part.points) { if (part.points[key].attributes.get('data-text')) { @@ -297,6 +297,7 @@ Svg.prototype.__renderPart = function (part) { let snippet = part.snippets[key] svg += this.__renderSnippet(snippet, part) } + svg += this.__closeGroup() return svg } @@ -346,6 +347,20 @@ Svg.prototype.__renderSnippet = function (snippet) { return svg } +/** + * Returns SVG markup for a Stack object + * + * @private + * @param {Stack} stack - The Stack instance to render + * @return {string} svg - The SVG markup for the Stack object + */ +Svg.prototype.__renderStack = function (stack) { + let svg = '' + for (const part of stack.parts) svg += this.__renderPart(part) + + return svg +} + /** * Returns SVG markup for the style block * diff --git a/packages/core/tests/path.test.mjs b/packages/core/tests/path.test.mjs index bb97c137bf8..5ab947e0772 100644 --- a/packages/core/tests/path.test.mjs +++ b/packages/core/tests/path.test.mjs @@ -689,9 +689,9 @@ describe('Path', () => { expect(p1.log()).to.equal('hello') }) - it('Should set render to true/false', () => { - const p1 = new Path().setRender(false) - expect(p1.render).to.equal(false) + it('Should set hidden to true/false', () => { + const p1 = new Path().setHidden(true) + expect(p1.hidden).to.equal(true) }) it('Should set class with setClass', () => { diff --git a/plugins/plugin-gore/src/index.mjs b/plugins/plugin-gore/src/index.mjs index b9dffe8fdba..9cc58b84aa7 100644 --- a/plugins/plugin-gore/src/index.mjs +++ b/plugins/plugin-gore/src/index.mjs @@ -32,7 +32,7 @@ export const plugin = { this.points[prefix + 'Cp2'], this.points[prefix + 'p2'] ) - .setRender(false) + .hide() this.points[prefix + 'p2'] = this.paths.auxiliaryPath.intersectsX(0)[0] //the new point p2 is the one in which the auxiliary curve intersects x=0 this.paths.auxiliaryPath = this.paths.auxiliaryPath.split(this.points[prefix + 'p2'])[0] //the auxiliary curve is split @@ -51,8 +51,8 @@ export const plugin = { .close() .attr('class', so.class ? so.class : '') - if (typeof so.render !== 'undefined' && so.render) this.paths[prefix + 'seam'].render = true - else this.paths[prefix + 'seam'].render = false + if (so?.hidden) this.paths[prefix + 'seam'].hide() + else this.paths[prefix + 'seam'].unhide() }, }, } diff --git a/plugins/plugin-round/src/index.mjs b/plugins/plugin-round/src/index.mjs index 83053a05431..567217a725d 100644 --- a/plugins/plugin-round/src/index.mjs +++ b/plugins/plugin-round/src/index.mjs @@ -31,9 +31,8 @@ export const plugin = { this.points[prefix + 'End'] ) .attr('class', so.class ? so.class : '') - if (typeof so.render !== 'undefined' && so.render) - this.paths[prefix + 'Rounded'].render = true - else this.paths[prefix + 'Rounded'].render = false + if (so?.hidden) this.paths[prefix + 'Rounded'].hide() + else this.paths[prefix + 'Rounded'].unhide() }, }, } diff --git a/plugins/plugin-theme/src/index.mjs b/plugins/plugin-theme/src/index.mjs index 5698ba02707..bea6eca58ce 100644 --- a/plugins/plugin-theme/src/index.mjs +++ b/plugins/plugin-theme/src/index.mjs @@ -37,7 +37,7 @@ export const plugin = { : (svg.defs += grid.metric) for (const key in svg.pattern.parts) { const part = svg.pattern.parts[key] - if (part.render && svg.pattern.needs(key)) { + if (!part.hidden && svg.pattern.needs(key)) { let anchor = new svg.pattern.Point(0, 0) if (typeof part.points.gridAnchor !== 'undefined') anchor = part.points.gridAnchor else if (typeof part.points.anchor !== 'undefined') anchor = part.points.anchor