1
0
Fork 0
freesewing/markdown/dev/reference/plugins/annotations/en.md

222 lines
6.2 KiB
Markdown
Raw Normal View History

2023-03-09 15:14:58 -06:00
---
title: plugin-annotations
2023-03-09 15:14:58 -06:00
---
Published as [@freesewing/plugin-annotations][1], this plugin provides a
variety of macros and snippets to annotate designs.
The annotations plugin provides the following snippets:
- [button](/reference/snippets/button)
- [buttonhole](/reference/snippets/button)
- [buttonhole-start](/reference/snippets/button)
- [buttonhole-end](/reference/snippets/button)
- [logo](/reference/snippets/logo)
- [notch](/reference/snippets/button)
- [bnotch](/reference/snippets/button)
The annotations plugin provides the following macros:
- [banner](/reference/macros/banner)
- [bannerbox](/reference/macros/bannerbox)
- [bartack](/reference/macros/bartack)
- [bartackAlong](/reference/macros/bartackalong)
- [bartackFractionAlong](/reference/macros/bartackfractionalong)
- [crossbox](/reference/macros/crossbox)
- [cutonfold](/reference/macros/cutonfold)
- [grainline](/reference/macros/grainline)
- [hd](/reference/macros/hd)
- [ld](/reference/macros/ld)
- [rmad](/reference/macros/rmad)
- [rmd](/reference/macros/rmd)
- [pd](/reference/macros/pd)
- [pleat](/reference/macros/pleat)
- [scalebox](/reference/macros/scalebox)
- [sewTogether](/reference/macros/setogether)
- [title](/reference/macros/title)
- [vd](/reference/macros/vd)
The annotations plugin also provides [methods to the Store for adding cutting instructions](#methods)
2023-03-09 15:14:58 -06:00
<Tip> For an in-depth look at how to add cutting instructions to your part, see our [cutlist how-to](/howtos/design/cutlist) </Tip>
2023-03-09 15:14:58 -06:00
## Installation
```sh
npm install @freesewing/plugin-annotations
2023-03-09 15:14:58 -06:00
```
## Usage
Either [add it as a part plugin](/reference/api/part/config/plugins) in your
design, or [add it to a pattern instance with
Pattern.use()](/reference/api/pattern/use).
To import the plugin for use:
```js
import { annotationsPlugin } from '@freesewing/plugin-banner'
2023-03-09 15:14:58 -06:00
// or
import { pluginAnnotations } from '@freesewing/plugin-banner'
2023-03-09 15:14:58 -06:00
```
## Methods
2023-03-12 11:35:19 -05:00
### store.cutlist.addCut
2023-03-09 15:14:58 -06:00
2023-03-12 11:35:19 -05:00
The `store.cutlist.addCut()` method will add a set of cutting instructions for the part
2023-03-09 15:14:58 -06:00
#### Signature
```js
2023-03-12 11:35:19 -05:00
store.cutlist.addCut(Object so)
2023-03-09 15:14:58 -06:00
````
2023-03-12 11:35:19 -05:00
Pass an object to the `store.cutlist.addCut` method with any of the following keys; any you don't provide will be filled with the defaults:
2023-03-09 15:14:58 -06:00
| Key | Type | Default | Description |
| :-- | :--- | :------ | :---------- |
| cut | Number\|false | 2 | the number of pieces to cut from the specified material. Pass `false` to clear all cutting instructions for the material |
| material | String | 'fabric' | the translation key of the material to cut from |
| identical | Boolean | false | should even numbers of pieces be cut in the same direction? false for mirrored |
| bias | Boolean | false | should the pieces in these cutting instructions be cut on the bias |
| ignoreOnFold | Boolean | false | should these cutting instructions ignore any cutOnFold information set by the part |
<Note>
<details>
<summary> You can use any `string` you want for your material, but here are some standard ones we have translation for </summary>
<div>
| Key | Translation |
|:--|:--|
| fabric | Main Fabric |
| lining | Lining |
| canvas | Canvas |
| lmhCanavas | Light to Medium Hair Canvas |
| heavyCanvas | Heavyweight Hair Canvas |
| interfacing | Interfacing |
| plastic | Plastic |
| ribbing | Ribbing |
</div>
</details>
</Note>
#### Example
```js
import {pluginCutlist} from '@freesewing/plugin-cutlist'
const part = {
name: 'example.front',
plugins: [pluginCutlist],
2023-03-12 11:35:19 -05:00
draft: ({part, store}) => {
2023-03-09 15:14:58 -06:00
// add instructions to cut two from main fabric
2023-03-12 11:35:19 -05:00
store.cutlist.addCut()
2023-04-12 14:47:59 +00:00
// add instructions to cut four on the bias from lining
2023-03-12 11:35:19 -05:00
store.cutlist.addCut({cut: 4, material: 'lining', bias: true, })
2023-03-09 15:14:58 -06:00
return part
}
}
```
You can also add multiple sets of cutting instructions for the same material
```js
import {pluginCutlist} from '@freesewing/plugin-cutlist'
const part = {
name: 'example.front',
plugins: [pluginCutlist],
2023-03-12 11:35:19 -05:00
draft: ({part, store}) => {
2023-03-09 15:14:58 -06:00
// add instructions to 1 from lining
2023-03-12 11:35:19 -05:00
store.cutlist.addCut({cut: 1, material: 'lining'})
2023-03-09 15:14:58 -06:00
// add instructions to cut 1 on the bias from lining
2023-03-12 11:35:19 -05:00
store.cutlist.addCut({cut: 1, material: 'lining', bias: true, })
2023-03-09 15:14:58 -06:00
return part
}
}
```
2023-03-12 11:35:19 -05:00
### store.cutlist.removeCut
2023-03-09 15:14:58 -06:00
2023-03-12 11:35:19 -05:00
The `store.cutlist.removeCut()` method will remove cutting instructions from the part
2023-03-09 15:14:58 -06:00
#### Signature
```js
2023-03-12 11:35:19 -05:00
store.cutlist.removeCut(String material)
2023-03-09 15:14:58 -06:00
```
#### Example
```js
import {pluginCutlist} from '@freesewing/plugin-cutlist'
const part = {
name: 'example.front',
plugins: [pluginCutlist],
2023-03-12 11:35:19 -05:00
draft: ({part, store}) => {
2023-03-09 15:14:58 -06:00
// remove all cutting instructions for all materials
2023-03-12 11:35:19 -05:00
store.cutlist.removeCut()
2023-03-09 15:14:58 -06:00
// remove cutting instructions for just one material
2023-03-12 11:35:19 -05:00
store.cutlist.removeCut('fabric')
2023-03-09 15:14:58 -06:00
return part
}
}
```
2023-03-12 11:35:19 -05:00
### store.cutlist.setGrain
2023-03-09 15:14:58 -06:00
2023-03-12 11:35:19 -05:00
The `store.cutlist.setGrain()` method will record the angle of the grainline annotation. This method is called internally by [`plugin-grainline`](/reference/plugins/grainline) to store information for cutting layout tools. You shouldn't have to call it, but it's there if you need it.
2023-03-09 15:14:58 -06:00
#### Signature
```js
2023-03-12 11:35:19 -05:00
store.cutlist.setGrain(Number grainAngle)
2023-03-09 15:14:58 -06:00
```
#### Example
```js
import {pluginCutlist} from '@freesewing/plugin-cutlist'
const part = {
name: 'example.front',
plugins: [pluginCutlist],
2023-03-12 11:35:19 -05:00
draft: ({part, store}) => {
2023-03-09 15:14:58 -06:00
// set the grainline angle
2023-03-12 11:35:19 -05:00
store.cutlist.setGrain(0)
2023-03-09 15:14:58 -06:00
return part
}
}
```
2023-03-12 11:35:19 -05:00
### store.cutlist.setCutOnFold
The `store.cutlist.setCutOnFold()` method will record the points that make up the cut on fold line. This method is called internally by [`plugin-cutonfold`](/reference/plugins/cutonfold) to store information for cutting layout tools. You shouldn't have to call it, but it's there if you need it.
2023-03-09 15:14:58 -06:00
#### Signature
```js
2023-03-12 11:35:19 -05:00
store.cutlist.setCutOnFold(Point p1, Point p2)
2023-03-09 15:14:58 -06:00
```
#### Example
```js
import {pluginCutlist} from '@freesewing/plugin-cutlist'
const part = {
name: 'example.front',
plugins: [pluginCutlist],
2023-03-12 11:35:19 -05:00
draft: ({part, points, Point, store}) => {
2023-03-09 15:14:58 -06:00
// set the cut on fold line
points.p1 = new Point(0, 0)
points.p2 = new Point(0, 10)
2023-03-12 11:35:19 -05:00
store.cutlist.setCutOnFold(points.p1, points.p2)
2023-03-09 15:14:58 -06:00
return part
}
}
```
## Notes
The annotations plugin is part of our [plugin-bundle](/reference/plugins/bundle)
2023-03-09 15:14:58 -06:00
[1]: https://www.npmjs.com/package/@freesewing/plugin-annotations