1
0
Fork 0
freesewing/packages/charlie/src/index.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

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'
// 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
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']) {
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
Pattern.prototype.draftBack = (part) => draftBack(part)
Pattern.prototype.draftFront = (part) => draftFront(part)
2021-01-30 16:30:45 +01:00
export default Pattern