1
0
Fork 0

chore(markdown): Restructuring dev docs

This commit is contained in:
Joost De Cock 2021-12-27 17:33:49 +01:00
parent 9ef46c502a
commit d42d9a9377
114 changed files with 246 additions and 1462 deletions

View file

@ -0,0 +1,19 @@
---
title: dependencies
---
```js
dependencies: {
front: "back",
sleeveplacket: ["sleeve", "cuff"]
}
```
An object of `key`-`value` pairs that controls the order in which pattern parts will get drafted.
<Tip>
See [Part dependencies](/advanced/dependencies) for more in-depth information on dependencies.
</Tip>

View file

@ -0,0 +1,28 @@
---
title: Pattern configuration file
for: developers
about: Reference documentation for the pattern configuration file
---
```js
import { version } from '../package.json'
export default {
version,
name: "sorcha",
// More configuration here
}
```
A pattern configuration file exports a default object with the following properties:
<ReadMore list />
<Note>
This is about the pattern configuration file, used at build-time.
For run-time configuration, see [Pattern settings](/reference/settings/).
</Note>

View file

@ -0,0 +1,15 @@
---
title: hide
---
```js
hide: [
"base"
]
```
An array that lists pattern parts that should be hidden by default.
Hidden means that they will be drafted, but not rendered. Typically used
for a base part on which other parts are built.

View file

@ -0,0 +1,20 @@
---
title: inject
---
```js
inject: {
front: "back"
}
```
An object of key/value pairs of parts. The `value` part will be injected in the `key` part.
By *injected* we mean rather than starting out with a fresh part, you'll get a part that
has the points, paths, and snippets of the `value` part.
<Tip>
See [the Howto on Part inheritance](/howtos/code/inject) for an example.
</Tip>

View file

@ -0,0 +1,22 @@
---
title: measurements
---
```js
measurements: [
"bicepsCircumference",
"centerBackNeckToWaist"
]
```
An array with the names of the measurements required to draft this pattern.
<Note>
###### Don't just make up names
See [freesewing models](https://freesewing.dev/reference/packages/models)
for a list of measurement names already used in freesewing patterns.
It is a [best practice](/guides/best-practices/reuse-measurements/) to stick to these names.
</Note>

View file

@ -0,0 +1,9 @@
---
title: name
---
```js
name: "sorcha"
```
A string with the name of your pattern.

View file

@ -0,0 +1,21 @@
---
title: optionalMeasurements
---
```js
optionalMeasurements: [
'highBust'
]
```
An array with the names of optional measurements that can be used to draft this pattern.
<Note>
###### Why would you want optional measurements?
This is often used in combination with [the bust plugin](/reference/plugins/bust/) to
allow a pattern to be drafted to the `highBust` measurement rather than the
`chest` measurement, thereby providing better fit for people with breasts.
</Note>

View file

@ -0,0 +1,16 @@
---
title: boolean
---
If your option is either `true` or `false`, or **on** or **off** or **yes** or **no**, you can use a boolean:
Your boolean option should be an object with these properties:
- `bool` : Either `true` or `false` which will be the default
```js
options: {
withLining: { bool: true }
}
```

View file

@ -0,0 +1,231 @@
---
title: options
---
Options come in 6 varities:
- [Constants](#constants) : A value that can't be changed
- [Booleans](#booleans) : A value that is either `true` or `false`
- [Percentages](#percentages) : A value in percent, with minimum and maximum values
- [Millimeters](#millimeters) : A value in millimeter, with minimum and maximum values
- [Degrees](#degrees) : A value in degrees, with minimum and maximum values
- [Counters](#counters) : An integer value, with minimum and maximum values
- [Lists](#lists) : A list of options with a default
Under the hood, millimeters, degrees, and counters are handled the same way.
We use different types because it easier to understand the nature of a given option.
### Constants
If your option is a scalar value (like a string or a number), it will be treated as a constant:
```js
options: {
collarFactor: 4.8
}
```
Rather than define constants in your code, it's good practice to set them in your configuration file.
This way, people who extend your pattern can change them if they would like to.
### Booleans
If your option is either `true` or `false, or **on** or **off** or **yes** or **no**, you can use a boolean:
Your boolean option should be an object with these properties:
- `bool` : Either `true` or `false` which will be the default
```js
options: {
withLining: { bool: true }
}
```
### Percentages
Percentage options are the bread and butter of freesewing.
Almost all your options will probably be percentages.
They make sure that your pattern will scale regardless of size,
and pass [the ant-man test](https://github.com/freesewing/antman).
Your percentage option should be an object with these properties:
- `pct` : The percentage
- `min` : The minimul that's allowed
- `max` : The maximum that's allowed
```js
options: {
acrossBackFactor: {
pct: 97,
min: 93,
max: 100
}
}
```
<Note>
###### Percentage options will be divided by 100 when loaded
You specify percentages in your config file. For example, `50` means 50%.
When your configuration is loaded, those percentages will by divided by 100.
So a percentage of `50` in your config file will be `0.5` when you read out that option in your pattern.
</Note>
### Millimeters
While we recommend using percentages where possible, sometimes that doesn't make sense.
For those cases, you can use millimeters.
Your millimeter option should be an object with these properties:
- `mm` : The default value in millimeter
- `min` : The minimul that's allowed
- `max` : The maximum that's allowed
```js
options: {
elasticWidth: {
mm: 35,
min: 5,
max: 80
}
}
```
### Degrees
For angles, use degrees.
Your degree option should be an object with these properties:
- `deg` : The default value in degrees
- `min` : The minimul that's allowed
- `max` : The maximum that's allowed
```js
options: {
collarAngle: {
deg: 85,
min: 60
max: 130
}
}
```
### Counters
For a given number of things, use counters.
Counters are for integers only. Things like number of buttons and so on.
Your counter option should be an object with these properties:
- `count` : The default integer value
- `min` : The minimal integer value that's allowed
- `max` : The maximum integer value that's allowed
```js
options: {
butttons: {
count: 7,
min: 4,
max: 12
}
}
```
### Lists
Use a list option when you want to offer an array of choices.
Your list option should be an object with these properties:
- `dflt` : The default for this option
- `list` : An array of available values options
```js
options: {
cuffStyle: {
dflt: "angledBarrelCuff",
list: [
"roundedBarrelCuff",
"angledBarrelCuff"
"straightBarrelCuff"
"roundedFrenchCuff"
"angledFrenchCuff"
"straightFrenchCuff"
]
}
}
```
## Extra
Patterns also take these configuration options to facilitate frontend integration:
### design
The name of the designer:
```js
design: "Joost De Cock"
```
### code
The name of the developer:
```js
code: "Joost De Cock"
```
### type
Either `pattern` or `block`.
```js
type: "pattern"
```
### difficulty
A `1` to `5` difficulty score that indicates how hard it is to make the pattern:
```js
difficulty: 3
```
### tags
A set of tags to allow filtering of patterns on the website:
```js
tags: ["underwear", "top", "basics"],
```
### optionGroups
Organises your pattern options in groups. It expects an object where the key is the group title,
and the value an array of options:
```js
optionGroups: {
fit: ["chestEase", "hipsEase", "stretchFactor"],
style: [
"armholeDrop",
"backlineBend",
"necklineBend",
"necklineDrop",
"shoulderStrapWidth",
"shoulderStrapPlacement",
"lengthBonus"
]
}
```

View file

@ -0,0 +1,17 @@
---
title: constant
---
If your option is a scalar value (like a string or a number), it will be treated as a constant:
```js
options: {
collarFactor: 4.8
}
```
<Tip>
Rather than define constants in your code, it's good practice to set them in your configuration file.
This way, people who extend your pattern can change them if they would like to.
</Tip>

View file

@ -0,0 +1,22 @@
---
title: counter
---
For a given number of things, use a counter.
Counters are for integers only. Things like number of buttons and so on.
Your counter option should be an object with these properties:
- `count` : The default integer value
- `min` : The minimal integer value that's allowed
- `max` : The maximum integer value that's allowed
```js
options: {
butttons: {
count: 7,
min: 4,
max: 12
}
}
```

View file

@ -0,0 +1,21 @@
---
title: degrees
---
For angles, use degrees.
Your degree option should be an object with these properties:
- `deg` : The default value in degrees
- `min` : The minimul that's allowed
- `max` : The maximum that's allowed
```js
options: {
collarAngle: {
deg: 85,
min: 60
max: 130
}
}
```

View file

@ -0,0 +1,14 @@
---
title: options
---
Options come in 6 varities:
<ReadMore list />
<Note>
Under the hood, millimeters, degrees, and counters are handled the same way.
We use different types because it easier to understand the nature of a given option.
</Note>

View file

@ -0,0 +1,26 @@
---
title: list
---
Use a list option when you want to offer an array of choices.
Your list option should be an object with these properties:
- `dflt` : The default for this option
- `list` : An array of available values options
```js
options: {
cuffStyle: {
dflt: "angledBarrelCuff",
list: [
"roundedBarrelCuff",
"angledBarrelCuff"
"straightBarrelCuff"
"roundedFrenchCuff"
"angledFrenchCuff"
"straightFrenchCuff"
]
}
}
```

View file

@ -0,0 +1,31 @@
---
title: millimeter
---
While we recommend using percentages where possible, sometimes that doesn't make sense.
For those cases, you can use a millimeter option which
should be an object with these properties:
- `mm` : The default value in millimeter
- `min` : The minimul that's allowed
- `max` : The maximum that's allowed
```js
options: {
elasticWidth: {
mm: 35,
min: 5,
max: 80
}
}
```
<Tip>
##### When to use a millimeter option
You should only use millimeter when the option refers to a physical object
that comes in certain sizes.
</Tip>

View file

@ -0,0 +1,36 @@
---
title: percentage
---
Percentage options are the bread and butter of freesewing.
Almost all your options will probably be percentages.
They make sure that your pattern will scale regardless of size.
Your percentage option should be an object with these properties:
- `pct` : The percentage
- `min` : The minimul that's allowed
- `max` : The maximum that's allowed
```js
options: {
acrossBackFactor: {
pct: 97,
min: 93,
max: 100
}
}
```
<Note>
###### Percentage options will be divided by 100 when loaded
You specify percentages in your config file. For example, `50` means 50%.
When your configuration is loaded, those percentages will by divided by 100.
So a percentage of `50` in your config file will be `0.5` when you read out that option in your pattern.
</Note>

View file

@ -0,0 +1,23 @@
---
title: parts
---
```js
parts: [
"front",
"back"
]
```
An array that lists your (additional) pattern parts. The name must be the key the `pattern.parts` object.
<Tip>
###### This does not need to be an exhaustive list of all parts in your pattern.
This list of parts is needed for the `draft()` method to figure out what
parts need to be drafted.
So if parts are included in the `dependencies`, `inject`, or `hide` configuration,
there's no need to include them here, as we already know of their existence.
</Tip>

View file

@ -0,0 +1,10 @@
---
title: code
---
```js
code: "Joost De Cock",
```
The name of the developer.

View file

@ -0,0 +1,14 @@
---
title: department
---
```js
department: "menswear",
```
One of the following:
- menswear
- womenswear
- unisex
- accessories

View file

@ -0,0 +1,9 @@
---
title: design
---
```js
design: "Joost De Cock",
```
The name of the designer.

View file

@ -0,0 +1,9 @@
---
title: difficulty
---
```js
difficulty: 3
```
A `1` to `5` difficulty score that indicates how hard it is to make the pattern.

View file

@ -0,0 +1,14 @@
---
title: UI configuration
order: 100
---
Patterns also take these configuration options to facilitate UI integration:
<ReadMore list />
<Tip>
UI = User Interface. Like a website or mobile app
</Tip>

View file

@ -0,0 +1,20 @@
---
title: The advanced option group
---
Naming an option group `advanced` will hide it by default from the user
unless they enable *expert mode*.
```js
optionGroups: {
fit: ["chestEase", "hipsEase", "stretchFactor"],
style: ["armholeDrop", "backlineBend"],
advanced: [ "plutoniumCount" ]
}
```
<Tip>
The `advanced` option group can also have nested groups
</Tip>

View file

@ -0,0 +1,29 @@
---
title: optionGroups
---
Organises your pattern options in groups.
It expects an object where the key is the group title, and the value an array of options:
```js
optionGroups: {
fit: ["chestEase", "hipsEase", "stretchFactor"],
style: [
"armholeDrop",
"backlineBend",
"necklineBend",
"necklineDrop",
"shoulderStrapWidth",
"shoulderStrapPlacement",
"lengthBonus"
]
}
```
<Note>
Options that are not included in the `optionGroup` configuration won't be
exposed in the frontend and thus will be unavailable to the user.
</Note>

View file

@ -0,0 +1,27 @@
---
title: Nested option groups
---
You can create sub-groups within an option group:
```js
optionGroups: {
style: [
'hemStyle',
'hemCurve',
{
closure: [
'extraTopButton',
'buttons',
'buttonFreeLength'
]
},
]
}
```
<Warning>
Only create subgroups one level deep.
We do not support groups in groups in groups.
</Warning>

View file

@ -0,0 +1,9 @@
---
title: tags
---
```js
tags: ["underwear", "top", "basics"],
```
A set of tags to allow filtering of patterns on the website.

View file

@ -0,0 +1,12 @@
---
title: type
---
```js
type: "pattern",
```
One of the following:
- pattern
- block

View file

@ -0,0 +1,10 @@
---
title: version
---
```
version: "0.3.1"
```
The version of your pattern.

View file

@ -1,10 +1,5 @@
---
title: Core API
for: developers
icons:
- javascript
- terms
about: FreeSewing's core API reference documents all available methods and objects
title: "@freesewing/core API"
---
This is the documentation for FreeSewing's core library, published as `@freesewing/core` on NPM.

View file

@ -0,0 +1,17 @@
---
title: Hooks API
for: developers
about: Documents the available lifecycle hooks in Core and how to use them
---
A **hook** is a lifecycle event.
You can register a method for a hook. When the hook is triggered, your method will be
called. It will receive two parameters:
- An object relevant to the hook (see the specific hook for details)
- Data passed when the hook was registered (optional)
Below is a list of all available hooks:
<ReadMore list />

View file

@ -0,0 +1,47 @@
---
title: insertText
---
The `insertText` hook is called when text is about to be inserted during rendering.
Methods attached to the `insertText` hook will receive 2 parameters:
- `locale` : The language code of the language requested by the user (defaults to `en`)
- `text`: The text to be inserted
Unlike most hooks that receive an object that you can make changes to,
for this hook you need to return a string.
This hook is typically used for translation, as is the case
in [our i18n plugin](/reference/plugins/i18n/).
## Understanding the insertText hook
When we say that *this hook is called when text is about to be inserted*, that is a simplified view.
In reality, this hook is called:
- For every value set on data-text
- For the combined result of these values, joined together with spaces
Let's use an example to clarify things:
```js
points.example
.attr('data-text', "seamAllowance")
.attr('data-text', ": 1cm")
```
For the example point above, the `insertText` hook will end up being called 3 times:
- First it will pass `seamAllowance` to the plugin
- Then it will pass `: 1cm` to the plugin
- Finally it will pass `seamAllowance : 1cm` to the plugin
Having the `insertText` hook only run once with `Seam allowance: 1cm` would be problematic because
the seam allowance may differ, or perhaps we're using imperial units, and so on.
Instead, you can (and should) divide your text into chunks that need translating, and chunks that do not.
This is also why we're not inserting **Seam allowance** but rather **seamAllowance**;
It is merely a key to indicate what translation we want to replace this text with.

View file

@ -0,0 +1,13 @@
---
title: postDraft
---
The `postDraft` hook runs just after your pattern is drafted.
Your plugin will receive the Pattern object.
<Note>
The `postDraft` hook is rarely used.
</Note>

View file

@ -0,0 +1,14 @@
---
title: postRender
---
The `postRender` hook is triggered after the SVG is rendered.
Like the `preRender` hook, it receives [the SVG object](/api/svg) as its first parameter.
<Note>
The `postRender` hooks is rarely used.
</Note>

View file

@ -0,0 +1,19 @@
---
title: postSample
---
The `postSample` hook runs just after your pattern is sampled.
Your plugin will receive the Pattern object.
It is triggered just before the end of either:
- the [Pattern.sampleOption()](/reference/api/pattern/#sampleoption) method
- the [Pattern.sampleMeasurement()](/reference/api/pattern/#samplemeasurement) method
- the [Pattern.sampleModels()](/reference/api/pattern/#samplemodels) method
<Note>
The `postSample` hook is rarely used.
</Note>

View file

@ -0,0 +1,13 @@
---
title: preDraft
---
The `preDraft` hook runs just before your pattern is drafted.
Your plugin will receive the Pattern object.
<Note>
The `preDraft` hook is rarely used.
</Note>

View file

@ -0,0 +1,9 @@
---
title: preRender
---
The `preRender` hook is triggered just before your pattern is rendered to SVG.
Your hook method will receive [the SVG object](/api/svg) as its first parameter.
It is typically used to change the result of the render, for example by adding CSS to the SVG output.

View file

@ -0,0 +1,19 @@
---
title: preSample
---
The `preSample` hook runs just before your pattern is sampled.
It is triggered at the very start of either:
- the [Pattern.sampleOption()](/reference/api/pattern/#sampleoption) method
- the [Pattern.sampleMeasurement()](/reference/api/pattern/#samplemeasurement) method
- the [Pattern.sampleModels()](/reference/api/pattern/#samplemodels) method
Your plugin will receive the Pattern object.
<Note>
The `preSample` hook is rarely used.
</Note>

View file

@ -0,0 +1,28 @@
---
title: bartack
---
The `bartack` macro allows you to add a *bartack* marker to your sewing pattern.
It is provided by the [bartack plugin](/reference/plugins/bartack/).
<Example part="plugin_bartack" caption="Example of the bartack macro" />
```js
points.a = new Point(15, 15)
macro('bartack', {
anchor: points.a,
angle: 30,
length: 15
})
```
| Property | Default | Type | Description |
|-------------:|------------|------------|-------------|
| `angle` | `0` | `number` | The angle under which to draw the bartack |
| `density` | `3` | `number` | Controls how close the stitches are togeter |
| `length` | `15` | `number` | Length of the bartack |
| `nameFormat` | | `function` | A method that receives the name of the path or point and should return the name for the cloned path and or point |
| `prefix` | | `string` | A prefix to apply to the names of the generated path and points |
| `suffix` | | `string` | A suffix to apply to the names of the generated path and points |
| `width` | `3` | `number` | Width of the bartack |

View file

@ -0,0 +1,44 @@
---
title: bartackAlong
---
The `bartackAlong` macro allows you to add a *bartack* marker to your sewing pattern.
More specifically, a bartack along a path.
It is provided by the [bartack plugin](/reference/plugins/bartack/).
<Example part="plugin_bartackalong" caption="Example of the bartackAlong macro" />
```js
points.a = new Point(15, 15)
points.b = new Point(20, 20)
points.c = new Point(30, 20)
points.d = new Point(35, 15)
points.e = new Point(20, 10)
points.f = new Point(30, 10)
paths.a = new Path()
.move(points.a)
.curve(points.b, points.c, points.d)
.setRender(false)
macro('bartackAlong', {
path: paths.a
})
macro('sprinkle', {
snippet: 'notch',
on: ['e', 'f']
})
```
| Property | Default | Type | Description |
|-------------:|------------|------------|-------------|
| `angle` | `0` | `number` | The angle under which to draw the bartack |
| `density` | `3` | `number` | Controls how close the stitches are togeter |
| `length` | `15` | `number` | Length of the bartack |
| `nameFormat` | | `function` | A method that receives the name of the path or point and should return the name for the cloned path and or point |
| `path` | | `Path` | The path the bartack should follow |
| `prefix` | | `string` | A prefix to apply to the names of the generated path and points |
| `suffix` | | `string` | A suffix to apply to the names of the generated path and points |
| `width` | `3` | `number` | Width of the bartack |

View file

@ -0,0 +1,48 @@
---
title: bartackFractionAlong
---
The `bartackFractionAlong` macro allows you to add a *bartack* marker to your sewing pattern.
More specifically, a bartack along a fraction of a path.
It is provided by the [bartack plugin](/reference/plugins/bartack/).
<Example part="plugin_bartackfractionalong" caption="Example of the bartackFractionAlong macro" />
```js
points.a = new Point(15, 15)
points.b = new Point(20, 20)
points.c = new Point(30, 20)
points.d = new Point(35, 15)
points.e = new Point(20, 10)
points.f = new Point(30, 10)
paths.a = new Path()
.move(points.a)
.curve(points.b, points.c, points.d)
.setRender(false)
macro('bartackAlong', {
path: paths.a,
start: 0.2,
end: 0.8
})
macro('sprinkle', {
snippet: 'notch',
on: ['e', 'f']
})
```
| Property | Default | Type | Description |
|-------------:|------------|------------|-------------|
| `angle` | `0` | `number` | The angle under which to draw the bartack |
| `density` | `3` | `number` | Controls how close the stitches are togeter |
| `end` | `1` | `number` | At which fraction of the path length (from `0` to `1`) should the bartack end |
| `length` | `15` | `number` | Length of the bartack |
| `nameFormat` | | `function` | A method that receives the name of the path or point and should return the name for the cloned path and or point |
| `path` | | `Path` | The path the bartack should follow |
| `prefix` | | `string` | A prefix to apply to the names of the generated path and points |
| `start` | `0` | `number` | At which fraction of the path length (from `0` to `1`) should the bartack start |
| `suffix` | | `string` | A suffix to apply to the names of the generated path and points |
| `width` | `3` | `number` | Width of the bartack |

View file

@ -0,0 +1,35 @@
---
title: cutonfold
---
The `cutonfold` macro adds a *cut on fold* indicator to your pattern.
It is provided by the [cutonfold plugin](/reference/plugins/cutonfold).
<Example part="plugin_cutonfold" caption="Example of the cut on fold indicator added by this macro" />
```js
macro('cutonfold', {
from: points.cofLeft,
to: points.cofRight,
grainline: true
}
```
| Property | Default | Type | Description |
|------------:|---------|---------------------|-------------|
| `from` | | [Point](/reference/api/point) | The startpoint of the *cut on fold* indicator |
| `to` | | [Point](/reference/api/point) | The endpoint of the *cut on fold* indicator |
| `margin` | 5 | [Point](/reference/api/point) | The distance in % to keep from the start/end edge |
| `offset` | 50 | Number | The distance in mm to offset from the line from start to end |
| `grainline` | `false` | Boolean | Whether this cutonfold indicator is also the grainline |
<Note>
###### It's safe to use a corner of your pattern part for this
Since this is typically used on corners, the generated cut-on-fold indicator
will not go all the way to the `to` and `from` points.
</Note>

View file

@ -0,0 +1,22 @@
---
title: Macros
for: developers
about: Complete list of all available macros and how to use them
---
Macros are a way to combine different operations into a single command,
and are typically provided by plugins.
Below is a list of available macros:
<ReadMore list />
<Note>All macros take a single object as their configuration. </Note>
<Tip>
For more info on a specific macro and examples, follow the link to the plugin that provides the macro.
</Tip>

View file

@ -0,0 +1,18 @@
---
title: flip
---
The `flip` macro flips (mirrors) an entire part vertically around the Y-axis.
It takes no arguments, and is provided by the [flip plugin](/reference/plugins/flip).
```js
macro("flip")
```
Under the hood, this macro will:
- Go through all Points in your Part, and multiply their X-coordinate by -1
- Go through all the Paths in your Part, and for each drawing operation will multiply the X-coordinare by -1
- Go through all the Snippets in your Part and multiply the X-coordinate of the anchor point by -1

View file

@ -0,0 +1,21 @@
---
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" caption="Example of the grainline indicator added by this macro" />
```js
macro("grainline", {
from: points.grainlineFrom,
to: points.grainlineTo,
}
```
| Property | Default | Type | Description |
|------------:|---------|---------------------|-------------|
| `from` | | [Point](/reference/api/point) | The startpoint of the *grainline* indicator |
| `to` | | [Point](/reference/api/point) | The endpoint of the *grainline* indicator |

View file

@ -0,0 +1,39 @@
---
title: hd
---
The `hd` macro adds a *horizontal dimension* to your pattern.
It is provided by the [dimension plugin](/reference/plugins/dimension/).
<Example
part="point_dx"
caption="An example of a horizontal dimension"
/>
```js
macro('hd', {
from: points.from,
to: points.to,
y: 25
})
```
| Property | Default | Type | Description |
|----------------:|----------|---------------------|-------------|
| `from` | | [Point](/reference/api/point) | The startpoint of the dimension |
| `to` | | [Point](/reference/api/point) | The endpoint of the dimension |
| `y` | | Number | The Y-value at which to draw the dimension |
| `id` | auto-assigned | String | A custom ID under wich paths and points will be created |
| `text` | Horizontal distance | Number | The text to go on the dimension if not the from-to horizontal distance |
| `noStartMarker` | `false` | Boolean | Whether to not draw a start marker |
| `noEndMarker` | `false` | Boolean | Whether to not draw an end marker |
<Note>
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

@ -0,0 +1,40 @@
---
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"
caption="An example of a linear dimension"
/>
```js
macro('ld', {
from: points.from,
to: points.to,
d: 0
})
```
| Property | Default | Type | Description |
|-----------------|---------|---------------------|-------------|
| `from` | | [Point](/reference/api/point) | The startpoint of the dimension |
| `to` | | [Point](/reference/api/point) | The endpoint of the dimension |
| `d` | 0 | Number | The offset at which to draw the dimension |
| `id` | auto-assigned | String | A custom ID under wich paths and points will be created |
| `text` | Linear distance | Number | The text to go on the dimension if not the from-to linear distance |
| `noStartMarker` | `false` | Boolean | Whether to not draw a start marker |
| `noEndMarker` | `false` | Boolean | Whether to not draw an end marker |
<Note>
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

@ -0,0 +1,24 @@
---
title: miniscale
---
The `miniscale` macro adds a mini *scale box* to your pattern. This box allows
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" caption="Example of a scalebox (left) and miniscale (right)" />
```js
macro('miniscale', {
at: points.anchor
})
```
| Property | Default | Type | Description |
|-------------|---------|---------------------|-------------|
| `at` | | [Point](/reference/api/point) | The point to anchor the *scale box* on |
| `rotate` | 0 | Number | Rotation in degrees |

View file

@ -0,0 +1,42 @@
---
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/).
<Example part="plugin_mirror" caption="Example of the mirror plugin" />
```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']
})
```
| Property | Default | Type | Description |
|-------------:|------------|------------|-------------|
| `mirror` | | `array` | Array with 2 [Point](/reference/api/point) objects that define the *mirror line* |
| `clone` | `true` | `bool` | Whether to clone mirrored points and or paths |
| `points` | | `array` | An array of [Point](/reference/api/point) objects |
| `paths` | | `array` | An array of [Path](/reference/api/path) objects |
| `prefix` | `mirrored` | `string` | A prefix to apply to the names of the clones points and or paths. Ignored if `nameFormat` is set |
| `nameFormat` | | `function` | A method that receives the name of the path or point and should return the name for the cloned path and or point |

View file

@ -0,0 +1,35 @@
---
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/).
<Example part="path_length" caption="Example of a multiple path dimensions" />
```js
macro('pd', {
path: paths.example,
d: -20
})
```
| Property | Default | Type | Description |
|----------------:|---------|---------------------|-------------|
| `path` | | [Path](/reference/api/path) | The path to draw the dimension along |
| `offset` | 0 | Number | The offset at which to draw the dimension |
| `text` | Path length | Number | The text to go on the dimension if not the length of the path |
| `id` | auto-assigned | String | A custom ID under wich paths and points will be created |
| `noStartMarker` | `false` | Boolean | Whether to not draw a start marker |
| `noEndMarker` | `false` | Boolean | Whether to not draw an end marker |
<Note>
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

@ -0,0 +1,26 @@
---
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/).
To be able to use this plugin, you need to give your dimension an id:
```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')
```

View file

@ -0,0 +1,30 @@
---
title: rmd
---
The `rmd` macro removes a dimension.
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:
```js
macro('ld', {
from: points.from,
to: points.to,
d: 0,
id: 'example'
})
```
Now you can remove it as such:
```js
macro('rmd', {
id: 'example'
})
```
| Property | Default | Type | Description |
|----------|---------|----------|-------------|
| `id` | | `string` | The id of the dimension to remove |

View file

@ -0,0 +1,31 @@
---
title: 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" caption="Example of corners rounded with the round plugin" />
```js
macro('round', {
from: points.bottomRight,
to: points.topLeft,
via: points.topRight,
radius: 20,
prefix: 'tr',
render: true
})
```
| Property | Default | Type | Description |
|------------:|---------|---------------------|-------------|
| `from` | | [Point](/reference/api/point) | The startpoint towards the corner to round |
| `to` | | [Point](/reference/api/point) | The endpoint away from the corner to 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 |
| `class` | | String | Class(es) to assign to the path created by this macro |

View file

@ -0,0 +1,27 @@
---
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 is provided by the [scalebox plugin](/reference/plugins/scalebox).
<Example part="plugin_scalebox" caption="Example of the scalebox added by this macro" />
```js
macro('scalebox', {
at: points.anchor
})
```
| Property | Default | Type | Description |
|-------------|---------|---------------------|-------------|
| `at` | | [Point](/reference/api/point) | The point to anchor the *scale box* on |
| `lead` | FreeSewing | String | The lead text above the title |
| `title` | *pattern name + version* | String | The title text |
| `text` | (\*) | String | The text below the title |
| `rotate` | 0 | Number | Rotation in degrees |
(\*) `freesewingIsMadeByJoostDeCockAndContributors \n withTheFinancialSupportOfOurPatrons`

View file

@ -0,0 +1,22 @@
---
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" caption="Example of button snippets sprinkled on a pattern by this macro" />
```js
macro('sprinkle', {
snippet: 'button',
on: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
})
```
| Property | Default | Type | Description |
|------------:|---------|------------------|-------------|
| `snippet` | | String | Name of the snippet to sprinkle |
| `on` | `[]` | Array of strings | An array with **the names** of points to add the snippet on |

View file

@ -0,0 +1,19 @@
---
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" caption="Example of a title added by this macro" />
| Property | Default | Type | Description |
| ----------:| :-----: | ---------------------------------------------------------- |
| `at` | | [Point](/reference/api/point) | The point at which to insert the title |
| `nr` | | String | The number of the pattern part |
| `title` | | String | The name of the pattern part. If title is not set or is an empty string, this won't be rendered, and the version will go beneath the nr.|
| `prefix` | | String | A prefix to add to the created points. This allow for more than 1 title per part, as long as you give them a different prefix.|
| `append` | `false` | Boolean | Set this to `true` to append the `nr` to any text already set in Point `at`'s attributes, rather than overwrite it |
| `rotation` | 0 | Number | An optional rotation in degrees |
| `scale` | 1 | Number | An optional scaling factor |

View file

@ -0,0 +1,41 @@
---
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"
caption="An example of a vertical dimension"
/>
```js
macro('vd', {
from: points.from,
to: points.to,
x: 25
})
```
| Property | Default | Type | Description |
|----------------:|---------|---------------------|-------------|
| `from` | | [Point](/reference/api/point) | The startpoint of the dimension |
| `to` | | [Point](/reference/api/point) | The endpoint of the dimension |
| `x` | | Number | The X-value at which to draw the dimension |
| `text` | Vertical distance | Number | The text to go on the dimension if not the from-to vertical distance |
| `id` | auto-assigned | String | A custom ID under wich paths and points will be created |
| `noStartMarker` | `false` | Boolean | Whether to not draw a start marker |
| `noEndMarker` | `false` | Boolean | Whether to not draw an end marker |
<Note>
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

@ -0,0 +1,16 @@
---
title: complete
---
Set this to `false` to draft a base outline of the pattern, rather than a fully detailed pattern.
This has different uses, such as generating patterns to be cut out with a laser cutter.
The default is `true`. Setting this to `false` will force [sa](#sa) to be set to `false`.
```js
import brian from "@freesewing/brian";
let pattern = new brian({
complete: false
})
```

View file

@ -0,0 +1,23 @@
---
title: embed
---
Set to `true` to make SVG output suitable for embedding in a web page.
This removes the `width` and `height` attributes from the SVG tag, which allows
you to inject the SVG into an HTML document, and it will responsively scale.
```js
import brian from "@freesewing/brian";
let pattern = new brian({
embed: true
})
```
<Warning>
Do **not** use this for SVGs you want to print.
</Warning>

View file

@ -0,0 +1,14 @@
---
title: Settings
for: developers
about: Documents all the settings your pattern can receive, including the pattern options, measurmeents, and design options
---
Settings are what the user passes to your pattern at run-time.
Don't confuse them with the [pattern configuration](/reference/config/) that is determined by
the designer at build-time.
Below are the supported settings:
<ReadMore list />

View file

@ -0,0 +1,18 @@
---
title: idPrefix
---
Prefixes all IDs in the SVG with the string you pass it. (defaults to `fs-`).
When you embed multiple SVGs on a single page, the IDs can and will conflict,
especially when using `xlink:href` references (such as for text on paths and snippets).
This allows you to specify an ID prefix so you can sidestep ID collisions.
```js
import brian from "@freesewing/brian";
let pattern = new brian({
idPrefix: "something-else"
})
```

View file

@ -0,0 +1,72 @@
---
title: layout
---
Allows you to control the way pattern parts are laid out on the pattern.
There are 3 scenarios:
- layout is truthy: Do layout algorithmically
- layout is falsy: Do not do any layout apart from stacking all parts together
- layout is an object: Layout the parts as detailed in the layout object
Let's look at each in detail:
##### layout is truthy
This is the default behaviour. Parts will be laid without overlap in
a space that's a small as possible.
Don't expect miracles here.
It's one of those things humans are far better at than
computers.
##### layout is falsy
This will cause all parts to be laid out on top of each other.
It is almost certainly not what you want, but having all parts piled
on top of each other in the top left corner can be a good starting
point for a custom layout.
##### layout is a layout object
This allows you to control the layout by passing a layout object.
This object should be structures as such:
```js
import brian from "@freesewing/brian";
let pattern = new brian({
layout: {
parts: {
front: {
move: {
x: 14,
y: -202
}
},
back: {
rotate: 90,
flipX: true,
flipY, true
}
}
}
});
```
For each part in the `parts` attribute of our layout object, there are 4 possible attributes:
- move: Expects an object with an `x` and `y` property, and will move the part by `x` along the X-axis and by `y` along the Y-axis
- rotate: Expects a number, and will rotate the part by number degrees around its center point
- flipX: Will flip/mirror the part horizontally
- flipY: Will flip/mirror the part vertically
<Note>
It is a long-standing ambition of ours to build a layout component that allows
users to manually do the layout of their pattern.
Core already supports it, but building a React component for it is non-trivial.
</Note>

View file

@ -0,0 +1,16 @@
---
title: locale
---
A 2-letter language code that indicates what language the user wants.
This will be used to set the `xml:lang` attribute in the `svg` tag when rendering to SVG,
and by [the i18n plugin](/reference/plugins/i18n/) to translate the pattern.
```js
import brian from "@freesewing/brian";
let pattern = new brian({
locale: "es"
})
```

View file

@ -0,0 +1,31 @@
---
title: margin
---
Allows you to specify a part margin (in mm). The default is 2mm.
Each part will have this margin applied. This means that:
- At the edge of the SVG, the margin will be `margin * 1` (2mm by default)
- Between parts, the margin will be `margin * 2` (4mm by default)
Note that setting the margin to zero (or below) will cause parts to overlap.
```js
import brian from "@freesewing/brian";
let pattern = new brian({
margin: 5
})
```
<Note>
###### For paperless, the minimal margin is 10mm
In paperless mode, the margin will not go below 10mm.
That is because text is not taken into account when calculating the bounding box of the part.
Since dimensions are typically the outermost elements in a paperless part,
a too narrow margin would cause the dimension text to get cut off.
</Note>

View file

@ -0,0 +1,17 @@
---
title: measurements
---
The measurements to draft for. The pattern configuration lists all required measurements.
```js
import brian from "@freesewing/brian";
let pattern = new brian({
measurements: {
chestCircumference: 1080
shoulderSlope: 55
}
})
```

View file

@ -0,0 +1,15 @@
---
title: only
---
Allows you to specify one or more parts to draft/render, rather than the entire pattern.
Accepts a part name as string, or an array of part names.
```js
import brian from "@freesewing/brian";
let pattern = new brian({
only: ["front", "sleeve"]
})
```

View file

@ -0,0 +1,18 @@
---
title: options
---
The pattern options as specified in the pattern configuration.
```js
import brian from "@freesewing/brian";
let pattern = new brian({
options: {
chestEase: 120
}
})
```
<Note>Unlike measurements, options come with defaults.</Note>

View file

@ -0,0 +1,14 @@
---
title: paperless
---
Set this to `true` to draft a paperless pattern. The default is `false`.
```js
import brian from "@freesewing/brian";
let pattern = new brian({
paperless: true
})
```

View file

@ -0,0 +1,22 @@
---
title: sa
---
The seam allowance in mm.
Not setting this, setting it to `false`, or to zero, will draft a pattern without seam allowance.
```js
import brian from "@freesewing/brian";
let pattern = new brian({
sa: 10
})
```
<Note>
This is ignored if [settings.complete](#complete) is `false`
</Note>

View file

@ -0,0 +1,15 @@
---
title: units
---
Either `metric` (the default) or `imperial`.
Note that this is only used to format the output. Freesewing expects mm.
```js
import brian from "@freesewing/brian";
let pattern = new brian({
units: "imperial"
})
```

View file

@ -0,0 +1,15 @@
---
title: bnotch
---
The `bnotch` snippet is intended for notches at the back, or when you
need an alternative to the default `notch`.
It is provided by [plugin-theme](/reference/plugins/theme/).
```js
snippets.demo = new Snippet('bnotch', points.anchor)
```
<Example part="snippets_bnotch">An example of the bnotch snippet</Example>

View file

@ -0,0 +1,13 @@
---
title: button
---
The `button` snippet is used to mark button placement and is
provided by [plugin-buttons](/reference/plugins/buttons/).
```js
snippets.demo = new Snippet('button', points.anchor)
```
<Example part="snippets_button" caption="An example of the button snippet" />

View file

@ -0,0 +1,24 @@
---
title: buttonhole-end
---
The `buttonhole-end` snippet is used to mark buttonhole placement and is
provided by [plugin-buttons](/reference/plugins/buttons/).
```js
snippets.demo = new Snippet('buttonhole-end', points.anchor)
```
<Example part="snippets_buttonhole_end" caption="An example of the buttonhole-end snippet" />
<Note>
##### Aligning your buttons and buttonholes
We provide three buttonhole snippets with a different alignment:
- [buttonhole](/reference/snippets/buttonhole/): Anchor point is the middle of the buttonhole
- [buttonhole-start](/reference/snippets/buttonhole-start/): Anchor point is the start of the buttonhole
- [buttonhole-end](/reference/snippets/buttonhole-end/): Anchor point is the end of the buttonhole
</Note>

View file

@ -0,0 +1,24 @@
---
title: buttonhole-start
---
The `buttonhole-start` snippet is used to mark buttonhole placement and is
provided by [plugin-buttons](/reference/plugins/buttons/).
```js
snippets.demo = new Snippet('buttonhole-start', points.anchor)
```
<Example part="snippets_buttonhole_start" caption="An example of the buttonhole-start snippet" />
<Note>
##### Aligning your buttons and buttonholes
We provide three buttonhole snippets with a different alignment:
- [buttonhole](/reference/snippets/buttonhole/): Anchor point is the middle of the buttonhole
- [buttonhole-start](/reference/snippets/buttonhole-start/): Anchor point is the start of the buttonhole
- [buttonhole-end](/reference/snippets/buttonhole-end/): Anchor point is the end of the buttonhole
</Note>

View file

@ -0,0 +1,25 @@
---
title: buttonhole
---
The `buttonhole` snippet is used to mark buttonhole placement and is
provided by [plugin-buttons](/reference/plugins/buttons/).
```js
snippets.demo = new Snippet('buttonhole', points.anchor)
```
<Example part="snippets_buttonhole" caption="An example of the buttonhole snippet" />
<Note>
##### Aligning your buttons and buttonholes
We provide three buttonhole snippets with a different alignment:
- [buttonhole](/reference/snippets/buttonhole/): Anchor point is the middle of the buttonhole
- [buttonhole-start](/reference/snippets/buttonhole-start/): Anchor point is the start of the buttonhole
- [buttonhole-end](/reference/snippets/buttonhole-end/): Anchor point is the end of the buttonhole
</Note>

View file

@ -0,0 +1,9 @@
---
title: Snippets
for: developers
about: Complete list of all the available snippets
---
Snippets are provided by plugins. Follow the links below for more info on and an example of a specific snippet:
<ReadMore list />

View file

@ -0,0 +1,13 @@
---
title: logo
---
The `logo` snippet inserts the FreeSewing logo. It is
provided by [plugin-logo](/reference/plugins/logo/).
```js
snippets.demo = new Snippet('logo', points.anchor)
```
<Example part="snippets_logo" caption="An example of the logo snippet" />

View file

@ -0,0 +1,12 @@
---
title: notch
---
The `notch` snippet is intended for notches and is
provided by [plugin-theme](/reference/plugins/theme/).
```js
snippets.demo = new Snippet('bnotch', points.anchor)
```
<Example part="snippets_notch" caption="An example of the notch snippet" />

View file

@ -0,0 +1,14 @@
---
title: snap-socket
---
The `snap-socket` snippet is used to mark the socket part of a snap button.
It is provided by [plugin-buttons](/reference/plugins/buttons/).
```js
snippets.demo = new Snippet('snap-socket', points.anchor)
```
<Example part="snippets_snapsocket" caption="An example of the snap-socket snippet" />

View file

@ -0,0 +1,14 @@
---
title: snap-stud
---
The `snap-stud` snippet is used to mark the stud part of a snap button.
It is provided by [plugin-buttons](/reference/plugins/buttons/).
```js
snippets.demo = new Snippet('snap-stud', points.anchor)
```
<Example part="snippets_snapstud" caption="An example of the snap-stud snippet" />