2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
title: Adding pattern parts
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-12 14:42:45 +02:00
|
|
|
Parts can be added to the design add build time, by passing them to [the Design
|
|
|
|
constructor](/reference/api/design), or at runtime by calling
|
|
|
|
[Pattern.addPart()](/reference/api/pattern/addpart). The latter approach is
|
|
|
|
rarely used, but it's there if you need it.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-12 14:42:45 +02:00
|
|
|
## At build time
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-12 14:42:45 +02:00
|
|
|
```mjs
|
|
|
|
import { Design } from '@freesewing/core'
|
|
|
|
import { myPart } from './mypart.mjs'
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-12 14:42:45 +02:00
|
|
|
const Sorcha = new Design({
|
|
|
|
parts: [ myPart ]
|
|
|
|
})
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
2022-10-12 14:42:45 +02:00
|
|
|
## At run time
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-12 14:42:45 +02:00
|
|
|
```mjs
|
|
|
|
import { Aaron } from '@freesewing/aaron'
|
|
|
|
import { myRuntimePart } from './mypart.mjs'
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-12 14:42:45 +02:00
|
|
|
const pattern = new Aaron()
|
|
|
|
pattern.addPart(myRuntimePart)
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|