2022-09-04 19:48:15 +02:00
|
|
|
import { mirrorPlugin } from '@freesewing/plugin-mirror'
|
|
|
|
import { base } from './base.mjs'
|
|
|
|
|
2022-09-11 16:34:08 +02:00
|
|
|
const pluginMirror = ({ points, Point, paths, Path, snippets, Snippet, options, macro, part }) => {
|
2022-01-18 14:12:36 +01:00
|
|
|
if (['mirror', 'all'].indexOf(options.plugin) !== -1) {
|
2023-04-15 09:37:33 +02:00
|
|
|
// Mirror lines
|
2022-01-19 16:23:25 +01:00
|
|
|
points.mirrorA = new Point(0, 0)
|
|
|
|
points.mirrorB = new Point(70, 30)
|
|
|
|
points.mirrorC = new Point(0, 50)
|
|
|
|
points.mirrorD = new Point(30, -30)
|
2022-01-18 14:12:36 +01:00
|
|
|
paths.mirrorA = new Path()
|
|
|
|
.move(points.mirrorA)
|
|
|
|
.line(points.mirrorB)
|
2022-01-19 16:23:25 +01:00
|
|
|
.attr('class', 'dashed note')
|
2022-01-18 14:12:36 +01:00
|
|
|
.attr('data-text', 'Mirror A')
|
|
|
|
.attr('data-text-class', 'right')
|
|
|
|
paths.mirrorB = new Path()
|
|
|
|
.move(points.mirrorC)
|
|
|
|
.line(points.mirrorD)
|
2022-01-19 16:23:25 +01:00
|
|
|
.attr('class', 'dashed note')
|
2022-01-18 14:12:36 +01:00
|
|
|
.attr('data-text', 'Mirror B')
|
|
|
|
.attr('data-text-class', 'right')
|
|
|
|
|
2023-04-15 09:37:33 +02:00
|
|
|
// line
|
|
|
|
points.start = new Point(10, 0)
|
|
|
|
points.end = new Point(30, 30)
|
|
|
|
paths.line = new Path().move(points.start).line(points.end)
|
2022-01-18 14:12:36 +01:00
|
|
|
|
2023-04-15 09:37:33 +02:00
|
|
|
// curve
|
|
|
|
points.from = new Point(50, 50)
|
|
|
|
points.cp1 = new Point(12, 34)
|
|
|
|
points.cp2 = new Point(14, -4)
|
|
|
|
points.to = new Point(64, 34)
|
|
|
|
paths.curve = new Path().move(points.from).curve(points.cp1, points.cp2, points.to)
|
2022-01-18 14:12:36 +01:00
|
|
|
|
2023-04-15 09:37:33 +02:00
|
|
|
// snippet
|
|
|
|
points.a = new Point(20, 30)
|
|
|
|
snippets.a = new Snippet('button', points.a)
|
2022-01-18 14:12:36 +01:00
|
|
|
|
|
|
|
if (options.mirrorLine !== 'none') {
|
|
|
|
macro('mirror', {
|
2022-01-19 16:23:25 +01:00
|
|
|
mirror:
|
|
|
|
options.mirrorLine === 'a'
|
|
|
|
? [points.mirrorA, points.mirrorB]
|
|
|
|
: [points.mirrorC, points.mirrorD],
|
2023-04-15 09:37:33 +02:00
|
|
|
points: ['a'],
|
|
|
|
paths: ['line', 'curve'],
|
2022-01-18 14:12:36 +01:00
|
|
|
clone: options.mirrorClone,
|
|
|
|
})
|
|
|
|
}
|
2023-04-15 09:37:33 +02:00
|
|
|
|
|
|
|
macro('bannerbox', {
|
|
|
|
topLeft: new Point(options.mirrorLine === 'b' ? -35 : 5, -25),
|
|
|
|
bottomRight: new Point(65, 50),
|
|
|
|
title: 'plugin = measurements',
|
|
|
|
})
|
2022-01-18 14:12:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return part
|
|
|
|
}
|
|
|
|
|
2022-09-04 19:48:15 +02:00
|
|
|
export const mirror = {
|
|
|
|
name: 'plugintest.mirror',
|
|
|
|
after: base,
|
|
|
|
options: {
|
|
|
|
mirrorLine: { dflt: 'a', list: ['a', 'b', 'none'], menu: 'mirror' },
|
|
|
|
mirrorClone: { bool: true, menu: 'mirror' },
|
|
|
|
},
|
|
|
|
plugins: mirrorPlugin,
|
|
|
|
draft: pluginMirror,
|
|
|
|
}
|