2021-10-17 18:26:00 +02:00
|
|
|
---
|
|
|
|
title: Pattern.sampleOption()
|
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-20 18:09:28 +02:00
|
|
|
The `Pattern.sampleOption()` method will _sample_ the pattern which means
|
|
|
|
to draft multiple variants of the same pattern, and stack them on
|
|
|
|
top of each other.
|
|
|
|
|
|
|
|
In this particular case, the variants it drafts depend
|
2022-12-08 20:45:45 -08:00
|
|
|
on [the type of option](/reference/api/part/config/options/):
|
2021-09-25 17:05:18 +02:00
|
|
|
|
2022-12-08 20:45:45 -08:00
|
|
|
- For a Percentage or Degree option, 10 steps will be sampled, between min and max
|
|
|
|
- For a Counter or Millimeter option, a maximum of 10 steps will be sampled, between min and max
|
|
|
|
- For a Constant numeric option, 10 steps will be sampled between 90% and 110% of the value
|
|
|
|
- For a List option, each option in the list will be sampled
|
|
|
|
- For a Boolean option, both `false` and `true` will be sampled
|
2022-09-20 18:09:28 +02:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::tip
|
2021-09-25 17:05:18 +02:00
|
|
|
The goal of option sampling is to verify the impact of an option on the pattern, and verify that
|
|
|
|
its min and max boundaries are correct and its default value is sensible.
|
2024-09-28 13:13:48 +02:00
|
|
|
:::
|
2021-09-25 17:05:18 +02:00
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::noteThis method is chainable as it returns the Pattern object:::
|
2021-09-25 17:05:18 +02:00
|
|
|
|
|
|
|
## Pattern.sampleOption() signature
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
|
|
|
Pattern pattern.sampleOption(string option)
|
2022-02-19 08:04:25 +01:00
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2021-09-25 17:05:18 +02:00
|
|
|
## Pattern.sampleOption() example
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
2022-09-20 18:09:28 +02:00
|
|
|
import { Aaron } from "@freesewing/aaron"
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2023-10-30 19:27:24 +01:00
|
|
|
// Load some public test measurements from the FreeSewing backend
|
|
|
|
const measurements = (
|
|
|
|
await (
|
|
|
|
await fetch("https://backend3.freesewing.org/curated-sets/1.json")
|
|
|
|
).json()
|
|
|
|
).measurements
|
|
|
|
|
|
|
|
const pattern = new Aaron({ measurements })
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-08 20:45:45 -08:00
|
|
|
const svg = pattern.draft().sampleOption('backlineBend')
|
2022-02-19 08:04:25 +01:00
|
|
|
```
|