@freesewing/plugin-mirror
Advanced tools
+1
-1
| { | ||
| "id": "plugin-mirror", | ||
| "description": "A FreeSewing plugin to mirror points or paths", | ||
| "version": "4.4.3" | ||
| "version": "4.5.0" | ||
| } |
+2
-2
| { | ||
| "name": "@freesewing/plugin-mirror", | ||
| "version": "4.4.3", | ||
| "version": "4.5.0", | ||
| "description": "A FreeSewing plugin to mirror points or paths", | ||
@@ -39,3 +39,3 @@ "author": "Joost De Cock <joost@joost.at> (https://codeberg.org/joostdecock)", | ||
| "peerDependencies": { | ||
| "@freesewing/core": "4.4.3" | ||
| "@freesewing/core": "4.5.0" | ||
| }, | ||
@@ -42,0 +42,0 @@ "dependencies": {}, |
+1
-1
@@ -14,3 +14,3 @@ <p align='center'><a | ||
| title="All Contributors" | ||
| ><img src="https://img.shields.io/badge/all_contributors-132-pink.svg" | ||
| ><img src="https://img.shields.io/badge/all_contributors-131-pink.svg" | ||
| alt="All Contributors"/> | ||
@@ -17,0 +17,0 @@ </a></p><p align='center'><a |
+35
-1
@@ -47,4 +47,6 @@ import about from '../about.json' with { type: 'json' } | ||
| paths = [], | ||
| snippets = [], | ||
| prefix = 'mirrored', | ||
| nameFormat = undefined, | ||
| reverse = false, | ||
| }) { | ||
@@ -57,3 +59,4 @@ const [start, end] = mirror | ||
| if (this.paths[pathId]) { | ||
| const path = clone ? this.paths[pathId].clone() : this.paths[pathId] | ||
| let path = clone ? this.paths[pathId].clone() : this.paths[pathId] | ||
| path = reverse ? path.reverse() : path | ||
@@ -102,2 +105,33 @@ const newId = clone | ||
| } | ||
| for (const snippetId of snippets) { | ||
| // Make sure the snippet exists | ||
| if (this.snippets[snippetId]) { | ||
| const pointId = this.snippets[snippetId].anchor.name | ||
| const snippet = clone ? this.snippets[snippetId].clone() : this.snippets[snippetId] | ||
| const newSnippetId = clone | ||
| ? typeof nameFormat == 'function' | ||
| ? nameFormat(snippetId, 'snippet') | ||
| : `${prefix}${capFirst(snippetId)}` | ||
| : snippetId | ||
| this.snippets[newSnippetId] = snippet | ||
| const point = mirrorPoint(snippet.anchor) | ||
| if (this.points[pointId]) { | ||
| const newPointId = clone | ||
| ? typeof nameFormat == 'function' | ||
| ? nameFormat(pointId, 'point') | ||
| : `${prefix}${capFirst(pointId)}` | ||
| : pointId | ||
| this.points[newPointId] = point | ||
| snippet.anchor = this.points[newPointId] | ||
| } else { | ||
| snippet.anchor = point | ||
| } | ||
| } | ||
| } | ||
| }, | ||
@@ -104,0 +138,0 @@ }, |
10898
11.31%124
29.17%