1
0
Fork 0

breaking: New annotation plugin replaces others

This wraps up the initial work on a new annotations plugin that replaces
other plugins that provide annotations. As a result, the following
plugins are now no longer available:

- plugin-banner
- plugin-bartack
- plugin-buttons
- plugin-cutonfold
- plugin-dimension
- plugin-grainine
- plugin-logo
- plugin-notches
- plugin-scalebox
- plugin-title

The new plugin-annotations package provides all these plugins used to
provide. In addition, it also includes the following new macros:

- bannerbox
- pleat
- sewTogether
This commit is contained in:
joostdecock 2023-04-15 15:14:56 +02:00
parent ad18463e2a
commit d0447c0f77
39 changed files with 655 additions and 926 deletions

View file

@ -54,18 +54,6 @@
- Fixed pocket size issue
- Fixed waist shaping issue
### plugin-banner
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
### plugin-bartack
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
### plugin-bundle
#### Removed
@ -74,24 +62,6 @@
### plugin-bust
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
### plugin-buttons
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
### plugin-cutonfold
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
### plugin-dimension
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
@ -108,12 +78,6 @@
- The `goreNumber` props is removed. Please use `gores` instead
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
### plugin-grainline
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
@ -138,24 +102,12 @@
### plugin-mirror
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
### plugin-notches
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
### plugin-round
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
### plugin-scalebox
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
@ -174,16 +126,6 @@
### plugin-theme
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
### plugin-title
#### Changed
- Use localized date format
#### Removed
- This plugin no longer sets its version as an SVG attribute when rendering patterns
@ -349,13 +291,6 @@
- Support drafting for high bust
### plugin-title
#### Added
- Added support for removing the title via a macro call
- Added a render timestamp to the title
## 2.21.3 (2022-07-02)
@ -729,18 +664,6 @@
### tutorial
#### Changed
- Migrated from Rollup to Esbuild for all builds
### plugin-banner
#### Changed
- Migrated from Rollup to Esbuild for all builds
### plugin-bartack
#### Changed
- Migrated from Rollup to Esbuild for all builds
@ -753,24 +676,6 @@
### plugin-bust
#### Changed
- Migrated from Rollup to Esbuild for all builds
### plugin-buttons
#### Changed
- Migrated from Rollup to Esbuild for all builds
### plugin-cutonfold
#### Changed
- Migrated from Rollup to Esbuild for all builds
### plugin-dimension
#### Changed
- Migrated from Rollup to Esbuild for all builds
@ -783,12 +688,6 @@
### plugin-gore
#### Changed
- Migrated from Rollup to Esbuild for all builds
### plugin-grainline
#### Changed
- Migrated from Rollup to Esbuild for all builds
@ -813,24 +712,12 @@
### plugin-mirror
#### Changed
- Migrated from Rollup to Esbuild for all builds
### plugin-notches
#### Changed
- Migrated from Rollup to Esbuild for all builds
### plugin-round
#### Changed
- Migrated from Rollup to Esbuild for all builds
### plugin-scalebox
#### Changed
- Migrated from Rollup to Esbuild for all builds
@ -849,12 +736,6 @@
### plugin-theme
#### Changed
- Migrated from Rollup to Esbuild for all builds
### plugin-title
#### Changed
- Migrated from Rollup to Esbuild for all builds
@ -1341,25 +1222,6 @@
- Switched to default import for version from package.json
### plugin-banner
#### Changed
- Changed the default options
- Now part of `@freesewing/plugin-bundle`
### plugin-bartack
#### Changed
- Now part of `@freesewing/plugin-bundle`
#### Fixed
- Fixed issue with `bartackFractionAlong` macro
- Handle start and endpoints being the same in `bartackFractionAlong`
- Support start and endpoints being reversed in `bartackFractionAlong`
### plugin-bundle
#### Changed
@ -1367,18 +1229,6 @@
- plugin-banner is now part of plugin-bundle
- plugin-bartack is now part of plugin-bundle
### plugin-cutonfold
#### Added
- Support for scale setting
### plugin-dimension
#### Fixed
- Support hiding start/end markers on path dimensions (pd macro)
### plugin-flip
#### Added
@ -1392,12 +1242,6 @@
- The `goreNumber` property of the gore macro has been renamed to `gores`
- Using `goreNumber` is now deprecated in favor of `gore` and will be removed in the next majot version
### plugin-grainline
#### Added
- Added support for custom text
### plugin-sprinkle
#### Added
@ -1405,16 +1249,6 @@
- Added support for `scale` to scale all sprinkled snippets
- Added support for `rotate` to rotate all sprinkled snippets
### plugin-title
#### Added
- Added support for `settings.scale`
#### Removed
- Removed rendering of config.cut as it's not used
### core
#### Added
@ -1488,22 +1322,6 @@
- Updated the rendertest pattern to be more concise
### plugin-banner
#### Added
- Added (esm) unit tests
### plugin-bartack
#### Added
- Added (esm) unit tests
#### Changed
- Add utility classes and CSS variables for better styling support
### plugin-bundle
#### Added
@ -1512,32 +1330,6 @@
### plugin-bust
#### Added
- Added (esm) unit tests
### plugin-buttons
#### Added
- Added (esm) unit tests
#### Changed
- Add utility classes and CSS variables for better styling support
#### Fixed
- Only add snippets once to SVG object
### plugin-cutonfold
#### Added
- Added (esm) unit tests
### plugin-dimension
#### Added
- Added (esm) unit tests
@ -1550,12 +1342,6 @@
### plugin-gore
#### Added
- Added (esm) unit tests
### plugin-grainline
#### Added
- Added (esm) unit tests
@ -1580,12 +1366,6 @@
### plugin-mirror
#### Added
- Added (esm) unit tests
### plugin-notches
#### Added
- Added (esm) unit tests
@ -1596,16 +1376,6 @@
- Added (esm) unit tests
### plugin-scalebox
#### Added
- Added (esm) unit tests
#### Changed
- Add utility classes and CSS variables for better styling support
### plugin-sprinkle
#### Added
@ -1624,16 +1394,6 @@
- Added (esm) unit tests
### plugin-title
#### Added
- Added (esm) unit tests
#### Changed
- Add utility classes and CSS variables for better styling support
### plugin-versionfree-svg
#### Added
@ -2175,12 +1935,6 @@
- Include plugin-buttons
- Include plugin-mirror
### plugin-buttons
#### Changed
- Is now included in plugin-bundle
### plugin-mirror
#### Changed
@ -2570,19 +2324,6 @@
- Added examples for bartack plugin
- Added examples for new buttonhole-start/end snippets
### plugin-buttons
#### Added
- Added the buttonhole-end snippet
- Added the buttonhole-start snippet
### plugin-dimension
#### Added
- Added the `rmad` macro
### plugin-logo
#### Added
@ -2843,16 +2584,6 @@
- Added missing scalebox
### plugin-scalebox
#### Added
- Now includes the miniscale macro
#### Changed
- Took my name off the patterns
## 2.11.2 (2021-01-11)
@ -2874,12 +2605,6 @@
- Removed unused lengthBonus option
### plugin-notches
#### Added
- Initial release. See [#757](https://github.com/freesewing/freesewing/issues/757)
### i18n
#### Changed
@ -2965,19 +2690,6 @@
- Teagan is a T-shirt pattern
### plugin-dimension
#### Added
- Added support for passing in the ID used to add paths to the part
- Added the `rmd` macro that removes dimensions
### plugin-title
#### Added
- Added support for cutting instructions. Closes [#500](https://github.com/freesewing/freesewing/issues/500)
### core
#### Added
@ -3366,16 +3078,6 @@
- Removed `Circumference` suffix from measurement names
### plugin-buttons
#### Changed
- Snippet names are changed, `snap-male` is now `snap-stud` and `snap-female` is now `snap-socket` Changing this to avoid needless use of gender related terminology.
#### Removed
- Snippet `snap-male` and `snap-female` are no longer available. Use `snap-stud` and `snap-socket` instead
### plugin-measurements
#### Added
@ -3532,12 +3234,6 @@
- The `sleevecapBackFactorY` and `sleevecapFrontFactorY` options had a minimum above the default
### plugin-dimension
#### Changed
- Don't escape inch symbol in text. Instead let Svg.escapeText() handle it at render time
### core
#### Fixed
@ -3556,12 +3252,6 @@
## 2.4.2 (2020-03-08)
### plugin-title
#### Changed
- Added *for* to title output
### i18n
#### Added
@ -3796,12 +3486,6 @@
## 2.1.5 (2019-11-19)
### plugin-dimension
#### Fixed
- Fixed issue where inch marks where breaking SVG because of unescaped double quotes
## 2.1.4 (2019-11-01)
@ -4073,12 +3757,6 @@
### tutorial
#### Added
- Initial release
### plugin-banner
#### Added
- Initial release
@ -4091,36 +3769,12 @@
### plugin-bust
#### Added
- Initial release
### plugin-buttons
#### Added
- Initial release
### plugin-cutonfold
#### Added
- Initial release
### plugin-dimension
#### Added
- Initial release
### plugin-flip
#### Added
- Initial release
### plugin-grainline
#### Added
- Initial release
@ -4139,12 +3793,6 @@
### plugin-round
#### Added
- Initial release
### plugin-scalebox
#### Added
- Initial release
@ -4163,12 +3811,6 @@
### plugin-theme
#### Added
- Initial release
### plugin-title
#### Added
- Initial release

View file

@ -6,6 +6,7 @@
"plugin-flip": "A FreeSewing plugin to flip parts horizontally",
"plugin-gore": "A FreeSewing plugin to generate gores for a semi-sphere or dome",
"plugin-i18n": "A FreeSewing plugin for pattern translation",
"plugin-logo": "A FreeSewing plugin that provides our logo as a snippet",
"plugin-measurements": "A FreeSewing plugin that adds additional measurements that can be calculated from existing ones",
"plugin-mirror": "A FreeSewing plugin to mirror points or paths",
"plugin-round": "A FreeSewing plugin to round corners",
@ -13,6 +14,5 @@
"plugin-svgattr": "A FreeSewing plugin to set SVG attributes",
"plugin-theme": "A FreeSewing plugin that provides a default theme",
"plugin-timing": "A FreeSewing plugin to record the time it takes to draft your pattern parts",
"plugin-title": "A FreeSewing plugin to add a title to your pattern parts",
"plugin-versionfree-svg": "A FreeSewing plugin to keep version info out of your SVG to allow easy diffs across versions"
}

View file

@ -4,7 +4,6 @@ import { annotations } from './plugin-annotations.mjs'
import { flip } from './plugin-flip.mjs'
import { gore } from './plugin-gore.mjs'
import { i18n } from './plugin-i18n.mjs'
import { logo } from './plugin-logo.mjs'
import { measurements } from './plugin-measurements.mjs'
import { mirror } from './plugin-mirror.mjs'
import { round } from './plugin-round.mjs'
@ -13,7 +12,7 @@ import { sprinkle } from './plugin-sprinkle.mjs'
// Setup our new design
const Plugintest = new Design({
data,
parts: [annotations, flip, gore, i18n, logo, measurements, mirror, round, sprinkle],
parts: [annotations, flip, gore, i18n, measurements, mirror, round, sprinkle],
})
// Named exports
@ -29,7 +28,7 @@ export {
gore,
//grainline,
i18n,
logo,
//logo,
measurements,
mirror,
//notches,

View file

@ -348,7 +348,7 @@ const pluginAnnotations = ({
points.st_a = new Point(x - 5, y)
points.st_b = new Point(x + 35, y + 10)
points.st_c = new Point(x + 70, y)
macro('sewtogether', {
macro('sewTogether', {
from: points.st_a,
to: points.st_c,
hinge: options.sewtogetherHinge,
@ -357,7 +357,7 @@ const pluginAnnotations = ({
macro('bannerbox', {
topLeft: new Point(x, y - 30),
bottomRight: new Point(x + 65, y + 10),
text: 'macro = sewtogether',
text: 'macro = sewTogether',
...store.get('bannerbox.macro'),
})
@ -381,6 +381,18 @@ const pluginAnnotations = ({
...store.get('bannerbox.macro'),
})
points.logo = new Point(40, 40)
snippets.logo = new Snippet('logo', points.logo)
.attr('data-scale', options.logoScale)
.attr('data-rotate', options.logoRotate)
macro('bannerbox', {
topLeft: new Point(25, 10),
bottomRight: new Point(60, 45),
text: 'snippet = logo',
...store.get('bannerbox.snippet'),
})
// Overarching bannerbox
macro('bannerbox', {
topLeft: new Point(-10, -10),
@ -418,6 +430,9 @@ export const annotations = {
dimensionsCustomText: { bool: false, menu: 'annotations.dimensions' },
dimensionsEndMarker: { bool: true, menu: 'annotations.dimensions' },
dimensionsStartMarker: { bool: true, menu: 'annotations.dimensions' },
// Logo
logoScale: { pct: 100, min: 10, max: 200, menu: 'annptations.logo' },
logoRotate: { deg: 0, min: -360, max: 360, menu: 'annotations.logo' },
// Pleat
pleatMargin: { count: 35, min: 0, max: 50, menu: 'annotations.pleat' },
pleatReverse: { bool: false, menu: 'annotations.pleat' },

View file

@ -1,4 +1,5 @@
import { base } from './base.mjs'
import { logoPlugin } from '@freesewing/plugin-logo'
const pluginLogo = ({
points,
@ -37,4 +38,5 @@ export const logo = {
logoRotate: { deg: 0, min: -360, max: 360, menu: 'logo' },
},
draft: pluginLogo,
plugins: [logoPlugin],
}

View file

@ -1,16 +0,0 @@
// This file is auto-generated | Any changes you make will be overwritten.
import { Test } from '../src/index.mjs'
// Shared tests
import { testPatternConfig } from '../../../tests/designs/config.mjs'
import { testPatternDrafting } from '../../../tests/designs/drafting.mjs'
import { testPatternSampling } from '../../../tests/designs/sampling.mjs'
// Test config
testPatternConfig(Test)
// Test drafting - Change the second parameter to `true` to log errors
testPatternDrafting(Test, false)
// Test sampling - Change the second parameter to `true` to log errors
testPatternSampling(Test, false)

View file

@ -0,0 +1,61 @@
---
title: plugin-annotations
---
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)
- [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)
## Installation
```sh
npm install @freesewing/plugin-annotations
```
## 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'
// or
import { pluginAnnotations } from '@freesewing/plugin-banner'
```
## Notes
The annotations plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-annotations

View file

@ -1,32 +0,0 @@
---
title: plugin-banner
---
Published as [@freesewing/plugin-banner][1], this plugin provides [the banner
macro](/reference/macros/banner) which allows you to add repeating text
along a path.
## Installation
```sh
npm install @freesewing/plugin-banner
```
## Usage
Either [add it as a part plugins](/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 { bannerPlugin } from '@freesewing/plugin-banner'
// or
import { pluginBanner } from '@freesewing/plugin-banner'
```
## Notes
The banner plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-banner

View file

@ -1,35 +0,0 @@
---
title: plugin-bartack
---
Published as [@freesewing/plugin-bartack][1], this plugin provides
the [bartack](/reference/macros/bartack),
[bartackAlong](/reference/macros/bartackalong), and
the [bartackFractionAlong](/reference/macros/bartackfractionalong) macros
which allows you to add bartacks — a set
of tight zig-zag stitches used to enforce a seam — to your design.
## Installation
```sh
npm install @freesewing/plugin-bartack
```
## Usage
Either [add it as a part plugins](/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 { bartackPlugin } from '@freesewing/plugin-bartack'
// or
import { pluginBartack } from '@freesewing/plugin-bartack'
```
## Notes
The bartack plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-bartack

View file

@ -1,38 +0,0 @@
---
title: plugin-buttons
---
Published as [@freesewing/plugin-buttons][1], this plugin provides the following
[snippets](/reference/snippets):
- [button](/reference/snippets/button)
- [buttonhole](/reference/snippets/buttonhole)
- [buttonhole-start](/reference/snippets/buttonhole-start)
- [buttonhole-end](/reference/snippets/buttonhole-end)
- [snap-stud](/reference/snippets/snap-stud)
- [snap-socket](/reference/snippets/snap-socket)
## Installation
```sh
npm install @freesewing/plugin-buttons
```
## Usage
Either [add it as a part plugins](/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 { buttonsPlugin } from '@freesewing/plugin-buttons'
// or
import { pluginButtons } from '@freesewing/plugin-buttons'
```
## Notes
The buttons plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-buttons

View file

@ -1,32 +0,0 @@
---
title: plugin-cutonfold
---
Published as [@freesewing/plugin-cutonfold][1], this plugin provides [the
cutonfold macro](/reference/macros/cutonfold) which adds a _cut on fold_
indicator to your design.
## Installation
```sh
npm install @freesewing/plugin-cutonfold
```
## Usage
Either [add it as a part plugins](/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 { cutonfoldPlugin } from '@freesewing/plugin-cutonfold'
// or
import { pluginCutonfold } from '@freesewing/plugin-cutonfold'
```
## Notes
The cutonfold plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-cutonfold

View file

@ -1,38 +0,0 @@
---
title: plugin-dimension
---
Published as [@freesewing/plugin-dimension][1], this plugin provides the
following macros:
- [hd](/reference/macros/hd) : Adds a horizontal dimension
- [vd](/reference/macros/vd) : Adds a vertical dimension
- [ld](/reference/macros/ld) : Adds a linear dimension
- [pd](/reference/macros/pd) : Adds a dimension along a path
- [rmd](/reference/macros/rmd) : Removes a dimension
- [rmad](/reference/macros/rmad) : Removes all dimensions with a default prefix
## Installation
```sh
npm install @freesewing/plugin-dimension
```
## Usage
Either [add it as a part plugins](/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 { dimensionPlugin } from '@freesewing/plugin-dimension'
// or
import { pluginDimension } from '@freesewing/plugin-dimension'
```
## Notes
The dimension plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-dimension

View file

@ -1,32 +0,0 @@
---
title: plugin-grainline
---
Published as [@freesewing/plugin-grainline][1], this plugin provides [the
grainline macro](/reference/macros/grainline) which adds a _grainline_
indicator to your design.
## Installation
```sh
npm install @freesewing/plugin-grainline
```
## Usage
Either [add it as a part plugins](/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 { grainlinePlugin } from '@freesewing/plugin-grainline'
// or
import { pluginGrainline } from '@freesewing/plugin-grainline'
```
## Notes
The grainline plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-grainline

View file

@ -1,32 +0,0 @@
---
title: plugin-logo
---
Published as [@freesewing/plugin-logo][1], this plugin provides [the logo
macro](/reference/macros/logo) which adds FreeSewing's logo to your
design.
## Installation
```sh
npm install @freesewing/plugin-logo
```
## Usage
Either [add it as a part plugins](/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 { logoPlugin } from '@freesewing/plugin-logo'
// or
import { pluginLogo } from '@freesewing/plugin-logo'
```
## Notes
The logo plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-logo

View file

@ -1,32 +0,0 @@
---
title: plugin-notches
---
Published as [@freesewing/plugin-notches][1], this plugin provides the
[notch](/reference/snippets/notch) and
[bnotch](/reference/snippets/bnotch) snippets.
## Installation
```sh
npm install @freesewing/plugin-notches
```
## Usage
Either [add it as a part plugins](/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 { notchesPlugin } from '@freesewing/plugin-notches'
// or
import { pluginNotches } from '@freesewing/plugin-notches'
```
## Notes
The notches plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-notches

View file

@ -1,38 +0,0 @@
---
title: plugin-scalebox
---
Published as [@freesewing/plugin-scalebox][1], this plugin provides the
[scalebox](/reference/macros/scalebox) and
[miniscale](/reference/macros/miniscale) macros which add a (mini) scalebox
to your design, so users can verify that the pattern is printed at the correct
scale.
## Installation
```sh
npm install @freesewing/plugin-scalebox
```
## Usage
Either [add it as a part plugins](/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 { scaleboxPlugin } from '@freesewing/plugin-scalebox'
// or
import { pluginScalebox } from '@freesewing/plugin-scalebox'
```
## Notes
This plugin by default includes FreeSewing branding, but you can
override that when calling the `scalebox` macro in case you want to
generate your own branded designs.
The scalebox plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-scalebox

View file

@ -0,0 +1,45 @@
---
title: plugin-timing
---
Published as [@freesewing/plugin-timing][1], this plugin measures
detailed timing information while drafting a design and keeps it in the
pattern store.
It is intended to be used for developers trying to indicate which parts
of their code are slow, or in general provide insights into the speed
at which a design can be drafted.
## Installation
```sh
npm install @freesewing/plugin-timing
```
## Usage
Either [add it as a part plugins](/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 { timingPlugin } from '@freesewing/plugin-mirror'
// or
import { pluginTiming } from '@freesewing/plugin-mirror'
```
<Fixme>
##### Provide in-depth example
This is currently not used, but that will change once v3 gets closer to release.
At that point, we should provide an in-depth example here.
</Fixme>
## Notes
The mirror plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-timing

View file

@ -1,32 +0,0 @@
---
title: plugin-title
---
Published as [@freesewing/plugin-title][1], this plugin provides [the title
macro](/reference/macros/title) which facilitates adding part titles to
your designs.
## Installation
```sh
npm install @freesewing/plugin-title
```
## Usage
Either [add it as a part plugins](/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 { titlePlugin } from '@freesewing/plugin-title'
// or
import { pluginTitle } from '@freesewing/plugin-title'
```
## Notes
The title plugin is part of our [plugin-bundle](/reference/plugins/bundle)
[1]: https://www.npmjs.com/package/@freesewing/plugin-title

View file

@ -9,6 +9,7 @@ import { bannerboxMacros } from './bannerbox.mjs'
import { bartackMacros } from './bartack.mjs'
import { crossboxMacros } from './crossbox.mjs'
import { scaleboxMacros } from './scalebox.mjs'
import { titleMacros } from './title.mjs'
// Hooks and Macros
import { cutonfoldMacros, cutonfoldHooks } from './cutonfold.mjs'
import { dimensionsMacros, dimensionsHooks } from './dimensions.mjs'
@ -42,6 +43,7 @@ export const plugin = {
...grainlineMacros,
...pleatMacros,
...sewtogetherMacros,
...titleMacros,
},
}

View file

@ -5,8 +5,8 @@ const logo = (scale) =>
export const logoHooks = {
preRender: [
function (svg) {
if (svg.defs.indexOf('id="logo"') === -1) {
svg.defs += logo(svg.pattern.settings[0].scale)
for (const def of svg.defs) {
if (svg.defs.indexOf('id="logo"') === -1) svg.defs += logo(svg.pattern.settings[0].scale)
}
},
],

View file

@ -21,7 +21,7 @@ export const sewtogetherHooks = {
// Export macros
export const sewtogetherMacros = {
sewtogether: function (so, { points, paths, Path, complete, scale, sa }) {
sewTogether: function (so, { points, paths, Path, complete, scale, sa }) {
if (so === false) {
delete points.sewtogetherFrom
delete points.sewtogetherFromCp

View file

@ -0,0 +1,107 @@
const style = `
text.title-nr {
font-size: 24pt;
font-weight: 700;
text-anchor: middle;
dominant-baseline: reset-size;
}
text.title-name {
font-size: 7pt;
font-weight: 500;
text-anchor: middle;
dominant-baseline: reset-size;
}
text.title-pattern {
font-size: 4pt;
font-weight: 500;
dominant-baseline: reset-size;
text-anchor: middle;
font-style: italic;
}
`
const titleMacro = function (so, { points, scale, locale, store }) {
const prefix = so.prefix || ''
// Passing `false` will remove the title
if (so === false) {
for (const id of [
`_${prefix}_titleNr`,
`_${prefix}_titleName`,
`_${prefix}_titlePattern`,
`_${prefix}_titleFor`,
`_${prefix}_exportDate`,
])
delete points[id]
return true
}
const transform = function (anchor) {
const cx = anchor.x - so.scale * anchor.x
const cy = anchor.y - so.scale * anchor.y
return `matrix(${so.scale}, 0, 0, ${so.scale}, ${cx}, ${cy}) rotate(${so.rotation} ${anchor.x} ${anchor.y})`
}
const defaults = {
scale: 1,
rotation: 0,
}
so = { ...defaults, ...so }
so.scale = so.scale * scale
let overwrite = true
if (so.append) overwrite = false
points[`_${prefix}_titleNr`] = so.at
.clone()
.attr('data-text', so.nr, overwrite)
.attr('data-text-class', 'text-4xl fill-note font-bold')
.attr('data-text-transform', transform(so.at))
let shift = 8
if (so.title) {
points[`_${prefix}_titleName`] = so.at
.shift(-90 - so.rotation, shift * so.scale)
.attr('data-text', so.title)
.attr('data-text-class', 'text-lg fill-current font-bold')
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, 13 * so.scale)))
shift += 8
}
let name = store.data?.name || 'No Name'
name = name.replace('@freesewing/', '')
points[`_${prefix}_titlePattern`] = so.at
.shift(-90 - so.rotation, shift * so.scale)
.attr('data-text', name)
.attr('data-text', 'v' + (store.data?.version || 'No Version'))
.attr('data-text-class', 'fill-note')
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, shift * so.scale)))
if (store.data.for) {
shift += 8
points[`_${prefix}_titleFor`] = so.at
.shift(-90 - so.rotation, shift * so.scale)
.attr('data-text', '( ' + store.data.for + ' )')
.attr('data-text-class', 'fill-current font-bold')
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, shift * so.scale)))
}
shift += 6
const now = new Date()
let hours = now.getHours()
let mins = now.getMinutes()
if (hours < 10) hours = `0${hours}`
if (mins < 10) mins = `0${mins}`
points[`_${prefix}_exportDate`] = so.at
.shift(-90 - so.rotation, shift * so.scale)
.attr(
'data-text',
now.toLocaleDateString(locale || 'en', {
weekday: 'long',
year: 'numeric',
month: 'short',
day: 'numeric',
})
)
.attr('data-text', `@ ${hours}:${mins}`)
.attr('data-text-class', 'text-sm')
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, shift * so.scale)))
}
// Export macros
export const titleMacros = { title: titleMacro }

View file

@ -0,0 +1,87 @@
import chai from 'chai'
import { Design } from '@freesewing/core'
import { annotationsPlugin } from '../src/index.mjs'
const expect = chai.expect
describe('Banner Plugin Tests', () => {
it('Should add repeating text to a path', () => {
const part = {
name: 'test',
draft: ({ Point, points, Path, paths, macro, part }) => {
points.from = new Point(30, 30)
points.to = new Point(30, 100)
paths.example = new Path().move(points.from).line(points.to)
macro('banner', {
text: 'foo',
path: paths.example,
})
return part
},
plugins: [annotationsPlugin],
}
const design = new Design({ parts: [part] })
const pattern = new design()
pattern.draft()
const c = pattern.parts[0].test.paths.example
expect(c.attributes.get('data-text')).to.equal(
'&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;foo&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'
)
expect(c.attributes.get('data-text-class').trim()).to.equal('center')
expect(c.attributes.get('data-text-dy')).to.equal('-1')
})
it('Number of spaces should be configurable', () => {
const part = {
name: 'test',
draft: ({ Point, points, Path, paths, macro, part }) => {
points.from = new Point(30, 30)
points.to = new Point(30, 100)
paths.example2 = new Path().move(points.from).line(points.to)
macro('banner', {
text: 'foo',
path: paths.example2,
spaces: 2,
repeat: 2,
})
return part
},
plugins: [annotationsPlugin],
}
const design = new Design({ parts: [part] })
const pattern = new design()
pattern.draft()
const c = pattern.parts[0].test.paths.example2
expect(c.attributes.get('data-text')).to.equal('&#160;&#160;foo&#160;&#160;foo&#160;&#160;')
})
it('Number of repetitions should be configurable', () => {
const part = {
name: 'test',
draft: ({ Point, points, Path, paths, macro, part }) => {
points.from = new Point(30, 30)
points.to = new Point(30, 100)
paths.example3 = new Path().move(points.from).line(points.to)
macro('banner', {
text: 'foo',
path: paths.example3,
spaces: 1,
repeat: 4,
})
return part
},
plugins: [annotationsPlugin],
}
const design = new Design({ parts: [part] })
const pattern = new design()
pattern.draft()
const c = pattern.parts[0].test.paths.example3
expect(c.attributes.get('data-text')).to.equal('&#160;foo&#160;foo&#160;foo&#160;foo&#160;')
})
})

View file

@ -0,0 +1,240 @@
import chai from 'chai'
import { Design, round } from '@freesewing/core'
import { annotationsPlugin } from '../src/index.mjs'
const expect = chai.expect
describe('Dimension Plugin Tests', () => {
describe('Measures horizontal dimensions', function () {
const part = {
name: 'test',
draft: ({ Point, points, macro, part }) => {
points.from = new Point(10, 20)
points.to = new Point(200, 20)
macro('hd', {
from: points.from,
to: points.to,
y: 35,
})
return part
},
plugins: [annotationsPlugin],
}
const Test = new Design({ parts: [part] })
const pattern = new Test()
pattern.draft()
it('should draw a line and add text to indicate its length', () => {
const c = pattern.parts[0].test.paths['__paperless1']
expect(c.attributes.get('class')).to.equal('mark')
expect(c.attributes.get('marker-start')).to.equal('url(#dimensionFrom)')
expect(c.attributes.get('marker-end')).to.equal('url(#dimensionTo)')
expect(c.attributes.get('data-text')).to.equal('19cm')
expect(c.attributes.get('data-text-class')).to.equal('fill-mark center')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('line')
expect(c.ops[0].to.x).to.equal(10)
expect(c.ops[0].to.y).to.equal(35)
expect(c.ops[1].to.x).to.equal(200)
expect(c.ops[1].to.y).to.equal(35)
})
it('should draw the start marker', () => {
const c = pattern.parts[0].test.paths['__paperless1_ls']
expect(c.attributes.get('class')).to.equal('mark dotted')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('line')
expect(c.ops[0].to.x).to.equal(10)
expect(c.ops[0].to.y).to.equal(20)
expect(c.ops[1].to.x).to.equal(10)
expect(c.ops[1].to.y).to.equal(35)
})
it('should draw the end marker', () => {
const c = pattern.parts[0].test.paths['__paperless1_le']
expect(c.attributes.get('class')).to.equal('mark dotted')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('line')
expect(c.ops[0].to.x).to.equal(200)
expect(c.ops[0].to.y).to.equal(20)
expect(c.ops[1].to.x).to.equal(200)
expect(c.ops[1].to.y).to.equal(35)
})
})
describe('Measures vertical dimensions', () => {
const part = {
name: 'test',
draft: ({ Point, points, macro, part }) => {
points.from = new Point(10, 20)
points.to = new Point(10, 200)
macro('vd', {
from: points.from,
to: points.to,
x: 25,
})
return part
},
plugins: [annotationsPlugin],
}
const Test = new Design({ parts: [part] })
const pattern = new Test()
pattern.draft()
it('Should draw a line and add text to indicate its length', () => {
const c = pattern.parts[0].test.paths['__paperless1']
expect(c.attributes.get('class')).to.equal('mark')
expect(c.attributes.get('marker-start')).to.equal('url(#dimensionFrom)')
expect(c.attributes.get('marker-end')).to.equal('url(#dimensionTo)')
expect(c.attributes.get('data-text')).to.equal('18cm')
expect(c.attributes.get('data-text-class')).to.equal('fill-mark center')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('line')
expect(c.ops[0].to.x).to.equal(25)
expect(c.ops[0].to.y).to.equal(20)
expect(c.ops[1].to.x).to.equal(25)
expect(c.ops[1].to.y).to.equal(200)
})
it('Should draw the start marker', () => {
const c = pattern.parts[0].test.paths['__paperless1_ls']
expect(c.attributes.get('class')).to.equal('mark dotted')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('line')
expect(c.ops[0].to.x).to.equal(10)
expect(c.ops[0].to.y).to.equal(20)
expect(c.ops[1].to.x).to.equal(25)
expect(c.ops[1].to.y).to.equal(20)
})
it('Should draw the end marker', () => {
const c = pattern.parts[0].test.paths['__paperless1_le']
expect(c.attributes.get('class')).to.equal('mark dotted')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('line')
expect(c.ops[0].to.x).to.equal(10)
expect(c.ops[0].to.y).to.equal(200)
expect(c.ops[1].to.x).to.equal(25)
expect(c.ops[1].to.y).to.equal(200)
})
})
describe('Measures the length of straight lines', () => {
const part = {
name: 'test',
draft: ({ Point, points, macro, part }) => {
points.from = new Point(10, 10)
points.to = new Point(100, 100)
macro('ld', {
from: points.from,
to: points.to,
d: 15,
})
return part
},
plugins: [annotationsPlugin],
}
const Test = new Design({ parts: [part] })
const pattern = new Test()
pattern.draft()
it('Should draw a line and add text to indicate its length', () => {
const c = pattern.parts[0].test.paths['__paperless1']
expect(c.attributes.get('class')).to.equal('mark')
expect(c.attributes.get('marker-start')).to.equal('url(#dimensionFrom)')
expect(c.attributes.get('marker-end')).to.equal('url(#dimensionTo)')
expect(c.attributes.get('data-text')).to.equal('12.73cm')
expect(c.attributes.get('data-text-class')).to.equal('fill-mark center')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('line')
expect(round(c.ops[0].to.x)).to.equal(20.61)
expect(round(c.ops[0].to.y)).to.equal(-0.61)
expect(round(c.ops[1].to.x)).to.equal(110.61)
expect(round(c.ops[1].to.y)).to.equal(89.39)
})
it('Should draw the start marker', () => {
const c = pattern.parts[0].test.paths['__paperless1_ls']
expect(c.attributes.get('class')).to.equal('mark dotted')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('line')
expect(round(c.ops[0].to.x)).to.equal(10)
expect(round(c.ops[0].to.y)).to.equal(10)
expect(round(c.ops[1].to.x)).to.equal(20.61)
expect(round(c.ops[1].to.y)).to.equal(-0.61)
})
it('Should draw the end marker', () => {
const c = pattern.parts[0].test.paths['__paperless1_le']
expect(c.attributes.get('class')).to.equal('mark dotted')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('line')
expect(round(c.ops[0].to.x)).to.equal(100)
expect(round(c.ops[0].to.y)).to.equal(100)
expect(round(c.ops[1].to.x)).to.equal(110.61)
expect(round(c.ops[1].to.y)).to.equal(89.39)
})
})
describe('Measures curved lines', () => {
const part = {
name: 'test',
draft: ({ Point, points, macro, Path, part }) => {
points.from = new Point(10, 10)
points.cp1 = new Point(100, 10)
points.cp2 = new Point(10, 100)
points.to = new Point(100, 100)
macro('pd', {
path: new Path().move(points.from).curve(points.cp1, points.cp2, points.to),
d: 15,
})
return part
},
plugins: [annotationsPlugin],
}
const Test = new Design({ parts: [part] })
const pattern = new Test()
pattern.draft()
it('Should draw a line and add text to indicate the length', () => {
const c = pattern.parts[0].test.paths['__paperless1']
expect(c.attributes.get('class')).to.equal('mark')
expect(c.attributes.get('marker-start')).to.equal('url(#dimensionFrom)')
expect(c.attributes.get('marker-end')).to.equal('url(#dimensionTo)')
expect(c.attributes.get('data-text')).to.equal('15.09cm')
expect(c.attributes.get('data-text-class')).to.equal('fill-mark center')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('curve')
expect(round(c.ops[0].to.x)).to.equal(10)
expect(round(c.ops[0].to.y)).to.equal(25)
expect(round(c.ops[1].to.x)).to.equal(37.15)
expect(round(c.ops[1].to.y)).to.equal(32.79)
})
it('Should draw the start marker', () => {
const c = pattern.parts[0].test.paths['__paperless1_ls']
expect(c.attributes.get('class')).to.equal('mark dotted')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('line')
expect(c.ops[0].to.x).to.equal(10)
expect(c.ops[0].to.y).to.equal(10)
expect(c.ops[1].to.x).to.equal(10)
expect(c.ops[1].to.y).to.equal(25)
})
it('Should draw the end marker', () => {
const c = pattern.parts[0].test.paths['__paperless1_le']
expect(c.attributes.get('class')).to.equal('mark dotted')
expect(c.ops[0].type).to.equal('move')
expect(c.ops[1].type).to.equal('line')
expect(c.ops[0].to.x).to.equal(100)
expect(c.ops[0].to.y).to.equal(100)
expect(c.ops[1].to.x).to.equal(100)
expect(c.ops[1].to.y).to.equal(115)
})
})
})

View file

@ -1,6 +1,6 @@
import chai from 'chai'
import { Design } from '@freesewing/core'
import { plugin } from '../src/index.mjs'
import { annotationsPlugin } from '../src/index.mjs'
const expect = chai.expect
@ -18,7 +18,7 @@ describe('Title Plugin Tests', () => {
return part
},
plugins: [plugin],
plugins: [annotationsPlugin],
}
const Pattern = new Design({
data: { name: 'testPattern', version: 99 },
@ -59,7 +59,7 @@ describe('Title Plugin Tests', () => {
return part
},
plugins: [plugin],
plugins: [annotationsPlugin],
}
const Pattern = new Design({
data: { name: 'testPattern', version: 99 },
@ -90,7 +90,7 @@ describe('Title Plugin Tests', () => {
return part
},
plugins: [plugin],
plugins: [annotationsPlugin],
}
const Pattern = new Design({
data: { name: 'testPattern', version: 99 },

View file

@ -4,7 +4,7 @@ import { measurementsPlugin } from '../../plugin-measurements/src/index.mjs'
import { mirrorPlugin } from '../../plugin-mirror/src/index.mjs'
import { roundPlugin } from '../../plugin-round/src/index.mjs'
import { sprinklePlugin } from '../../plugin-sprinkle/src/index.mjs'
import { titlePlugin } from '../../plugin-title/src/index.mjs'
import { logoPlugin } from '../../plugin-logo/src/index.mjs'
import { name, version } from '../data.mjs'
const bundledPlugins = [
@ -13,7 +13,7 @@ const bundledPlugins = [
mirrorPlugin,
roundPlugin,
sprinklePlugin,
titlePlugin,
logoPlugin,
]
function bundleHooks() {

View file

@ -0,0 +1,33 @@
# Change log for: @freesewing/plugin-logo
## 2.21.0 (2022-06-27)
### Changed
- Migrated from Rollup to Esbuild for all builds
## 2.19.6 (2021-12-29)
### Added
- Added (esm) unit tests
## 2.15.0 (2021-04-15)
### Added
- Render logo in currentColor to support dark mode
## 2.0.0 (2019-08-25)
### Added
- Initial release
This is the **initial release**, and the start of this change log.
> Prior to version 2, FreeSewing was not a JavaScript project.
> As such, that history is out of scope for this change log.

View file

@ -1,13 +1,13 @@
![FreeSewing](https://static.freesewing.org/banner.png)
<p align='center'><a
href="https://www.npmjs.com/package/@freesewing/plugin-title"
title="@freesewing/plugin-title on NPM"
><img src="https://img.shields.io/npm/v/@freesewing/plugin-title.svg"
alt="@freesewing/plugin-title on NPM"/>
href="https://www.npmjs.com/package/@freesewing/plugin-logo"
title="@freesewing/plugin-logo on NPM"
><img src="https://img.shields.io/npm/v/@freesewing/plugin-logo.svg"
alt="@freesewing/plugin-logo on NPM"/>
</a><a
href="https://opensource.org/licenses/MIT"
title="License: MIT"
><img src="https://img.shields.io/npm/l/@freesewing/plugin-title.svg?label=License"
><img src="https://img.shields.io/npm/l/@freesewing/plugin-logo.svg?label=License"
alt="License: MIT"/>
</a><a
href="https://deepscan.io/dashboard#view=project&tid=2114&pid=2993&bid=23256"
@ -15,10 +15,10 @@
><img src="https://deepscan.io/api/teams/2114/projects/2993/branches/23256/badge/grade.svg"
alt="Code quality on DeepScan"/>
</a><a
href="https://github.com/freesewing/freesewing/issues?q=is%3Aissue+is%3Aopen+label%3Apkg%3Aplugin-title"
title="Open issues tagged pkg:plugin-title"
><img src="https://img.shields.io/github/issues/freesewing/freesewing/pkg:plugin-title.svg?label=Issues"
alt="Open issues tagged pkg:plugin-title"/>
href="https://github.com/freesewing/freesewing/issues?q=is%3Aissue+is%3Aopen+label%3Apkg%3Aplugin-logo"
title="Open issues tagged pkg:plugin-logo"
><img src="https://img.shields.io/github/issues/freesewing/freesewing/pkg:plugin-logo.svg?label=Issues"
alt="Open issues tagged pkg:plugin-logo"/>
</a><a
href="#contributors-"
title="All Contributors"
@ -46,9 +46,9 @@
alt="Follow @freesewing_org on Twitter"/>
</a></p>
# @freesewing/plugin-title
# @freesewing/plugin-logo
A FreeSewing plugin to add a title to your pattern parts
A FreeSewing plugin that provides our logo as a snippet
@ -65,7 +65,7 @@ A FreeSewing plugin to add a title to your pattern parts
This repository is our *monorepo* holding all our NPM designs, plugins, other NPM packages, and (web)sites.
This folder holds: @freesewing/plugin-title
This folder holds: @freesewing/plugin-logo
If you're not entirely sure what to do or how to start, type this command:

View file

@ -1,4 +1,4 @@
// This file is auto-generated | All changes you make will be overwritten.
export const name = '@freesewing/plugin-title'
export const name = '@freesewing/plugin-logo'
export const version = '3.0.0-alpha.4'
export const data = { name, version }

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

View file

@ -1,7 +1,7 @@
{
"name": "@freesewing/plugin-title",
"name": "@freesewing/plugin-logo",
"version": "3.0.0-alpha.4",
"description": "A FreeSewing plugin to add a title to your pattern parts",
"description": "A FreeSewing plugin that provides our logo as a snippet",
"author": "Joost De Cock <joost@joost.at> (https://github.com/joostdecock)",
"homepage": "https://freesewing.org/",
"repository": "github:freesewing/freesewing",

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,16 @@
import chai from 'chai'
import { Design } from '@freesewing/core'
import { plugin } from '../src/index.mjs'
const expect = chai.expect
describe('Logo Plugin Tests', () => {
it('Should import style and defs', () => {
const Pattern = new Design()
const pattern = new Pattern().use(plugin)
pattern.draft().render()
expect(pattern.svg.defs).to.contain(
'<g id="logo" transform="scale(1) translate(-23 -36)"><path class="logo"'
)
})
})

View file

@ -1,60 +0,0 @@
# Change log for: @freesewing/plugin-title
## 2.22.0 (2022-08-23)
### Added
- Added support for removing the title via a macro call
- Added a render timestamp to the title
## 2.21.0 (2022-06-27)
### Changed
- Migrated from Rollup to Esbuild for all builds
## 2.20.0 (2022-01-24)
### Added
- Added support for `settings.scale`
### Removed
- Removed rendering of config.cut as it's not used
## 2.19.6 (2021-12-29)
### Added
- Added (esm) unit tests
### Changed
- Add utility classes and CSS variables for better styling support
## 2.9.0 (2020-10-02)
### Added
- Added support for cutting instructions. Closes [#500](https://github.com/freesewing/freesewing/issues/500)
## 2.4.2 (2020-03-08)
### Changed
- Added *for* to title output
## 2.0.0 (2019-08-25)
### Added
- Initial release
This is the **initial release**, and the start of this change log.
> Prior to version 2, FreeSewing was not a JavaScript project.
> As such, that history is out of scope for this change log.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

View file

@ -1,121 +0,0 @@
import { name, version } from '../data.mjs'
const style = `
text.title-nr {
font-size: 24pt;
font-weight: 700;
text-anchor: middle;
dominant-baseline: reset-size;
}
text.title-name {
font-size: 7pt;
font-weight: 500;
text-anchor: middle;
dominant-baseline: reset-size;
}
text.title-pattern {
font-size: 4pt;
font-weight: 500;
dominant-baseline: reset-size;
text-anchor: middle;
font-style: italic;
}
`
export const plugin = {
name,
version,
hooks: {
preRender: (svg) => {
if (svg.style.indexOf(`test.title-nr`) === -1) svg.style += style
},
},
macros: {
title: function (so, { points, scale, locale, store }) {
const prefix = so.prefix || ''
// Passing `false` will remove the title
if (so === false) {
for (const id of [
`_${prefix}_titleNr`,
`_${prefix}_titleName`,
`_${prefix}_titlePattern`,
`_${prefix}_titleFor`,
`_${prefix}_exportDate`,
])
delete points[id]
return true
}
const transform = function (anchor) {
const cx = anchor.x - so.scale * anchor.x
const cy = anchor.y - so.scale * anchor.y
return `matrix(${so.scale}, 0, 0, ${so.scale}, ${cx}, ${cy}) rotate(${so.rotation} ${anchor.x} ${anchor.y})`
}
const defaults = {
scale: 1,
rotation: 0,
}
so = { ...defaults, ...so }
so.scale = so.scale * scale
let overwrite = true
if (so.append) overwrite = false
points[`_${prefix}_titleNr`] = so.at
.clone()
.attr('data-text', so.nr, overwrite)
.attr('data-text-class', 'text-4xl fill-note font-bold')
.attr('data-text-transform', transform(so.at))
let shift = 8
if (so.title) {
points[`_${prefix}_titleName`] = so.at
.shift(-90 - so.rotation, shift * so.scale)
.attr('data-text', so.title)
.attr('data-text-class', 'text-lg fill-current font-bold')
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, 13 * so.scale)))
shift += 8
}
let name = store.data?.name || 'No Name'
name = name.replace('@freesewing/', '')
points[`_${prefix}_titlePattern`] = so.at
.shift(-90 - so.rotation, shift * so.scale)
.attr('data-text', name)
.attr('data-text', 'v' + (store.data?.version || 'No Version'))
.attr('data-text-class', 'fill-note')
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, shift * so.scale)))
if (store.data.for) {
shift += 8
points[`_${prefix}_titleFor`] = so.at
.shift(-90 - so.rotation, shift * so.scale)
.attr('data-text', '( ' + store.data.for + ' )')
.attr('data-text-class', 'fill-current font-bold')
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, shift * so.scale)))
}
shift += 6
const now = new Date()
let hours = now.getHours()
let mins = now.getMinutes()
if (hours < 10) hours = `0${hours}`
if (mins < 10) mins = `0${mins}`
points[`_${prefix}_exportDate`] = so.at
.shift(-90 - so.rotation, shift * so.scale)
.attr(
'data-text',
now.toLocaleDateString(locale || 'en', {
weekday: 'long',
year: 'numeric',
month: 'short',
day: 'numeric',
})
)
.attr('data-text', `@ ${hours}:${mins}`)
.attr('data-text-class', 'text-sm')
.attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, shift * so.scale)))
},
},
}
// More specifically named exports
export const titlePlugin = plugin
export const pluginTitle = plugin