1
0
Fork 0

chore(markdown): Working on v3 docs

This commit is contained in:
Joost De Cock 2022-09-20 18:09:28 +02:00
parent 22680fbddc
commit 1f7ba79f81
17 changed files with 433 additions and 272 deletions

View file

@ -2,24 +2,28 @@
title: Pattern.sample()
---
A pattern's `sample()` method will _sample_ the pattern which means
to draft it in different iterations while adjusting the input settings.
The `Pattern.sample()` method will _sample_ the pattern which means
to draft multiple variants of the same pattern, and stack them on
top of each other.
<Note>This method is chainable as it returns the Pattern object</Note>
Under the hood, this method will call one of
[Pattern.sampleOption()](/reference/apu/pattern/sampleoption),
[Pattern.sampleMeasurement()](/reference/apu/pattern/sampleoption), or
[Pattern.sampleModels()](/reference/apu/pattern/sampleoption) to sample
an option, a measurement, or a set of measurements respectively.
an option, a measurement, or different models respectively.
Unlike those three methods where you pass the relevant info to to the method,
this `Pattern.sample()` will instead read the `pattern.settings.sample`
object to determine what to do.
this `Pattern.sample()` method will instead read the `settings.sample`
object to determine what needs to be done.
The possiblities are:
The `settings.sample` object can hold the following properties:
- **type**: One of `option`, `measurement`, or `models`
- **option**: An option name as defined in the pattern config file (only used when `type` is option).
- **measurement**: A measurement name as defined in the pattern config file (only used when `type` is measurement).
- **models**: An array of models with the required measurements for this pattern (only used when `type` is models).
- **models**: A plain object of different models where the key is the model name and the value an object with the required measurements.
See the specific sample methods below for more details:
@ -27,35 +31,6 @@ See the specific sample methods below for more details:
- [Pattern.sampleMeasurement()](/reference/apu/pattern/sampleoption)
- [Pattern.sampleModels()](/reference/apu/pattern/sampleoption)
From a lifecycle point of view, the `Pattern.sample()` method is a substitute for
`Pattern.draft()`. So you call it after instantiating the pattern, prior to
calling `Pattern.render()`.
<Tip>
###### Anchor your samples
If you add a point named `anchor` to your pattern part, the different samples
will be anchored on this point.
In other words, for each sample, the anchor point will be kept in the same location.
</Tip>
<Note>This method is chainable as it returns the Pattern object</Note>
<Warning>
##### FreeSewing v3 breaking changes
This method does some juggling under the hood, essentially cramming
different versions of a pattern into a single Pattern object.
This behavior is likely to change in FreeSewing v3. Refer to [the
roadmap](https://github.com/freesewing/freesewing/discussions/1278) for details.
</Warning>
## Pattern.sample() signature
```js
@ -65,14 +40,13 @@ Pattern pattern.sample()
## Pattern.sample() example
```js
import Aaron from "@freesewing/aaron"
import models from "@freesewing/models"
import { Aaron } from "@freesewing/aaron"
import { cisFemaleAdult } from "@freesewing/models"
const pattern = new Aaron({
settings: {
embed: true,
},
measurements: models.manSize38
sample: {
models: cisFemaleAdult
}
})
const svg = pattern.sample().render()