From be7a4b2617e195cc08b1ff54c522310ca87b3c6b Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Mon, 1 Nov 2021 17:40:31 +0100 Subject: [PATCH] fix(sandy): Typo and prefer const to let --- packages/sandy/src/curved-waistband.js | 5 +++-- packages/sandy/src/shared.js | 16 ++++++++-------- packages/sandy/src/skirt.js | 8 ++++---- packages/sandy/src/straight-waistband.js | 2 +- packages/sandy/src/waistband.js | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/sandy/src/curved-waistband.js b/packages/sandy/src/curved-waistband.js index 04c19da2fcf..b525541133b 100644 --- a/packages/sandy/src/curved-waistband.js +++ b/packages/sandy/src/curved-waistband.js @@ -6,7 +6,7 @@ export default function (part) { * and intenal radius and angle calculated from measurements * and options */ - let { + const { utils, store, sa, @@ -25,7 +25,8 @@ export default function (part) { // Calculate the angle of the ring sector and the radius of the upper arc const an = utils.rad2deg(store.get('bottomCircumference') - store.get('topCircumference')) / - absuluteOptions.waistbandWidth + absoluteOptions.waistbandWidth + const rad = store.get('topCircumference') / utils.deg2rad(an) diff --git a/packages/sandy/src/shared.js b/packages/sandy/src/shared.js index bd99fa2a58c..2e9826dd4cf 100644 --- a/packages/sandy/src/shared.js +++ b/packages/sandy/src/shared.js @@ -1,8 +1,8 @@ const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => { - let { utils, Point, points, Path } = part.shorthand() + const { utils, Point, points, Path } = part.shorthand() const roundExtended = (radius, angle = 90) => { - let arg = utils.deg2rad(angle / 2) + const arg = utils.deg2rad(angle / 2) return (radius * 4 * (1 - Math.cos(arg))) / Math.sin(arg) / 3 } @@ -11,8 +11,8 @@ const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => { * Calculates the distance of the control point for the internal * and external arcs using bezierCircleExtended */ - let distIn = roundExtended(radIn, an / 2) - let distEx = roundExtended(radEx, an / 2) + const distIn = roundExtended(radIn, an / 2) + const distEx = roundExtended(radEx, an / 2) // The centre of the circles points.center = new Point(0, 0) @@ -64,11 +64,11 @@ const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => { points.ex2C = points.ex2.shift(an / 2 + 180, distEx) // Flip all the points to generate the full ring sector - for (let id of ['in2', 'in2C', 'in1C', 'ex1C', 'ex2C', 'ex2']) + for (const id of ['in2', 'in2C', 'in1C', 'ex1C', 'ex2C', 'ex2']) points[id + 'Flipped'] = points[id].flipX() // Rotate all the points an angle rot - for (let id of [ + for (const id of [ 'in1', 'in1C', 'in2', @@ -88,8 +88,8 @@ const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => { if (rotate) { // Rotate all points so the line from in1Rotated to ex1Rotated is vertical - let deg = 270 - points.in2Flipped.angle(points.ex2Flipped) - for (let id in points) { + const deg = 270 - points.in2Flipped.angle(points.ex2Flipped) + for (const id in points) { points[id] = points[id].rotate(deg, points.in2Flipped) } } diff --git a/packages/sandy/src/skirt.js b/packages/sandy/src/skirt.js index 0f5c963e671..10b97c839e7 100644 --- a/packages/sandy/src/skirt.js +++ b/packages/sandy/src/skirt.js @@ -1,7 +1,7 @@ import draftRingSector from './shared' export default function (part) { - let { + const { utils, store, sa, @@ -75,7 +75,7 @@ export default function (part) { * fabric */ if (an > 90 && sa) { - let maxAn = utils.rad2deg(Math.atan(radiusWaist / sa)) + const maxAn = utils.rad2deg(Math.atan(radiusWaist / sa)) if (an > 90 + maxAn) an = 90 + maxAn } } @@ -83,14 +83,14 @@ export default function (part) { * The radius of the hem arc is the radius of the waist * arc with the length of the skirt added */ - let radiusHem = + const radiusHem = radiusWaist + store.get('fullLength') * options.lengthBonus - absoluteOptions.waistbandWidth /** * The ring sector will be rotated an angle an/2 so we * display the part with one edge of the skirt vertical */ - let rot = an / 2 + const rot = an / 2 // Call draftRingSector to draft the part paths.seam = draftRingSector(part, rot, an, radiusWaist, radiusHem, true).attr('class', 'fabric') diff --git a/packages/sandy/src/straight-waistband.js b/packages/sandy/src/straight-waistband.js index b3050e967d3..3aab2e436d7 100644 --- a/packages/sandy/src/straight-waistband.js +++ b/packages/sandy/src/straight-waistband.js @@ -3,7 +3,7 @@ export default function (part) { * The straight waistband is just a rectangle with the width * of double the waistband width, since it will be folded */ - let { + const { store, sa, Point, diff --git a/packages/sandy/src/waistband.js b/packages/sandy/src/waistband.js index 78de589937c..7c64a5848be 100644 --- a/packages/sandy/src/waistband.js +++ b/packages/sandy/src/waistband.js @@ -2,7 +2,7 @@ import straightWaistband from './straight-waistband' import curvedWaistband from './curved-waistband' export default (part) => { - let { options } = part.shorthand() + const { options } = part.shorthand() if (options.waistbandShape === 'curved') return curvedWaistband(part) else return straightWaistband(part)