store methods don't become properties on shorthand
This commit is contained in:
parent
aaa25b76f3
commit
49748a7c00
25 changed files with 95 additions and 80 deletions
|
@ -65,7 +65,6 @@ export const back = {
|
|||
measurements,
|
||||
log,
|
||||
part,
|
||||
addCut,
|
||||
}) => {
|
||||
// Get to work
|
||||
points.cbNeck = new Point(0, measurements.neck * options.backNeckCutout)
|
||||
|
@ -270,7 +269,7 @@ export const back = {
|
|||
on: ['armholePitch', 'bustCenter'],
|
||||
})
|
||||
|
||||
addCut()
|
||||
if (typeof store.addCut === 'function') store.addCut()
|
||||
|
||||
if (sa) paths.sa = paths.saBase.offset(sa).attr('class', 'fabric sa')
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ function draftCarlitaFront({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
/**
|
||||
* we're adding half of the proportionate amount of chest east for the bust span
|
||||
|
@ -349,9 +348,9 @@ function draftCarlitaFront({
|
|||
.attr('class', 'fabric help')
|
||||
|
||||
if (complete) {
|
||||
if (typeof addCut === 'function') {
|
||||
addCut()
|
||||
addCut({ material: 'lining' })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut()
|
||||
store.addCut({ material: 'lining' })
|
||||
}
|
||||
snippets.button1Left = new Snippet('button', points.button1Left).attr('data-scale', 2)
|
||||
snippets.button1Right = new Snippet('button', points.button1Right).attr('data-scale', 2)
|
||||
|
|
|
@ -13,7 +13,6 @@ function draftCarlitaSide({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
// Give points their original names
|
||||
for (let i of store.get('side')) points[i] = points[i + 'Rot2'].clone()
|
||||
|
@ -39,9 +38,9 @@ function draftCarlitaSide({
|
|||
paths.seam = paths.saBase.clone().line(points.hem).close().attr('class', 'fabric')
|
||||
|
||||
if (complete) {
|
||||
if (typeof addCut === 'function') {
|
||||
addCut()
|
||||
addCut({ material: 'lining' })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut()
|
||||
store.addCut({ material: 'lining' })
|
||||
}
|
||||
points.title = points.bustPoint.shiftFractionTowards(points.waist, 0.5)
|
||||
macro('title', {
|
||||
|
|
|
@ -18,7 +18,6 @@ function draftCarltonBack({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
calculateRatios(part)
|
||||
// Belt width
|
||||
|
@ -98,10 +97,18 @@ function draftCarltonBack({
|
|||
.line(points.bpStart)
|
||||
.attr('class', 'dashed')
|
||||
|
||||
addCut()
|
||||
addCut({ cut: 2, material: 'lining' })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut()
|
||||
store.addCut({ cut: 2, material: 'lining' })
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
macro('title', {
|
||||
at: points.title,
|
||||
nr: '2',
|
||||
title: 'back',
|
||||
})
|
||||
|
||||
macro('sprinkle', {
|
||||
snippet: 'bnotch',
|
||||
on: ['shoulder', 'bpTriangleTip'],
|
||||
|
|
|
@ -13,7 +13,6 @@ function draftCarltonBelt({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
let length = 1.6 * (store.get('cbToDart') + store.get('dartToSide'))
|
||||
let width = store.get('beltWidth')
|
||||
|
@ -50,7 +49,7 @@ function draftCarltonBelt({
|
|||
.close()
|
||||
.attr('class', 'fabric')
|
||||
|
||||
addCut({ cut: 4 })
|
||||
if (typeof store.addCut === 'function') store.addCut({ cut: 4 })
|
||||
if (complete) {
|
||||
snippets.button = new Snippet('button', points.button).attr('data-scale', 2)
|
||||
points.title = new Point(points.bottomRight.x / 2, points.bottomRight.y / 2)
|
||||
|
|
|
@ -12,7 +12,6 @@ function draftCarltonChestPocketBag({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
points.topLeft = new Point(0, 0)
|
||||
points.bottomRight = new Point(
|
||||
|
@ -44,7 +43,7 @@ function draftCarltonChestPocketBag({
|
|||
.line(points.startRight)
|
||||
.attr('class', 'lining dashed')
|
||||
|
||||
addCut({ material: 'lining' })
|
||||
if (typeof store.addCut === 'function') store.addCut({ material: 'lining' })
|
||||
|
||||
if (complete) {
|
||||
points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
||||
|
|
|
@ -11,7 +11,6 @@ function draftCarltonChestPocketWelt({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
points.topLeft = new Point(0, 0)
|
||||
points.bottomRight = new Point(store.get('chestPocketWidth') * 2, store.get('chestPocketHeight'))
|
||||
|
@ -31,8 +30,10 @@ function draftCarltonChestPocketWelt({
|
|||
|
||||
paths.fold = new Path().move(points.topMid).line(points.bottomMid).attr('class', 'dashed')
|
||||
|
||||
addCut()
|
||||
addCut({ material: 'lmhCanvas' })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut()
|
||||
store.addCut({ material: 'lmhCanvas' })
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
points.title = new Point(points.bottomRight.x / 4, points.bottomRight.y / 2)
|
||||
|
|
|
@ -16,7 +16,7 @@ function draftCarltonCollar({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
store,
|
||||
}) {
|
||||
// We're going to slash and spread this collar. Slashing first:
|
||||
// Divide top in 5 parts
|
||||
|
@ -187,9 +187,11 @@ function draftCarltonCollar({
|
|||
grainline: true,
|
||||
})
|
||||
|
||||
addCut({ cut: 1 })
|
||||
addCut({ cut: 1, bias: true })
|
||||
addCut({ cut: 2, material: 'lining', bias: true, ignoreOnFold: true })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut({ cut: 1 })
|
||||
store.addCut({ cut: 1, bias: true })
|
||||
store.addCut({ cut: 2, material: 'lining', bias: true, ignoreOnFold: true })
|
||||
}
|
||||
|
||||
points.title = points.standTopCp.clone()
|
||||
macro('title', {
|
||||
|
|
|
@ -14,7 +14,6 @@ function draftCarltonCollarStand({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
let height = measurements.chest * options.collarHeight
|
||||
let length = store.get('frontCollarLength') + store.get('backCollarLength')
|
||||
|
@ -46,8 +45,10 @@ function draftCarltonCollarStand({
|
|||
.close()
|
||||
.attr('class', 'fabric')
|
||||
|
||||
addCut()
|
||||
addCut({ cut: 1, material: 'lmhCanvas' })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut()
|
||||
store.addCut({ cut: 1, material: 'lmhCanvas' })
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
points.title = points.bottomLeftCp.clone()
|
||||
|
|
|
@ -12,7 +12,6 @@ function draftCarltonCuffFacing({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
points.topLeft = new Point(0, 0)
|
||||
points.bottomRight = new Point(
|
||||
|
@ -47,8 +46,10 @@ function draftCarltonCuffFacing({
|
|||
.close()
|
||||
.attr('class', 'fabric')
|
||||
|
||||
addCut()
|
||||
addCut({ cut: 2, material: 'lmhCanvas' })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut()
|
||||
store.addCut({ cut: 2, material: 'lmhCanvas' })
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
||||
|
|
|
@ -19,7 +19,6 @@ function draftCarltonFront({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
calculateRatios(part)
|
||||
|
||||
|
@ -301,7 +300,7 @@ function draftCarltonFront({
|
|||
.close()
|
||||
.attr('class', 'fabric help')
|
||||
|
||||
addCut()
|
||||
if (typeof store.addCut === 'function') store.addCut()
|
||||
|
||||
if (complete) {
|
||||
snippets.button1Left = new Snippet('button', points.button1Left).attr('data-scale', 2)
|
||||
|
|
|
@ -13,7 +13,6 @@ function draftCarltonInnerPocketBag({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
points.topLeft = new Point(0, 0)
|
||||
points.bottomRight = new Point(
|
||||
|
@ -45,7 +44,7 @@ function draftCarltonInnerPocketBag({
|
|||
.line(points.startRight)
|
||||
.attr('class', 'lining dashed')
|
||||
|
||||
addCut({ material: 'lining' })
|
||||
if (typeof store.addCut === 'function') store.addCut({ material: 'lining' })
|
||||
|
||||
if (complete) {
|
||||
points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
||||
|
|
|
@ -11,7 +11,6 @@ function draftCarltonInnerPocketTab({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
points.topLeft = new Point(0, 0)
|
||||
points.topRight = new Point(store.get('innerPocketWidth') * 1.2, 0)
|
||||
|
@ -31,7 +30,7 @@ function draftCarltonInnerPocketTab({
|
|||
|
||||
paths.hint = new Path().move(points.top).line(points.bottom).attr('class', 'lining dashed')
|
||||
|
||||
addCut({ cut: 1, material: 'lining' })
|
||||
if (typeof store.addCut === 'function') store.addCut({ cut: 1, material: 'lining' })
|
||||
|
||||
if (complete) {
|
||||
points.title = points.top.shiftFractionTowards(points.bottom, 0.5)
|
||||
|
|
|
@ -11,7 +11,6 @@ function draftCarltonInnerPocketWelt({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
points.topLeft = new Point(0, 0)
|
||||
points.bottomRight = new Point(
|
||||
|
@ -50,8 +49,10 @@ function draftCarltonInnerPocketWelt({
|
|||
.close()
|
||||
.attr('class', 'lashed')
|
||||
|
||||
addCut()
|
||||
addCut({ material: 'lmhCanvas' })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut()
|
||||
store.addCut({ material: 'lmhCanvas' })
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
||||
|
|
|
@ -12,7 +12,6 @@ function draftCarltonPocket({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
points.topLeft = new Point(0, 0)
|
||||
points.bottomRight = new Point(store.get('pocketWidth'), store.get('pocketHeight'))
|
||||
|
@ -54,7 +53,7 @@ function draftCarltonPocket({
|
|||
|
||||
paths.fold = new Path().move(points.topLeft).line(points.topRight).attr('class', 'fabric dashed')
|
||||
|
||||
addCut()
|
||||
if (typeof store.addCut === 'function') store.addCut()
|
||||
|
||||
if (complete) {
|
||||
points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
||||
|
|
|
@ -12,7 +12,6 @@ function draftCarltonPocketFlap({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
points.topLeft = new Point(0, 0)
|
||||
points.bottomRight = new Point(store.get('pocketWidth'), store.get('pocketFlapHeight'))
|
||||
|
@ -46,8 +45,10 @@ function draftCarltonPocketFlap({
|
|||
|
||||
paths.seam = paths.seam.line(points.topRight).line(points.topLeft).close().attr('class', 'fabric')
|
||||
|
||||
addCut({ cut: 4 })
|
||||
addCut({ material: 'lmhCanvas' })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut({ cut: 4 })
|
||||
store.addCut({ material: 'lmhCanvas' })
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
||||
|
|
|
@ -12,7 +12,6 @@ function draftCarltonPocketLining({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
points.topLeft = points.bottomLeft.shiftFractionTowards(points.topLeft, 0.75)
|
||||
points.topRight = new Point(points.bottomRight.x, points.topLeft.y)
|
||||
|
@ -46,7 +45,7 @@ function draftCarltonPocketLining({
|
|||
|
||||
delete paths.fold
|
||||
|
||||
addCut({ material: 'lining' })
|
||||
if (typeof store.addCut === 'function') store.addCut({ material: 'lining' })
|
||||
|
||||
if (complete) {
|
||||
points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
||||
|
|
|
@ -13,7 +13,6 @@ function draftCarltonTail({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
let length = store.get('waistToHem') - store.get('beltWidth') / 2
|
||||
|
||||
|
@ -69,8 +68,10 @@ function draftCarltonTail({
|
|||
.line(points.fold5Bottom)
|
||||
.attr('class', 'fabric dashed')
|
||||
|
||||
addCut()
|
||||
addCut({ material: 'lining' })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut()
|
||||
store.addCut({ material: 'lining' })
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
points.title = points.fold4Top.shiftFractionTowards(points.waistBottom, 0.5)
|
||||
|
|
|
@ -16,7 +16,6 @@ function draftCarltonTopSleeve({
|
|||
Snippet,
|
||||
snippets,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
// Add cuff
|
||||
let length = measurements.shoulderToWrist * options.cuffLength
|
||||
|
@ -55,10 +54,17 @@ function draftCarltonTopSleeve({
|
|||
.close()
|
||||
.attr('class', 'fabric')
|
||||
|
||||
addCut()
|
||||
addCut({ material: 'lining' })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut()
|
||||
store.addCut({ material: 'lining' })
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
macro('title', {
|
||||
at: points.armCenter,
|
||||
nr: 3,
|
||||
title: 'topsleeve',
|
||||
})
|
||||
macro('grainline', {
|
||||
from: points.boxBottom,
|
||||
to: points.top,
|
||||
|
|
|
@ -15,7 +15,6 @@ function draftCarltonUnderSleeve({
|
|||
paths,
|
||||
Path,
|
||||
part,
|
||||
addCut,
|
||||
}) {
|
||||
// Add cuff
|
||||
let length = measurements.shoulderToWrist * options.cuffLength
|
||||
|
@ -51,9 +50,18 @@ function draftCarltonUnderSleeve({
|
|||
.close()
|
||||
.attr('class', 'fabric')
|
||||
|
||||
addCut()
|
||||
addCut({ material: 'lining' })
|
||||
if (typeof store.addCut === 'function') {
|
||||
store.addCut()
|
||||
store.addCut({ material: 'lining' })
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
macro('title', {
|
||||
at: points.armCenter,
|
||||
nr: 4,
|
||||
title: 'undersleeve',
|
||||
})
|
||||
|
||||
macro('grainline', {
|
||||
from: points.boxBottom,
|
||||
to: new Point(points.top.x, points.usLeftEdge.y),
|
||||
|
|
|
@ -135,15 +135,6 @@ Part.prototype.shorthand = function () {
|
|||
utils: utils,
|
||||
Bezier: Bezier,
|
||||
}
|
||||
// Add top-level store methods and add a part name parameter
|
||||
const partName = this.name
|
||||
for (const [key, method] of Object.entries(this.context.store)) {
|
||||
if (typeof method === 'function')
|
||||
shorthand[key] = function (...args) {
|
||||
return method(partName, ...args)
|
||||
}
|
||||
}
|
||||
|
||||
// We'll need this
|
||||
let self = this
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ Pattern.prototype.createPartForSet = function (partName, set = 0) {
|
|||
Pattern.prototype.draftPartForSet = function (partName, set) {
|
||||
if (typeof this.config.parts?.[partName]?.draft === 'function') {
|
||||
this.activePart = partName
|
||||
this.setStores[set].set('activePart', partName)
|
||||
try {
|
||||
this.__runHooks('prePartDraft')
|
||||
const result = this.config.parts[partName].draft(this.parts[set][partName].shorthand())
|
||||
|
|
|
@ -19,7 +19,6 @@ export const pluginCutlist = plugin
|
|||
/**
|
||||
* Add a set of cutting instructions for the part
|
||||
* @param {Store} store the Store
|
||||
* @param {string} partName the name of the part
|
||||
* @param {Object} so a set of cutting instructions for a material
|
||||
* @param {number} so.cut = 2 the number of pieces to cut from the specified fabric
|
||||
* @param {string} so.material = fabric the name of the material to cut from
|
||||
|
@ -27,8 +26,9 @@ export const pluginCutlist = plugin
|
|||
* @param {boolean} so.bias = false should the pieces in these cutting instructions be cut on the bias
|
||||
* @param {boolean} so.ignoreOnFold should these cutting instructions ignore any cutOnFold information set by the part
|
||||
*/
|
||||
function addCut(store, partName, so = {}) {
|
||||
function addCut(store, so = {}) {
|
||||
const { cut = 2, material = 'fabric', identical = false, bias = false, ignoreOnFold = false } = so
|
||||
const partName = store.get('activePart')
|
||||
if (cut === false) {
|
||||
if (material === false) store.unset(['cutlist', partName, 'materials'])
|
||||
else store.unset(['cutlist', partName, 'materials', material])
|
||||
|
@ -50,12 +50,13 @@ function addCut(store, partName, so = {}) {
|
|||
}
|
||||
|
||||
/** Method to remove the cut info */
|
||||
function removeCut(store, partName, material = false) {
|
||||
return addCut(store, partName, { cut: false, material })
|
||||
function removeCut(store, material = false) {
|
||||
return addCut(store, { cut: false, material })
|
||||
}
|
||||
|
||||
/** Method to add the grain info */
|
||||
function setGrain(store, partName, grain = false) {
|
||||
function setGrain(store, grain = false) {
|
||||
const partName = store.get('activePart')
|
||||
const path = ['cutlist', partName, 'grain']
|
||||
if (grain === false) return store.unset(path)
|
||||
if (typeof grain !== 'number') {
|
||||
|
@ -66,7 +67,8 @@ function setGrain(store, partName, grain = false) {
|
|||
}
|
||||
|
||||
/** Method to add the cutOnFold info */
|
||||
function setCutOnFold(store, partName, p1, p2) {
|
||||
function setCutOnFold(store, p1, p2) {
|
||||
const partName = store.get('activePart')
|
||||
const path = ['cutlist', partName, 'cutOnFold']
|
||||
if (p1 === false && typeof p2 === 'undefined') {
|
||||
return store.unset(path)
|
||||
|
|
|
@ -18,7 +18,7 @@ export const plugin = {
|
|||
},
|
||||
},
|
||||
macros: {
|
||||
cutonfold: function (so, { points, paths, Path, complete, setCutOnFold, setGrain, scale }) {
|
||||
cutonfold: function (so, { points, paths, Path, complete, store, scale }) {
|
||||
if (so === false) {
|
||||
delete points.cutonfoldFrom
|
||||
delete points.cutonfoldTo
|
||||
|
@ -26,8 +26,8 @@ export const plugin = {
|
|||
delete points.cutonfoldVia2
|
||||
delete paths.cutonfoldCutonfold
|
||||
// setCutOnFold relies on plugin-cutlist
|
||||
if (typeof setCutOnFold === 'function') {
|
||||
setCutOnFold(false) // Restore default
|
||||
if (typeof store.setCutOnFold === 'function') {
|
||||
store.setCutOnFold(false) // Restore default
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ export const plugin = {
|
|||
prefix: 'cutonfold',
|
||||
...so,
|
||||
}
|
||||
if (typeof setCutOnFold === 'function') {
|
||||
setCutOnFold(so.from, so.to)
|
||||
if (so.grainline) setGrain(so.from.angle(so.to))
|
||||
if (typeof store.setCutOnFold === 'function') {
|
||||
store.setCutOnFold(so.from, so.to)
|
||||
if (so.grainline) store.setGrain(so.from.angle(so.to))
|
||||
}
|
||||
if (complete) {
|
||||
points[so.prefix + 'From'] = so.from.shiftFractionTowards(so.to, so.margin / 100)
|
||||
|
|
|
@ -19,12 +19,14 @@ export const plugin = {
|
|||
},
|
||||
},
|
||||
macros: {
|
||||
grainline: function (so = {}, { points, paths, Path, complete, setGrain }) {
|
||||
grainline: function (so = {}, { points, paths, Path, complete, store }) {
|
||||
if (so === false) {
|
||||
delete points.grainlineFrom
|
||||
delete points.grainlineTo
|
||||
delete paths.grainline
|
||||
setGrain(90) // Restoring default
|
||||
if (typeof store.setGrain === 'function') {
|
||||
setGrain(false) // Restoring default
|
||||
}
|
||||
return true
|
||||
}
|
||||
so = {
|
||||
|
@ -32,8 +34,8 @@ export const plugin = {
|
|||
...so,
|
||||
}
|
||||
// setGrain relies on plugin-cutlist
|
||||
if (typeof setGrain === 'function') {
|
||||
setGrain(so.from.angle(so.to))
|
||||
if (typeof store.setGrain === 'function') {
|
||||
store.setGrain(so.from.angle(so.to))
|
||||
}
|
||||
if (complete) {
|
||||
points.grainlineFrom = so.from.shiftFractionTowards(so.to, 0.05)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue