1
0
Fork 0

feat(plugintest): Added plugin-sprinkle

This commit is contained in:
Joost De Cock 2022-01-18 14:58:10 +01:00
parent f15063095c
commit b96a3b2f84
3 changed files with 57 additions and 7 deletions

View file

@ -43,6 +43,7 @@ export default {
mirror: [ 'mirrorLine', 'mirrorClone' ], mirror: [ 'mirrorLine', 'mirrorClone' ],
round: [ 'roundRadius', 'roundRender' ], round: [ 'roundRadius', 'roundRender' ],
scalebox: [ 'scaleboxType' ], scalebox: [ 'scaleboxType' ],
sprinkle: [ 'sprinkleScale', 'sprinkleRotate', 'sprinkleSnippet' ],
}, },
measurements: [], measurements: [],
parts: [ parts: [
@ -61,7 +62,7 @@ export default {
'notches', 'notches',
'round', 'round',
'scalebox', 'scalebox',
//'sprinkle', 'sprinkle',
//'svgattr', //'svgattr',
//'theme', //'theme',
//'title', //'title',
@ -70,7 +71,7 @@ export default {
], ],
options: { options: {
plugin: { plugin: {
dflt: 'scalebox', dflt: 'sprinkle',
list: [ list: [
'all', 'all',
'banner', 'banner',
@ -134,6 +135,23 @@ export default {
// Round options // Round options
roundRadius: { count: 10, min: 0, max: 50 }, roundRadius: { count: 10, min: 0, max: 50 },
roundRender: { bool: true }, roundRender: { bool: true },
scaleboxType: { dflt: 'scalebox' , list: ['scalebox', 'miniscale'] } scaleboxType: { dflt: 'scalebox' , list: ['scalebox', 'miniscale'] },
// Logo options
sprinkleScale: { pct: 100, min: 10, max: 200 },
sprinkleRotate: { deg: 0, min: -360, max: 360 },
sprinkleSnippet: {
dflt: 'notch',
list: [
'notch',
'bnotch',
'button',
'buttonhole',
'buttonhole-start',
'buttonhole-end',
'snap-stud',
'snap-socket',
'logo',
]
},
} }
} }

View file

@ -17,7 +17,7 @@ import mirror from '@freesewing/plugin-mirror'
import notches from '@freesewing/plugin-notches' 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 scalebox from '@freesewing/plugin-scalebox'
//import sprinkle from '@freesewing/plugin-sprinkle' import sprinkle from '@freesewing/plugin-sprinkle'
//import svgattr from '@freesewing/plugin-svgattr' //import svgattr from '@freesewing/plugin-svgattr'
//import theme from '@freesewing/plugin-theme' //import theme from '@freesewing/plugin-theme'
//import title from '@freesewing/plugin-title' //import title from '@freesewing/plugin-title'
@ -39,7 +39,7 @@ import draftMirror from './plugin-mirror'
import draftNotches from './plugin-notches' import draftNotches from './plugin-notches'
import draftRound from './plugin-round' import draftRound from './plugin-round'
import draftScalebox from './plugin-scalebox' import draftScalebox from './plugin-scalebox'
//import draftSprinkle from './plugin-sprinkle' import draftSprinkle from './plugin-sprinkle'
//import draftSvgattr from './plugin-svgattr' //import draftSvgattr from './plugin-svgattr'
//import draftTheme from './plugin-theme' //import draftTheme from './plugin-theme'
//import draftTitle from './plugin-title' //import draftTitle from './plugin-title'
@ -67,7 +67,7 @@ const plugins = [
notches, notches,
round, round,
scalebox, scalebox,
// sprinkle, sprinkle,
// svgattr, // svgattr,
// theme, // theme,
// title, // title,
@ -91,7 +91,7 @@ const methods = {
draftNotches, draftNotches,
draftRound, draftRound,
draftScalebox, draftScalebox,
// draftSprinkle, draftSprinkle,
// draftSvgattr, // draftSvgattr,
// draftTheme, // draftTheme,
// draftTitle, // draftTitle,

View file

@ -0,0 +1,32 @@
const draftScalebox = part => {
const { Point, points, Path, paths, options, macro } = part.shorthand()
if (['sprinkle', 'all'].indexOf(options.plugin) !== -1) {
points.center = new Point(0,0)
points.top = new Point(0,40)
const on = []
for (let i=0;i<360;i+=45) {
points[`s${i}`] = points.top.rotate(i, points.center)
on.push(`s${i}`)
}
macro('sprinkle', {
on,
snippet: options.sprinkleSnippet,
scale: options.sprinkleScale,
rotate: options.sprinkleRotate
})
paths.box = new Path()
.move(new Point(-50, -50))
.line(new Point(50, 50))
}
return part
}
export default draftScalebox