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

57 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-08-03 15:03:33 +02:00
import freesewing from '@freesewing/core'
import plugins from '@freesewing/plugin-bundle'
import buttons from '@freesewing/plugin-buttons'
import bust from '@freesewing/plugin-bust'
import Bent from '@freesewing/bent'
import Carlton from '@freesewing/carlton'
import config from '../config'
2019-04-06 12:30:11 +02:00
// Parts
2019-08-03 15:03:33 +02:00
import draftFront from './front'
import draftSide from './side'
2019-04-06 12:30:11 +02:00
// Create new design
2019-08-03 15:03:33 +02:00
const Pattern = new freesewing.Design(config, [plugins, buttons, bust])
2019-04-06 12:30:11 +02:00
2019-08-03 15:03:33 +02:00
let fromBent = ['Base', 'Front', 'Back', 'Sleeve', 'TopSleeve', 'UnderSleeve']
2019-04-06 12:30:11 +02:00
// Attach draft methods from Bent to prototype
for (let m of fromBent) {
2021-01-31 09:22:15 +01:00
Pattern.prototype['draftBent' + m] = function (part) {
2019-08-03 15:03:33 +02:00
return new Bent(this.settings)['draft' + m](part)
}
2019-04-06 12:30:11 +02:00
}
// Attach draft methods from Carlton to prototype
for (let m of [
2019-08-03 15:03:33 +02:00
'draftBack',
'draftTail',
'draftTopSleeve',
'draftUnderSleeve',
'draftBelt',
'draftCollarStand',
'draftCollar',
'draftCuffFacing',
'draftPocket',
'draftPocketFlap',
'draftPocketLining',
'draftChestPocketWelt',
'draftChestPocketBag',
'draftInnerPocketWelt',
'draftInnerPocketBag',
'draftInnerPocketTab'
2019-04-06 12:30:11 +02:00
]) {
2021-01-31 09:22:15 +01:00
Pattern.prototype[m] = function (part) {
2019-08-03 15:03:33 +02:00
return new Carlton(this.settings)[m](part)
}
2019-04-06 12:30:11 +02:00
}
2021-01-31 09:22:15 +01:00
Pattern.prototype.draftCarltonFront = function (part) {
2019-08-03 15:03:33 +02:00
return new Carlton(this.settings).draftFront(part)
}
2019-04-06 12:30:11 +02:00
// Attach own draft methods to prototype
2019-08-03 15:03:33 +02:00
Pattern.prototype.draftFront = draftFront
Pattern.prototype.draftSide = draftSide
2019-04-06 12:30:11 +02:00
2019-08-03 15:03:33 +02:00
export default Pattern