1
0
Fork 0
freesewing/markdown/dev/tutorials/pattern-design/your-first-part/en.md

78 lines
2.1 KiB
Markdown
Raw Normal View History

---
title: Your first part
order: 120
---
2022-02-20 14:35:50 +01:00
Much like garments themselves, patterns are made up of _parts_.
Most patterns will have multiple parts. A sleeve, a back part, the collar, and so on.
Our pattern is very simple, and only has one part: the bib.
The pattern that's been created for us also just has one part to get you started.
2022-07-02 22:52:31 +02:00
It's called **box** and it draws a box. If you click on the **To your design**
button in your browser, you'll get to see it:
![The default pattern with its box part](./step1.png)
2022-02-20 14:35:50 +01:00
Since we only need one part, we'll rename this _box_ part, and call it _bib_.
## Rename the box part to bib
2022-07-02 22:52:31 +02:00
First, update the configuration file in `design/config.js`.
Update the **parts** array with `bib`, rather than `box`:
```js
2022-07-02 22:52:31 +02:00
parts: ['bib'],
```
2022-02-19 08:04:25 +01:00
<Note>
2022-02-19 08:04:25 +01:00
##### Don't worry about the big red error
2022-02-19 08:04:25 +01:00
This will (temporarily) cause en error to appear in your development environment, because the rest of the code is still expecting to find a part named `box`, but we will fix this in the next steps.
</Note>
2022-07-02 22:52:31 +02:00
When that's done, rename the `design/src/box.js` file into `design/src/bib.js`.
2022-07-02 22:52:31 +02:00
Then, in the `design/src/index.js` file, change the import accordingly:
```js
// Change this line
//import draftBox from "./box"
// Into this
import draftBib from "./bib"
```
2022-07-02 22:52:31 +02:00
Finally, still in the `design/src/index.js` file, update the draft method:
```js
// Change this line
2022-07-02 22:52:31 +02:00
//Design.prototype.draftBox = draftBox
// Into this
2022-07-02 22:52:31 +02:00
Design.prototype.draftBib = draftBib
```
<Tip>
###### Always use draftPartname
2022-02-20 14:35:50 +01:00
FreeSewing will expect for each part to find a method named Draft\_Partname\_.
If you have a part named `sleeve` you should have a method called `draftSleeve()` that drafts that part.
In our case, we have a part named `bib` so we're using `draftBib()` as the method that drafts it.
</Tip>
2022-02-19 08:04:25 +01:00
Congratulations, your pattern now has a `bib` part, rather than a `box` part.
It still looks the same though:
<Example pattern="tutorial" part="step1">
Our bib part, which is the renamed box part
</Example>
This `bib` part is where we'll do some real work. But first, we have some more configuration to do.