1
0
Fork 0

Minor updates to pattern design tutorial for clarity and consistency

This commit is contained in:
Natalia Sayang 2024-03-12 02:02:06 +00:00
parent d4919040c2
commit 6a000fd365
6 changed files with 34 additions and 33 deletions

View file

@ -32,9 +32,7 @@ function draftBib({ part }) => {
export const bib = {
name: 'fromscratch.bib',
draft: draftBib,
// highlight-start
measurements: [ 'head' ],
// highlight-end
}
```

View file

@ -32,7 +32,6 @@ export const bib = {
name: 'fromscratch.bib',
draft: draftBib,
measurements: [ 'head' ],
// highlight-start
options: {
neckRatio: {
pct: 80,
@ -41,7 +40,6 @@ export const bib = {
menu: 'fit'
},
},
// highlight-end
}
```
@ -50,7 +48,7 @@ Can you guess what it means?
- We've added the `options` property to our `bib` object
- On the `options` property, we have added `neckRatio` which holds the configuration for our option
- It is a `pct` option -- which means it's a percentage
- Its default value is 90%
- Its default value is 80%
- Its minimum value is 70%
- Its maximum value is 90%
@ -64,8 +62,7 @@ They are all documented [in the part reference docs](/reference/api/part/config/
The `menu` property on our option is *extra*.
It will be ignored by FreeSewing's core library and if we leave it out, our design will produce the same result.
Instead, this `menu` property is there for the benefit FreeSewing's development
environment which will use this to build a menu structure for the various
Instead, this `menu` property is there for the benefit of FreeSewing's development environment which will use this to build a menu structure for the various
options.
This is covered in more detail in [Part 3](/tutorials/pattern-design/part3) of this tutorial.
@ -92,7 +89,6 @@ export const bib = {
max: 90,
menu: 'fit'
},
// highlight-start
widthRatio: {
pct: 45,
min: 35,
@ -105,12 +101,11 @@ export const bib = {
max: 85,
menu: 'style'
},
// highlight-end
},
}
```
This pretty much the exact same thing, except that are placing this in the `style` menu.
This is pretty much the exact same thing, except that are placing these in the `style` menu.
Later, I will test-drive our pattern to see how it behaves when we adapt the options
between their minimum and maximum values. At that time, I may need to tweak these values.

View file

@ -15,16 +15,14 @@ We'll be adding some points to our pattern to do just that. But we want to have
access to our measurements and options to do so. For this, we first destructure
`measurements` and `options` so we can access them:
```design/src/bib.mjs
```src/bib.mjs
function draftBib({
Path,
Point,
paths,
points,
// highlight-start
measurements,
options,
// highlight-end
part,
}) {
@ -39,7 +37,7 @@ Great. Now let's get to work.
Let's add some points, and use them to draw our first curve:
<Example tutorial caption="Our very first path forms a quarter of our neck opening">
```js
```src/bib.mjs
function draftBib({
Path,
Point,
@ -50,7 +48,6 @@ function draftBib({
part,
}) {
// highlight-start
/*
* Construct the quarter neck opening
*/
@ -79,7 +76,6 @@ function draftBib({
points.bottomCp2,
points.bottom
)
// highlight-end
return part
}

View file

@ -20,7 +20,7 @@ does.
If you're not familiar with the `({ part })` syntax you see above, this is a
technique called *parameter destructuring* or more generally, [object
destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment)
destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment).
The draft method receives only 1 parameter: An object that holds everything we
need to draft our method. Destructuring is a way to *pull things out of the
@ -63,12 +63,10 @@ Change the function to look like this:
```src/bib.mjs
function draftBib({
// highlight-start
Path,
Point,
paths,
points,
// highlight-end
part,
}) {
@ -76,7 +74,7 @@ function draftBib({
}
```
That's bunch of new lines, but each of one gives us something we'll use in this
That's a bunch of new lines, but each of one gives us something we'll use in this
tutorial.
For a complete list of what you can access via destructuring like this, refer

View file

@ -8,7 +8,7 @@ going to make sure it is. Here's how we'll make sure the neck opening is _just
right_:
<Example tutorial caption="It might look the same as before, but now it's just right">
```design/src/bib.mjs
```src/bib.mjs
function draftBib({
Path,
Point,
@ -19,29 +19,43 @@ function draftBib({
part,
}) {
// Construct the quarter neck opening
// highlight-start
/*
* Construct the quarter neck opening
*/
let tweak = 1
let target = (measurements.head * options.neckRatio) /4
let delta
do {
// highlight-end
points.right = new Point(tweak * measurements.head / 10, 0)
points.bottom = new Point(0, tweak * measurements.head / 12)
points.right = new Point(
tweak * measurements.head / 10,
0
)
points.bottom = new Point(
0,
tweak * measurements.head / 12
)
points.rightCp1 = points.right.shift(90, points.bottom.dy(points.right)/2)
points.bottomCp2 = points.bottom.shift(0, points.bottom.dx(points.right)/2)
points.rightCp1 = points.right.shift(
90,
points.bottom.dy(points.right) / 2
)
points.bottomCp2 = points.bottom.shift(
0,
points.bottom.dx(points.right) / 2
)
paths.quarterNeck = new Path()
.move(points.right)
.curve(points.rightCp1, points.bottomCp2, points.bottom)
.curve(
points.rightCp1,
points.bottomCp2,
points.bottom
)
// highlight-start
delta = paths.quarterNeck.length() - target
if (delta > 0) tweak = tweak * 0.99
else tweak = tweak * 1.02
} while (Math.abs(delta) > 1)
// highlight-end
return part
}
@ -71,4 +85,4 @@ We keep on doing this until `Math.abs(delta)` is less than 1. Meaning that we
are within 1 mm of our target value.
Now that we're happy with the length of our quarter neck opening, let's
construct the entire neck opening.
complete the entire neck opening.

View file

@ -86,4 +86,4 @@ This structure of putting the draft method at the top of the file and
the part object at the bottom is a bit of a convention in FreeSewing.
</Note>
We'll take a look at our part's *draft method* soon. For now, let's look at adding measurements to our part.
We'll take a deeper look at our part's draft method soon. For now, let's look at adding measurements to our part.