1
0
Fork 0
freesewing/markdown/dev/reference/api/design/en.md

78 lines
1.6 KiB
Markdown
Raw Normal View History

---
title: Design
---
The `Design` named export in FreeSewing's core library is a contructor that
creates new pattern designs.
2021-09-25 17:05:18 +02:00
## Signature
2021-09-25 17:05:18 +02:00
```js
Pattern Design({
array parts,
object data
})
```
## Example
2022-09-20 18:09:28 +02:00
```js
2022-09-20 18:09:28 +02:00
const Sorcha = new Design({
// design configuration here
})
```
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
Since a design's configuration is managed at the part level,
the Design configuration object only requires a `parts` property that should
2022-09-20 18:09:28 +02:00
hold an array of parts to include in the Design.
```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>
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: {
version: 3,
price: 12,
currency: 'euro'
2022-09-20 18:09:28 +02:00
}
})
```
## Notes
The Design constructor is a _super-constructor_.
2022-09-20 18:09:28 +02:00
It will return a constructor method that will a pattern based on your design.
## Properties
In addition to the returned constructor method, an instantiated Design object
also provides the following properties:
### Design.designConfig
This holds the design configuration as passed to the Design constructor.
### Design.patternConfig
Holds the resolved pattern configuration based on the configuration passed to the Design constructor.