2021-10-17 18:26:00 +02:00
---
2021-08-25 16:09:31 +02:00
title: Adding options
2023-09-30 14:04:18 +02:00
order: 40
2021-10-17 18:26:00 +02:00
---
2021-08-25 16:09:31 +02:00
2023-09-28 09:11:06 +02:00
I have shown what our bib should look like, and added the _head_ measurement
to work with. But there's still a number of choices I have to make:
2021-08-25 16:09:31 +02:00
2022-02-20 14:44:38 +01:00
- How large should the neck opening be?
- How wide should the bib be?
- How long should the bib be?
2021-08-25 16:09:31 +02:00
2023-09-28 09:11:06 +02:00
I could make all of these choices for the user and set them in stone, so to speak.
2021-08-25 16:09:31 +02:00
2023-09-28 09:11:06 +02:00
But since the pattern I am designing is code, it is trivial (and _IMHO_ very satisfying)
to make a pattern flexible and let the user choose.
All I need to do to give control to the user is add _options_ to the part.
2021-08-25 16:09:31 +02:00
## Add the neckRatio option
2023-09-28 09:11:06 +02:00
The first option I will add controls the ratio between the neck opening
2021-08-25 16:09:31 +02:00
and the head circumference. Let's call it `neckRatio` .
2023-09-28 09:11:06 +02:00
For this, I will add the `options` property to our `bib` object:
2021-08-25 16:09:31 +02:00
2023-09-30 14:04:18 +02:00
```src/bib.mjs
2023-09-28 09:11:06 +02:00
function draftBib({ part }) => {
2022-10-09 23:47:32 +02:00
return part
}
export const bib = {
2023-09-30 14:04:18 +02:00
name: 'fromscratch.bib',
2023-08-08 13:20:46 -05:00
draft: draftBib,
2023-09-28 09:11:06 +02:00
measurements: [ 'head' ],
2021-08-25 16:09:31 +02:00
options: {
2023-09-28 09:11:06 +02:00
neckRatio: {
pct: 80,
min: 70,
max: 90,
menu: 'fit'
},
2022-10-09 23:47:32 +02:00
},
}
2021-08-25 16:09:31 +02:00
```
Can you guess what it means?
2023-09-28 09:11:06 +02:00
- 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
2024-01-16 20:04:00 -08:00
- It is a `pct` option -- which means it's a percentage
2024-03-12 02:02:06 +00:00
- Its default value is 80%
2022-02-20 14:44:38 +01:00
- Its minimum value is 70%
- Its maximum value is 90%
2023-09-28 09:11:06 +02:00
There are different types of options, but percentages are by far the most common ones.
They are all documented [in the part reference docs ](/reference/api/part/config/options ).
2021-08-25 16:09:31 +02:00
< Note >
2023-09-28 09:11:06 +02:00
##### What is `menu` and why should you care?
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.
2024-03-12 02:02:06 +00:00
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
2023-09-28 09:11:06 +02:00
options.
2023-09-30 14:04:18 +02:00
This is covered in more detail in [Part 3 ](/tutorials/pattern-design/part3 ) of this tutorial.
2021-08-25 16:09:31 +02:00
< / Note >
2022-10-09 23:47:32 +02:00
## Add the widthRatio and lengthRatio options
2021-08-25 16:09:31 +02:00
Let's do something similar for the width and length of our bib:
2023-09-30 14:04:18 +02:00
```src/bib.mjs
2023-09-28 09:11:06 +02:00
function draftBib({ part }) => {
return part
2021-08-25 16:09:31 +02:00
}
2023-09-28 09:11:06 +02:00
export const bib = {
2023-09-30 14:04:18 +02:00
name: 'fromScratch.bib',
2023-09-28 09:11:06 +02:00
draft: draftBib,
measurements: [ 'head' ],
options: {
neckRatio: {
pct: 80,
min: 70,
max: 90,
menu: 'fit'
},
widthRatio: {
pct: 45,
min: 35,
max: 55,
menu: 'style'
},
lengthRatio: {
pct: 75,
min: 55,
max: 85,
menu: 'style'
},
},
}
```
2021-08-25 16:09:31 +02:00
2024-03-12 02:02:06 +00:00
This is pretty much the exact same thing, except that are placing these in the `style` menu.
2021-08-25 16:09:31 +02:00
2023-09-28 09:11:06 +02:00
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.
2021-08-25 16:09:31 +02:00
2023-09-28 09:11:06 +02:00
With that out of the way, I will start drawing the bib.
2021-08-25 16:09:31 +02:00