2021-10-17 18:26:00 +02:00
|
|
|
---
|
|
|
|
title: Design
|
2021-08-25 16:09:31 +02:00
|
|
|
order: 10
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-20 18:09:28 +02:00
|
|
|
The `Design` named export in FreeSewing's core library serves a single purpose:
|
|
|
|
To create new pattern designs.
|
2021-09-25 17:05:18 +02:00
|
|
|
|
|
|
|
## Design constructor
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
2022-09-20 18:09:28 +02:00
|
|
|
import { Design } from "@freesewing/core"
|
|
|
|
|
|
|
|
const Sorcha = new Design({
|
|
|
|
// design configuration here
|
|
|
|
})
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
2022-02-19 08:04:25 +01:00
|
|
|
This constructor creates a new pattern design.
|
2022-09-20 18:09:28 +02:00
|
|
|
It takes a single argument, an object holding the design's configuration.
|
|
|
|
|
|
|
|
## Design configuration
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-20 18:09:28 +02:00
|
|
|
Since a design's configuration is managed at the part level,
|
|
|
|
the Design constructor only expects a `parts` attribute that should
|
|
|
|
hold an array of parts to include in the Design.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
2022-09-20 18:09:28 +02:00
|
|
|
const Sorcha = new Design({
|
|
|
|
parts: [ front, back, sleeve ],
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
<Tip>A Design in FreeSewing is little more than a container for various Parts</Tip>
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-20 18:09:28 +02:00
|
|
|
Optionally, you can also pass it a `data` attrbute
|
|
|
|
to hold any custom data you'd like to add to your Design.
|
|
|
|
|
|
|
|
Any `data` you add to the Design constructor will be added
|
|
|
|
to [the Store](/reference/api/store).
|
|
|
|
|
|
|
|
```js
|
|
|
|
const Sorcha = new Design({
|
|
|
|
parts: [ front, back, sleeve ],
|
|
|
|
data: {
|
|
|
|
// Your custom data here
|
|
|
|
}
|
|
|
|
})
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
<Tip>
|
|
|
|
|
2022-09-20 18:09:28 +02:00
|
|
|
This Design constructor is a _super-constructor_.
|
|
|
|
It will return a constructor method that will a pattern based on your design.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
</Tip>
|