2021-01-30 16:30:45 +01:00
|
|
|
import freesewing from '@freesewing/core'
|
|
|
|
import Titan from '@freesewing/titan'
|
|
|
|
import plugins from '@freesewing/plugin-bundle'
|
|
|
|
|
|
|
|
import config from '../config'
|
|
|
|
// Parts
|
|
|
|
import draftBack from './back'
|
|
|
|
import draftFront from './front'
|
|
|
|
|
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-09 19:21:50 +01:00
|
|
|
const Pattern = new freesewing.Design(config, [plugins, 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-01-30 16:30:45 +01:00
|
|
|
|
|
|
|
export default Pattern
|