From ce70e40fba232e5f80ddd1d39e01133bf449836c Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Tue, 18 Jan 2022 14:36:02 +0100 Subject: [PATCH] feat(plugintest): Added plugin-round --- packages/plugintest/config/index.js | 9 +++-- packages/plugintest/src/index.js | 8 ++--- packages/plugintest/src/plugin-round.js | 44 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 packages/plugintest/src/plugin-round.js diff --git a/packages/plugintest/config/index.js b/packages/plugintest/config/index.js index 58b03493b24..a5dd73e3856 100644 --- a/packages/plugintest/config/index.js +++ b/packages/plugintest/config/index.js @@ -41,6 +41,7 @@ export default { gore: [ 'goreRadius', 'goreGoreNumber', 'goreExtraLength' ], logo: [ 'logoScale', 'logoRotate' ], mirror: [ 'mirrorLine', 'mirrorClone' ], + round: [ 'roundRadius', 'roundRender' ], }, measurements: [], parts: [ @@ -57,7 +58,7 @@ export default { 'measurements', 'mirror', 'notches', - //'round', + 'round', //'scalebox', //'sprinkle', //'svgattr', @@ -68,7 +69,7 @@ export default { ], options: { plugin: { - dflt: 'notches', + dflt: 'round', list: [ 'all', 'banner', @@ -129,6 +130,8 @@ export default { // Mirror options mirrorLine: { dflt: 'a', list: ['a', 'b', 'none' ] }, mirrorClone: { bool: true }, - + // Round options + roundRadius: { count: 10, min: 0, max: 50 }, + roundRender: { bool: true }, } } diff --git a/packages/plugintest/src/index.js b/packages/plugintest/src/index.js index f7658adcba4..383537d9320 100644 --- a/packages/plugintest/src/index.js +++ b/packages/plugintest/src/index.js @@ -15,7 +15,7 @@ import logo from '@freesewing/plugin-logo' import measurements from '@freesewing/plugin-measurements' import mirror from '@freesewing/plugin-mirror' import notches from '@freesewing/plugin-notches' -//import round from '@freesewing/plugin-round' +import round from '@freesewing/plugin-round' //import scalebox from '@freesewing/plugin-scalebox' //import sprinkle from '@freesewing/plugin-sprinkle' //import svgattr from '@freesewing/plugin-svgattr' @@ -37,7 +37,7 @@ import draftLogo from './plugin-logo' import draftMeasurements from './plugin-measurements' import draftMirror from './plugin-mirror' import draftNotches from './plugin-notches' -//import draftRound from './plugin-round' +import draftRound from './plugin-round' //import draftScalebox from './plugin-scalebox' //import draftSprinkle from './plugin-sprinkle' //import draftSvgattr from './plugin-svgattr' @@ -65,7 +65,7 @@ const plugins = [ measurements, mirror, notches, -// round, + round, // scalebox, // sprinkle, // svgattr, @@ -89,7 +89,7 @@ const methods = { draftMeasurements, draftMirror, draftNotches, -// draftRound, + draftRound, // draftScalebox, // draftSprinkle, // draftSvgattr, diff --git a/packages/plugintest/src/plugin-round.js b/packages/plugintest/src/plugin-round.js new file mode 100644 index 00000000000..41c5f4d1cd2 --- /dev/null +++ b/packages/plugintest/src/plugin-round.js @@ -0,0 +1,44 @@ + +const draftRound = part => { + + const { Point, points, Path, paths, macro, options } = part.shorthand() + + if (['round', 'all'].indexOf(options.plugin) !== -1) { + points.topLeft = new Point(0, 0) + points.bottomLeft = new Point(0, 30) + points.topRight = new Point(100, 0) + points.bottomRight = new Point(100, 30) + + paths.demo = new Path() + .move(points.topLeft) + .line(points.bottomLeft) + .line(points.bottomRight) + .line(points.topRight) + .close() + .attr('class', 'note dashed') + + const opts = { + radius: options.roundRadius, + render: options.roundRender + } + + macro('round', { + from: points.topLeft, + to: points.bottomRight, + via: points.bottomLeft, + prefix: 'bl', + ...opts + }) + macro('round', { + from: points.bottomRight, + to: points.topLeft, + via: points.topRight, + prefix: 'tr', + ...opts + }) + } + + return part +} + +export default draftRound