1
0
Fork 0
freesewing/sites/dev/docs/reference/api/pattern/samplemodels
Joost De Cock ab3204f9f1 chore: Port FreeSewing.dev to docusaurus
The replaces the NextJS site powering FreeSewing.dev with a Docusaurus
setup. It's part of my efforts to simplify FreeSewing's setup so we can
focus on our core value proposition.
2024-09-28 13:13:48 +02:00
..
readme.mdx chore: Port FreeSewing.dev to docusaurus 2024-09-28 13:13:48 +02:00

---
title: Pattern.sampleModels()
---

The `Pattern.sampleModels()` 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, it will draft a variants for each of the models you pass it.

:::tip
The goal of model sampling is to verify that a pattern grades correctly up and down as sizes change.
:::

:::noteThis method is chainable as it returns the Pattern object:::

## Pattern.sampleModels() signature

```js
Pattern pattern.sampleModels(object models, string focus)
```

The `models` object you pass as the first parameter should be structured as such:

```js
{
 modelName1: {
   measurement1: valueInMm,
   measurement2: valueInMm,
   // ...
 },
 modelName2: {
   measurement1: valueInMm,
   measurement2: valueInMm,
   // ...
 },
 // ...
}
```

The (optional) string you can pass as the second parameter should hold the
key of one of the models in the first parameter. In our example above, it
could hold `modelName2` for example.

By passing this second parameter, you can put the _focus_ on one of the models,
which will influence the render style, and make it
easier to see a comparison between a given set of measurements, and the rest.

Alternatively, you can use the `Pattern.sample()` method and set `settings.sample.focus` to the key
identifying your model in the models object.

## Pattern.sampleModels() example

```js
import { Aaron } from "@freesewing/aaron"

const Aaron = new Aaron()

// 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 svg = aaron.sampleModels(measurements, "34").render()
```