1
0
Fork 0

chore(markdown): Work on macro reference docs

This commit is contained in:
Joost De Cock 2022-09-30 04:39:30 +02:00
parent 403f0c45c2
commit cfef146fd3
13 changed files with 416 additions and 129 deletions

View file

@ -5,17 +5,35 @@ title: grainline
The `grainline` macro adds a _grainline_ indicator to your pattern.
It is provided by the [grainline plugin](/reference/plugins/grainline/).
<Example part="plugin_grainline">
Example of the grainline indicator added by this macro
</Example>
## Signature
```js
macro("grainline", {
from: points.grainlineFrom,
to: points.grainlineTo,
macro('grainline', {
Point from,
Point to,
String text=grainline,
})
```
## Example
<Example caption="Example of the grainline indicator added by this macro">
```js
({ Point, macro, part }) => {
macro('grainline', {
from: new Point(0,0),
to: new Point(100,0),
})
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
|------------:|-------------|------------|----------------------------------------------|
| `from` | | [Point][1] | The startpoint of the _grainline_ indicator |
@ -24,7 +42,9 @@ macro("grainline", {
[1]: /reference/api/point
## Removing the grainline indicator
## Notes
### Removing the grainline indicator
If you inherit a part with a grainline indicator and you'd like to remove it,
you can do so by passing `false` to the macro:

View file

@ -2,21 +2,42 @@
title: hd
---
The `hd` macro adds a _horizontal dimension_ to your pattern.
The `hd` macro adds a _horizontal dimension_ to your pattern.
It is provided by the [dimension plugin](/reference/plugins/dimension/).
<Example part="point_dx">
An example of a horizontal dimension
</Example>
## Signature
```js
macro('hd', {
from: points.from,
to: points.to,
y: 25
String id,
Point from,
Boolean noEndtMarker,
Boolean noStartMarker,
String text,
Point to,
Number y,
})
```
## Example
<Example caption="An example of a horizontal dimension with the hd macro">
```js
({ Point, macro, part }) => {
macro('hd', {
from: new Point(0,0),
to: new Point(100,0),
y:15,
})
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
|----------------:|----------|---------------------|-------------|
| `from` | | [Point](/reference/api/point) | The startpoint of the dimension |
@ -27,11 +48,10 @@ macro('hd', {
| `noStartMarker` | `false` | Boolean | Whether to not draw a start marker |
| `noEndMarker` | `false` | Boolean | Whether to not draw an end marker |
<Note>
## Notes
Setting a custom ID will:
- Allow removal of the dimension with [the `rmd` macro](/reference/macros/rmd)
- Prevent removal of the dimension with [the `rmad` macro](/reference/macros/rmad/)
</Note>

View file

@ -5,18 +5,39 @@ title: ld
The `ld` macro adds a _linear dimension_ to your pattern.
It is provided by the [dimension plugin](/reference/plugins/dimension/).
<Example part="point_dist">
An example of a linear dimension
</Example>
## Signature
```js
macro('ld', {
from: points.from,
to: points.to,
d: 0
Number d,
String id,
Point from,
Boolean noEndtMarker,
Boolean noStartMarker,
String text,
Point to,
})
```
## Example
<Example caption="An example of a linear dimension with the ld macro">
```js
({ Point, macro, part }) => {
macro('ld', {
from: new Point(0,0),
to: new Point(100,20),
d:15,
})
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
|-----------------|---------|---------------------|-------------|
| `from` | | [Point](/reference/api/point) | The startpoint of the dimension |
@ -27,11 +48,9 @@ macro('ld', {
| `noStartMarker` | `false` | Boolean | Whether to not draw a start marker |
| `noEndMarker` | `false` | Boolean | Whether to not draw an end marker |
<Note>
## Notes
Setting a custom ID will:
- Allow removal of the dimension with [the `rmd` macro](/reference/macros/rmd)
- Prevent removal of the dimension with [the `rmad` macro](/reference/macros/rmad/)
</Note>

View file

@ -8,25 +8,42 @@ users to verify their pattern is printed to scale.
The `miniscale` macro is provided by the [scalebox plugin](/reference/plugins/scalebox).
It is the mini version of [the scalebox macro](/reference/macros/scalebox/).
<Example part="plugin_scalebox">
Example of a scalebox (left) and miniscale (right)
</Example>
## Signature
```js
macro('miniscale', {
at: points.anchor
Point at,
Number rotate,
})
```
## Example
<Example caption="An example of the miniscale macro">
```js
({ Point, macro, part }) => {
macro('miniscale', {
at: new Point(0,0),
})
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
|-------------|---------|---------------------|-------------|
| `at` | | [Point](/reference/api/point) | The point to anchor the _scale box_ on |
| `rotate` | 0 | Number | Rotation in degrees |
## Removing the miniscal
## Notes
If you inherit a part with a miniscale on it and you'd like to remove all points and paths
generated by the miniscale macro, you can do so by passing `false` to the macro:
If you inherit a part with a miniscale on it and you'd like to remove all
points and paths generated by the miniscale macro, you can do so by passing
`false` to the macro:
```js
macro('miniscale', false)

View file

@ -2,37 +2,53 @@
title: mirror
---
The `mirror` macro allows you to mirror points and/or paths around a mirror line.
It is provided by the [mirror plugin](/reference/plugins/mirror/).
The `mirror` macro allows you to mirror points and/or paths around a mirror
line. It is provided by the [mirror plugin](/reference/plugins/mirror/).
<Example part="plugin_mirror">
Example of the mirror plugin
</Example>
## Signature
```js
points.a = new Point(5,5)
points.b = new Point(45,30)
points.c = new Point(5,30)
points.d = new Point(45,5)
points.mid = new Point(25,15)
paths.a = new Path()
.move(points.a)
.curve(points.b, points.c, points.d)
macro('mirror', {
mirror: [points.b, points.d],
points: [points.mid],
paths: [paths.a]
})
macro('sprinkle', {
snippet: 'notch',
on: ['mid', 'mirroredMid']
Boolean clone,
Array mirror,
Function nameFormat,
Array paths,
Array points,
String prefix,
})
```
## Example
<Example caption="An example of the mirror macro">
```js
({ Point, points, Path, paths, macro, part }) => {
points.from = new Point(0,0)
points.cp1 = new Point(10,20)
points.cp2 = new Point(60,20)
points.to = new Point(70,0)
paths.example = new Path()
.move(points.from)
.curve(points.cp1, points.cp2, points.to)
macro('mirror', {
clone: true,
mirror: [
new Point(20,10),
new Point(20,20),
],
paths: Object.values(paths),
points: Object.values(points),
})
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
|-------------:|------------|------------|-------------|
| `mirror` | | `array` | Array with 2 [Point](/reference/api/point) objects that define the _mirror line_ |

View file

@ -2,20 +2,45 @@
title: pd
---
The `pd` macro adds a _path dimension_ to your pattern, indicating the length of a path.
It is provided by the [dimension plugin](/reference/plugins/dimension/).
The `pd` macro adds a _path dimension_ to your pattern, indicating the length
of a path. It is provided by the [dimension
plugin](/reference/plugins/dimension/).
<Example part="path_length">
Example of a multiple path dimensions
</Example>
## Signature
```js
macro('pd', {
path: paths.example,
d: -20
Number d,
String id,
Path path,
Boolean noEndtMarker,
Boolean noStartMarker,
String text,
})
```
## Example
<Example caption="An example of a path dimension with the pd macro">
```js
({ Point, Path, paths, macro, part }) => {
paths.example = new Path()
.move(new Point(0,0))
.curve(new Point(20,10), new Point(60,10), new Point(80,0))
macro('pd', {
path: paths.example,
d: 15,
})
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
|----------------:|---------|---------------------|-------------|
| `path` | | [Path](/reference/api/path) | The path to draw the dimension along |
@ -25,11 +50,9 @@ macro('pd', {
| `noStartMarker` | `false` | Boolean | Whether to not draw a start marker |
| `noEndMarker` | `false` | Boolean | Whether to not draw an end marker |
<Note>
## Notes
Setting a custom ID will:
- Allow removal of the dimension with [the `rmd` macro](/reference/macros/rmd)
- Prevent removal of the dimension with [the `rmad` macro](/reference/macros/rmad/)
</Note>

View file

@ -2,25 +2,40 @@
title: rmad
---
The `rmad` macro removes all dimensions with the exception of those that were created with a custom ID.
It is provided by the [dimension plugin](/reference/plugins/dimension/).
The `rmad` macro removes all dimensions with the exception of those that were
created with a custom ID. It is provided by the [dimension
plugin](/reference/plugins/dimension/).
To be able to use this plugin, you need to give your dimension an id:
## Signature
```js
// This will be removed
macro('ld', {
from: points.from,
to: points.to,
d: 0,
})
// This will not removed
macro('ld', {
from: points.from,
to: points.to,
d: 0,
id: 'example' // custom ID
})
macro('rmad')
```
## Example
<Example caption="An example of the rmad macro">
```js
({ Point, macro, part }) => {
// This will be removed
macro('ld', {
from: new Point(10, 0),
to: new Point(40, 0),
d: 5,
})
// This will not removed
macro('ld', {
from: new Point(10, 20),
to: new Point(80, 20),
d: 5,
id: 'example' // custom ID
})
macro('rmad')
return part
}
```
</Example>

View file

@ -7,22 +7,42 @@ It is provided by the [dimension plugin](/reference/plugins/dimension/).
To be able to use this plugin, you need to give your dimension an id:
## Signature
```js
macro('ld', {
from: points.from,
to: points.to,
d: 0,
id: 'example'
macro('rmd', {
String id
})
```
Now you can remove it as such:
## Example
<Example caption="An example of the rmd macro">
```js
macro('rmd', {
id: 'example'
})
({ Point, macro, part }) => {
macro('ld', {
from: new Point(10, 0),
to: new Point(40, 0),
d: 5,
id: 'da',
})
macro('ld', {
from: new Point(10, 20),
to: new Point(80, 20),
d: 5,
id: 'db',
})
macro('rmd', { id: 'db' })
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
|----------|---------|----------|-------------|

View file

@ -2,25 +2,44 @@
title: round
---
The `round` macro rounds a corner. It is provided by the [round plugin](/reference/plugins/round/).
The `round` macro rounds a corner. It is provided by the [round
plugin](/reference/plugins/round/).
Note that this is only intended for 90 degree corners.
<Example part="plugin_round">
Example of corners rounded with the round plugin
</Example>
## Signature
```js
macro('round', {
from: points.bottomRight,
to: points.topLeft,
via: points.topRight,
radius: 20,
prefix: 'tr',
render: true
macro('round', {
String class,
Point from,
Boolean hide,
String prefix,
Number radius,
Point to,
Point via,
})
```
## Example
<Example caption="An example of the round macro">
```js
({ Point, points, macro, part }) => {
macro('round', {
from: new Point(0, 0),
to: new Point(100, 40),
via: new Point(100, 0),
radius: 30,
hide: false,
})
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
|------------:|---------|---------------------|-------------|
| `from` | | [Point](/reference/api/point) | The startpoint towards the corner to round |
@ -28,5 +47,9 @@ macro('round', {
| `via` | | [Point](/reference/api/point) | The corner to round |
| `radius` | Maximum | Number | The radius in mm in not the maximum |
| `prefix` | | String | A prefix to give to the points and paths created by this macro |
| `render` | `false` | Boolean | Whether to render the path created by this macro |
| `hide` | `true` | Boolean | Whether to hide the path created by this macro |
| `class` | | String | Class(es) to assign to the path created by this macro |
## Notes
This macro is only intended for 90 degree corners.

View file

@ -2,21 +2,43 @@
title: scalebox
---
The `scalebox` macro adds a _scale box_ to your pattern. This box allows
users to verify their pattern is printed to scale.
The `scalebox` macro adds a _scale box_ to your pattern. This box allows users
to verify their pattern is printed to scale.
The `scalebox` macro is provided by the [scalebox plugin](/reference/plugins/scalebox).
The `scalebox` macro is provided by the [scalebox
plugin](/reference/plugins/scalebox).
<Example part="plugin_scalebox">
Example of the scalebox added by this macro
</Example>
## Signature
```js
macro('scalebox', {
at: points.anchor
Point at,
String lead,
Number rotate,
String text,
String title,
})
```
## Example
<Example caption="An example of the scalebox macro">
```js
({ Point, macro, part }) => {
macro('scalebox', {
at: new Point(0,0),
title: 'This is the title',
number: 666,
})
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
|-------------|---------|---------------------|-------------|
| `at` | | [Point](/reference/api/point) | The point to anchor the _scale box_ on |
@ -27,7 +49,9 @@ macro('scalebox', {
(\*) `freesewingIsMadeByJoostDeCockAndContributors \n withTheFinancialSupportOfOurPatrons`
## Removing the scalebox
## Notes
### Removing the scalebox
If you inherit a part with a scalebox on it and you'd like to remove all points and paths
generated by the scalebox macro, you can do so by passing `false` to the macro:

View file

@ -5,17 +5,48 @@ title: sprinkle
The `sprinkle` macro facilitates adding snippets to your pattern in bulk.
It is by the [sprinkle plugin](/reference/plugins/sprinkle).
<Example part="plugin_sprinkle">
Example of button snippets sprinkled on a pattern by this macro
</Example>
## Signature
```js
macro('sprinkle', {
snippet: 'button',
on: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
Array on,
Number scale,
Snippet snippet,
Number rotation,
})
```
## Example
<Example caption="An example of the sprinkle macro">
```js
({ Point, points, Path, paths, macro, part }) => {
points.a = new Point(0,0)
points.b = new Point(10,5)
points.c = new Point(20,0)
points.d = new Point(30,5)
points.e = new Point(40,0)
points.f = new Point(50,5)
points.g = new Point(60,0)
macro('sprinkle', {
snippet: 'button',
on: ['a', 'b', 'c', 'd', 'e', 'f', 'g']
})
// Prevent clipping
paths.diag = new Path()
.move(points.a)
.move(points.g)
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
|------------:|---------|------------------|-------------|
| `snippet` | | String | Name of the snippet to sprinkle |

View file

@ -5,7 +5,47 @@ title: title
The `title` macro adds a title to a pattern part.
It is provided by the [title plugin](/reference/plugins/title).
<Example part="plugin_title">Example of a title added by this macro</Example>
## Signature
```js
macro('title', {
Boolean append,
Point at,
String nr,
String prefix,
Number rotation,
Number scale,
String title,
})
```
## Example
<Example caption="An example of the title macro">
```js
({ Point, Path, paths, macro, store, part }) => {
// This is where name/version is supposed to be stored
store.set('data.version', 3)
store.set('data.name', 'Example')
macro('title', {
nr: 9,
title: 'The title',
at: new Point(0,0)
})
// Prevent clipping
paths.diag = new Path()
.move(new Point(0,-50))
.move(new Point(80,20))
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
| ----------:| :-----: | ------------------- | ----------- |

View file

@ -5,18 +5,39 @@ title: vd
The `vd` macro adds a _vertical dimension_ to your pattern.
It is provided by the [dimension plugin](/reference/plugins/dimension/).
<Example part="point_dy">
An example of a vertical dimension
</Example>
## Signature
```js
macro('vd', {
from: points.from,
to: points.to,
x: 25
String id,
Point from,
Boolean noEndtMarker,
Boolean noStartMarker,
String text,
Point to,
Number x,
})
```
## Example
<Example caption="An example of a vertical dimension with the vd macro">
```js
({ Point, macro, part }) => {
macro('vd', {
from: new Point(0,0),
to: new Point(0,40),
x:10,
})
return part
}
```
</Example>
## Configuration
| Property | Default | Type | Description |
|----------------:|---------|---------------------|-------------|
| `from` | | [Point](/reference/api/point) | The startpoint of the dimension |
@ -27,11 +48,9 @@ macro('vd', {
| `noStartMarker` | `false` | Boolean | Whether to not draw a start marker |
| `noEndMarker` | `false` | Boolean | Whether to not draw an end marker |
<Note>
## Notes
Setting a custom ID will:
- Allow removal of the dimension with [the `rmd` macro](/reference/macros/rmd)
- Prevent removal of the dimension with [the `rmad` macro](/reference/macros/rmad/)
</Note>