From 8bb84beeaa17d60e3e3d322e6d745b515180b621 Mon Sep 17 00:00:00 2001 From: joostdecock Date: Thu, 28 Sep 2023 15:23:28 +0200 Subject: [PATCH] chore(bob): Better comment style --- designs/bob/src/bib.mjs | 94 ++++++++++++++++++++++++++++++----------- 1 file changed, 70 insertions(+), 24 deletions(-) diff --git a/designs/bob/src/bib.mjs b/designs/bob/src/bib.mjs index 5c98c1aac8c..a9f3d3770a1 100644 --- a/designs/bob/src/bib.mjs +++ b/designs/bob/src/bib.mjs @@ -24,12 +24,16 @@ export const bib = { units, part, }) => { - // Head size + /* + * Head size + */ const head = (`head` in measurements ? measurements.head : 360) * options.headSize - // Construct the neck opening + /* + * Construct the neck opening + */ + const target = (head * options.neckRatio) / 4 let tweak = 1 - let target = (head * options.neckRatio) / 4 let delta do { points.right = new Point((tweak * head) / 10, 0) @@ -58,7 +62,9 @@ export const bib = { points.topCp1 = points.bottomCp2.flipY() points.topCp2 = points.bottomCp1.flipY() - // Construct the outline + /* + * Construct the outline + */ let width = head * options.widthRatio let length = head * options.lengthRatio @@ -76,14 +82,18 @@ export const bib = { points.edgeTopLeftCp = points.edgeTop.shiftFractionTowards(points.topLeft, 0.5) points.edgeTopRightCp = points.edgeTopLeftCp.flipX() - // Round the end of the straps + /* + * Round the end of the straps + */ let strap = points.edgeTop.dy(points.top) points.tipRight = points.edgeTop.translate(strap / 2, strap / 2) points.tipRightTop = new Point(points.tipRight.x, points.edgeTop.y) points.tipRightBottom = new Point(points.tipRight.x, points.top.y) - // Macros will return the auto-generated IDs + /* + * Macros will return the auto-generated IDs + */ const ids1 = { tipRightTop: macro('round', { id: 'tipRightTop', @@ -98,13 +108,19 @@ export const bib = { via: points.tipRightBottom, }), } - // Create points from them with easy names + + /* + * Create points from them with easy names + */ for (const side in ids1) { for (const id of ['start', 'cp1', 'cp2', 'end']) { points[`${side}${utils.capitalize(id)}`] = points[ids1[side].points[id]].copy() } } - // Rotate straps so they don't overlap + + /* + * Rotate straps so they don't overlap + */ let rotateThese = [ 'edgeTopLeftCp', 'edgeTop', @@ -127,10 +143,14 @@ export const bib = { for (let p of rotateThese) points[p] = points[p].rotate(1, points.edgeLeft) } - // Add points to anchor snaps on + /* + * Add points to anchor snaps on + */ points.snapLeft = points.top.shiftFractionTowards(points.edgeTop, 0.5) - // Mirror points to the other side + /* + * Mirror points to the other side + */ points.edgeTopRightCp = points.edgeTopLeftCp.flipX() points.topCp1 = points.topCp2.flipX() points.tipLeftTopStart = points.tipRightTopStart.flipX() @@ -143,9 +163,12 @@ export const bib = { points.tipLeftBottomEnd = points.tipRightBottomEnd.flipX() points.snapRight = points.snapLeft.flipX() - // Round the bottom of the bib - // Radius is fixed, but you could use an option for it) - // Macros will return the auto-generated IDs + /* + * Round the bottom of the bib + * Radius is fixed, but you could use an option for it) + * + * Macros will return the auto-generated IDs + */ const ids2 = { bottomLeft: macro('round', { id: 'bottomLeft', @@ -162,13 +185,18 @@ export const bib = { radius: points.bottomRight.x / 4, }), } - // Create points from them with easy names + /* + * Create points from them with easy names + */ for (const side in ids2) { for (const id of ['start', 'cp1', 'cp2', 'end']) { points[`${side}${utils.capitalize(id)}`] = points[ids2[side].points[id]].copy() } } - // Construct the path + + /* + * Construct the path + */ paths.seam = new Path() .move(points.edgeLeft) .line(points.bottomLeftStart) @@ -190,10 +218,14 @@ export const bib = { .attr('class', 'fabric') /* - * Annotations + * + * Annotations + * */ - // Let the user know about the bias tape and fabric requirements + /* + * Let the user know about the bias tape and fabric requirements + */ store.flag.note({ msg: 'bob:biasTapeLength', replace: { @@ -201,14 +233,20 @@ export const bib = { }, }) - // Cut list + /* + * Cut list + */ store.cutlist.addCut({ cut: 1, from: 'fabric' }) - // Add the snaps + /* + * Add the snaps + */ snippets.snapStud = new Snippet('snap-stud', points.snapLeft) snippets.snapSocket = new Snippet('snap-socket', points.snapRight).attr('opacity', 0.5) - // Add the bias tape + /* + * Add the bias tape + */ if (complete) paths.bias = paths.seam .offset(-5) @@ -216,7 +254,9 @@ export const bib = { .attr('data-text', 'bob:finishWithBiasTape') .attr('data-text-class', 'center fill-note') - // Add the title + /* + * Add the title + */ points.title = points.bottom.shift(-90, 45) macro('title', { at: points.title, @@ -226,15 +266,21 @@ export const bib = { scale: 0.8, }) - // Add the scalebox + /* + * Add the scalebox + */ points.scalebox = points.title.shift(-90, 65) macro('scalebox', { at: points.scalebox }) - // Add the logo + /* + * Add the logo + */ points.logo = new Point(0, 0) snippets.logo = new Snippet('logo', points.logo) - // Add dimensions + /* + * Add dimensions + */ macro('hd', { id: 'wFull', from: points.bottomLeftStart,