2021-01-30 16:30:45 +01:00
|
|
|
import freesewing from '@freesewing/core'
|
|
|
|
import Titan from '@freesewing/titan'
|
|
|
|
import plugins from '@freesewing/plugin-bundle'
|
2021-03-13 09:58:17 +01:00
|
|
|
import mirrorPlugin from '@freesewing/plugin-mirror'
|
2021-01-30 16:30:45 +01:00
|
|
|
import config from '../config'
|
|
|
|
// Parts
|
|
|
|
import draftBack from './back'
|
|
|
|
import draftFront from './front'
|
2021-03-13 09:58:17 +01:00
|
|
|
import draftWaistband from './waistband'
|
|
|
|
import draftWaistbandButtonSide from './waistband-button-side'
|
|
|
|
import draftWaistbandButtonholeSide from './waistband-buttonhole-side'
|
|
|
|
import draftFrontPocket from './front-pocket'
|
|
|
|
import draftBackPocket from './back-pocket'
|
|
|
|
import draftBackPocketFacing from './back-pocket-facing'
|
2021-01-30 16:30:45 +01:00
|
|
|
|
2021-03-09 19:21:50 +01:00
|
|
|
// Hack the waistHeight option to make room for waistband
|
|
|
|
const waistbandPlugin = {
|
|
|
|
name: 'charlieWaistbandPlugin',
|
|
|
|
version: config.version,
|
|
|
|
hooks: {
|
|
|
|
preDraft: function ({ settings }) {
|
|
|
|
// Reduce the waistHeight option by 25% to make room for the waistband
|
|
|
|
// We could also just use negative numbers, but that might confuse the user
|
|
|
|
settings.options.waistHeight -= settings.options.waistbandReduction
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-30 16:30:45 +01:00
|
|
|
// Create design
|
2021-03-13 09:58:17 +01:00
|
|
|
const Pattern = new freesewing.Design(config, [plugins, mirrorPlugin, waistbandPlugin])
|
2021-01-30 16:30:45 +01:00
|
|
|
|
|
|
|
// Attach titan draft methods to prototype
|
|
|
|
for (let p of ['Front', 'Back']) {
|
2021-03-09 19:21:50 +01:00
|
|
|
Pattern.prototype[`draftTitan${p}`] = function (part) {
|
2021-01-30 16:30:45 +01:00
|
|
|
return new Titan(this.settings)[`draft${p}`](part)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Attach charlie draft methods to prototype
|
2021-03-09 19:21:50 +01:00
|
|
|
Pattern.prototype.draftBack = (part) => draftBack(part)
|
|
|
|
Pattern.prototype.draftFront = (part) => draftFront(part)
|
2021-03-13 09:58:17 +01:00
|
|
|
Pattern.prototype.draftWaistband = (part) => draftWaistband(part)
|
|
|
|
Pattern.prototype.draftWaistbandButtonSide = (part) => draftWaistbandButtonSide(part)
|
|
|
|
Pattern.prototype.draftWaistbandButtonholeSide = (part) => draftWaistbandButtonholeSide(part)
|
|
|
|
Pattern.prototype.draftFrontPocket = (part) => draftFrontPocket(part)
|
|
|
|
Pattern.prototype.draftBackPocket = (part) => draftBackPocket(part)
|
|
|
|
Pattern.prototype.draftBackPocketFacing = (part) => draftBackPocketFacing(part)
|
2021-01-30 16:30:45 +01:00
|
|
|
|
|
|
|
export default Pattern
|