1
0
Fork 0

feat(plugintest): Added plugin-round

This commit is contained in:
Joost De Cock 2022-01-18 14:36:02 +01:00
parent bdea7fe9b2
commit ce70e40fba
3 changed files with 54 additions and 7 deletions

View file

@ -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 },
}
}

View file

@ -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,

View file

@ -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