2020-08-02 19:17:06 +02:00
|
|
|
export default function (part) {
|
|
|
|
/*
|
|
|
|
* Helper method to draw the inseam path
|
|
|
|
*/
|
|
|
|
const drawInseam = () =>
|
|
|
|
new Path().move(points.fork).curve(points.forkCp2, points.kneeInCp1, points.floorIn)
|
|
|
|
/*
|
|
|
|
* Helper method to draw the outseam path
|
|
|
|
*/
|
|
|
|
const drawOutseam = (noPocketFlap = false) => {
|
|
|
|
let waistOut = points.styleWaistOut || points.waistOut
|
|
|
|
let outseam = new Path()
|
|
|
|
.move(points.floorOut)
|
|
|
|
.curve(points.kneeOutCp2, points.seatOut, waistOut)
|
|
|
|
if (!options.frontPockets || noPocketFlap) return outseam
|
|
|
|
else {
|
|
|
|
// Split outseam at top and bottom, and inject pocket flap
|
|
|
|
let split = outseam.split(points.pocketFlapBottomIn)
|
|
|
|
return split[0]
|
|
|
|
.join(
|
|
|
|
new Path()
|
|
|
|
.move(points.pocketFlapBottomIn)
|
|
|
|
.line(points.pocketFlapBottomOut)
|
|
|
|
.line(points.pocketFlapTopOut)
|
|
|
|
.line(points.pocketFlapTopIn)
|
|
|
|
)
|
|
|
|
.join(split[1].split(points.pocketFlapTopIn).pop())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Helper method to draw the outline path
|
|
|
|
*/
|
|
|
|
const drawPath = () => {
|
|
|
|
let waistIn = points.styleWaistIn || points.waistIn
|
|
|
|
return drawInseam()
|
|
|
|
.line(points.floorOut)
|
|
|
|
.join(drawOutseam())
|
|
|
|
.line(waistIn)
|
|
|
|
.line(points.crossSeamCurveStart)
|
|
|
|
.curve(points.crossSeamCurveCp1, points.crossSeamCurveCp2, points.fork)
|
|
|
|
.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Shorthand call
|
2021-10-08 17:32:12 +02:00
|
|
|
let {
|
|
|
|
store,
|
|
|
|
sa,
|
|
|
|
points,
|
|
|
|
Path,
|
|
|
|
paths,
|
|
|
|
options,
|
|
|
|
measurements,
|
|
|
|
complete,
|
|
|
|
paperless,
|
|
|
|
macro,
|
|
|
|
absoluteOptions,
|
|
|
|
} = part.shorthand()
|
2020-08-02 19:17:06 +02:00
|
|
|
|
|
|
|
// Adapt bottom leg width based on heel & heel ease
|
|
|
|
let quarterHeel = (measurements.heel * (1 + options.heelEase) * options.legBalance) / 2
|
2020-08-08 15:19:43 +02:00
|
|
|
points.floorOut = points.floor.shift(0, quarterHeel)
|
|
|
|
points.floorIn = points.floor.shift(180, quarterHeel)
|
2020-08-02 19:17:06 +02:00
|
|
|
points.kneeOut = points.knee.shift(0, quarterHeel)
|
|
|
|
points.kneeOutCp2 = points.kneeOut
|
|
|
|
points.kneeIn = points.knee.shift(180, quarterHeel)
|
|
|
|
points.kneeInCp1 = points.kneeIn
|
|
|
|
|
2020-08-08 15:19:43 +02:00
|
|
|
// Shorter leg if we have an elasticated hem
|
2021-09-15 20:20:59 +02:00
|
|
|
store.set('ankleElastic', absoluteOptions.ankleElastic)
|
2020-08-08 15:19:43 +02:00
|
|
|
if (options.elasticatedHem) {
|
|
|
|
for (const p of ['floor', 'floorIn', 'floorOut'])
|
2021-09-11 16:43:12 +02:00
|
|
|
points[p] = points[p].shift(90, store.get('ankleElastic'))
|
2020-08-08 15:19:43 +02:00
|
|
|
}
|
|
|
|
|
2020-08-02 19:17:06 +02:00
|
|
|
// Adapt waist so we can get these pants over our bum without a zipper
|
|
|
|
let delta =
|
|
|
|
(measurements.seat * options.legBalance) / 2 - points.styleWaistIn.dist(points.styleWaistOut)
|
|
|
|
let angle = points.styleWaistIn.angle(points.styleWaistOut)
|
|
|
|
points.styleWaistOut = points.styleWaistOut.shift(angle, delta)
|
|
|
|
points.seatOut = points.seatOut.shift(angle, delta)
|
|
|
|
|
|
|
|
// Cut the top of our pants short to make room for the waistband/elastic
|
2021-10-08 18:11:01 +02:00
|
|
|
store.set('waistbandWidth', absoluteOptions.waistbandWidth)
|
2021-09-11 16:43:12 +02:00
|
|
|
points.styleWaistOut = drawOutseam(true).reverse().shiftAlong(store.get('waistbandWidth'))
|
2020-08-02 19:17:06 +02:00
|
|
|
points.styleWaistIn = points.styleWaistIn.shiftTowards(
|
|
|
|
points.crossSeamCurveStart,
|
2021-09-11 16:43:12 +02:00
|
|
|
store.get('waistbandWidth')
|
2020-08-02 19:17:06 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Add the (optional) front pocket extention
|
|
|
|
if (options.frontPockets) {
|
|
|
|
let outseam = drawOutseam(true).reverse()
|
2021-11-08 19:23:28 +01:00
|
|
|
points.pocketFlapTopIn = outseam.shiftAlong(absoluteOptions.frontPocketFlapSize)
|
2020-08-02 19:17:06 +02:00
|
|
|
points.pocketFlapBottomIn = outseam.shiftAlong(
|
|
|
|
options.frontPocketFlapSize + measurements.heel * options.frontPocketHeelRatio
|
|
|
|
)
|
|
|
|
points.pocketFlapTopOut = points.pocketFlapTopIn
|
2021-11-08 19:23:28 +01:00
|
|
|
.shiftTowards(points.pocketFlapBottomIn, absoluteOptions.frontPocketFlapSize)
|
2020-08-02 19:17:06 +02:00
|
|
|
.rotate(90, points.pocketFlapTopIn)
|
|
|
|
points.pocketFlapBottomOut = points.pocketFlapBottomIn
|
2021-11-08 19:23:28 +01:00
|
|
|
.shiftTowards(points.pocketFlapTopIn, absoluteOptions.frontPocketFlapSize)
|
2020-08-02 19:17:06 +02:00
|
|
|
.rotate(-90, points.pocketFlapBottomIn)
|
|
|
|
points.pocketFlapBottomOut = points.pocketFlapTopOut.shiftOutwards(
|
|
|
|
points.pocketFlapBottomOut,
|
2021-11-08 19:23:28 +01:00
|
|
|
absoluteOptions.frontPocketFlapSize
|
2020-08-02 19:17:06 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-08-08 15:19:43 +02:00
|
|
|
// Add markings for the (optional) back pockets
|
|
|
|
if (options.backPockets) {
|
|
|
|
const pocketWidth = () =>
|
|
|
|
points.styleWaistOut.dist(points.styleWaistIn) * options.backPocketWidthRatio
|
|
|
|
let angle = points.styleWaistOut.angle(points.styleWaistIn)
|
|
|
|
points.pocketWaistCenter = points.styleWaistIn.shiftFractionTowards(
|
|
|
|
points.styleWaistOut,
|
|
|
|
options.backPocketWaistRatio
|
|
|
|
)
|
|
|
|
points.pocketCenter = points.pocketWaistCenter.shift(
|
|
|
|
angle + 90,
|
|
|
|
points.styleWaistIn.dist(points.crossSeamCurveStart) * options.backPocketHeightRatio
|
|
|
|
)
|
|
|
|
points.pocketLeft = points.pocketCenter.shift(angle, pocketWidth() / 2)
|
|
|
|
points.pocketRight = points.pocketLeft.rotate(180, points.pocketCenter)
|
|
|
|
// Pocket bag
|
|
|
|
points.pocketBagWaistLeft = points.pocketWaistCenter.shift(angle, pocketWidth() / 1.5)
|
|
|
|
points.pocketBagWaistRight = points.pocketBagWaistLeft.rotate(180, points.pocketWaistCenter)
|
|
|
|
points.pocketBagBottomCenter = points.pocketCenter.shift(angle + 90, pocketWidth() * 1.5)
|
|
|
|
points.pocketBagBottomLeft = points.pocketBagBottomCenter.shift(angle, pocketWidth() / 1.5)
|
|
|
|
points.pocketBagBottomRight = points.pocketBagBottomLeft.rotate(
|
|
|
|
180,
|
|
|
|
points.pocketBagBottomCenter
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-08-02 19:17:06 +02:00
|
|
|
// Now draw the outline
|
|
|
|
paths.seam = drawPath()
|
|
|
|
|
|
|
|
// Store inseam & outseam length
|
|
|
|
store.set('pacoInseamBack', drawInseam().length())
|
|
|
|
store.set('pacoOutseamBack', drawOutseam(true).length())
|
2020-08-09 17:42:09 +02:00
|
|
|
// Store top&ankle length
|
2020-08-02 19:17:06 +02:00
|
|
|
store.set('backWaist', points.styleWaistIn.dist(points.styleWaistOut))
|
2020-08-09 17:42:09 +02:00
|
|
|
store.set('backAnkle', points.floorIn.dist(points.floorOut))
|
2020-08-02 19:17:06 +02:00
|
|
|
|
2020-08-08 15:19:43 +02:00
|
|
|
if (complete) {
|
|
|
|
if (options.backPockets) {
|
|
|
|
paths.pocket = new Path()
|
|
|
|
.move(points.pocketLeft)
|
|
|
|
.line(points.pocketRight)
|
2020-08-08 16:01:46 +02:00
|
|
|
.attr('class', 'farbic lashed')
|
2020-08-08 15:19:43 +02:00
|
|
|
paths.pocketBag = new Path()
|
|
|
|
.move(points.pocketBagWaistLeft)
|
|
|
|
.line(points.pocketBagBottomLeft)
|
|
|
|
.line(points.pocketBagBottomRight)
|
|
|
|
.line(points.pocketBagWaistRight)
|
2020-08-08 16:01:46 +02:00
|
|
|
.attr('class', 'lining lashed')
|
2020-08-08 15:19:43 +02:00
|
|
|
macro('sprinkle', {
|
|
|
|
snippet: 'bnotch',
|
2021-04-24 10:16:31 +02:00
|
|
|
on: ['pocketLeft', 'pocketRight', 'pocketBagWaistLeft', 'pocketBagWaistRight'],
|
2020-08-08 15:19:43 +02:00
|
|
|
})
|
|
|
|
}
|
2020-08-08 16:01:46 +02:00
|
|
|
|
|
|
|
if (sa) {
|
2022-07-09 15:29:43 +02:00
|
|
|
const waistIn = points.styleWaistIn || points.waistIn
|
|
|
|
const hemSa = options.elasticatedHem ? sa : 4 * sa
|
2020-08-08 16:01:46 +02:00
|
|
|
paths.sa = drawInseam()
|
|
|
|
.offset(sa)
|
2022-07-09 15:29:43 +02:00
|
|
|
.line(points.floorIn.shift(180, sa).shift(-90, hemSa))
|
|
|
|
.line(points.floorOut.shift(0, sa).shift(-90, hemSa))
|
2020-08-08 16:01:46 +02:00
|
|
|
.join(drawOutseam().offset(sa).trim())
|
|
|
|
.join(
|
|
|
|
new Path()
|
|
|
|
.move(points.styleWaistOut)
|
|
|
|
.line(waistIn)
|
|
|
|
.line(points.crossSeamCurveStart)
|
|
|
|
.curve(points.crossSeamCurveCp1, points.crossSeamCurveCp2, points.fork)
|
|
|
|
.offset(sa)
|
|
|
|
)
|
|
|
|
.close()
|
|
|
|
.attr('class', 'fabric sa')
|
|
|
|
}
|
2021-11-08 19:36:47 +01:00
|
|
|
}
|
2020-08-08 16:01:46 +02:00
|
|
|
|
2021-11-08 19:36:47 +01:00
|
|
|
if (paperless) {
|
|
|
|
// Help construct cross seam
|
|
|
|
paths.hint = new Path()
|
|
|
|
.move(points.crossSeamCurveStart)
|
|
|
|
.line(points.crossSeamCurveMax)
|
|
|
|
.line(points.fork)
|
|
|
|
.attr('class', 'note lashed')
|
|
|
|
macro('hd', {
|
|
|
|
from: points.floorIn,
|
|
|
|
to: points.floorOut,
|
|
|
|
y: points.floorIn.y - 30,
|
|
|
|
})
|
|
|
|
macro('hd', {
|
|
|
|
from: points.floorIn,
|
|
|
|
to: points.floor,
|
|
|
|
y: points.floorIn.y - 15,
|
|
|
|
})
|
|
|
|
macro('hd', {
|
|
|
|
from: points.floor,
|
|
|
|
to: points.floorOut,
|
|
|
|
y: points.floorIn.y - 15,
|
|
|
|
})
|
|
|
|
macro('vd', {
|
|
|
|
from: points.floorOut,
|
|
|
|
to: points.styleWaistOut,
|
|
|
|
x:
|
|
|
|
(points.seatOut.x > points.styleWaistOut.x ? points.seatOut.x : points.styleWaistOut.x) +
|
|
|
|
sa +
|
|
|
|
15,
|
|
|
|
})
|
|
|
|
macro('vd', {
|
|
|
|
from: points.floorIn,
|
|
|
|
to: points.fork,
|
|
|
|
x: points.fork.x - sa - 15,
|
|
|
|
})
|
|
|
|
macro('vd', {
|
|
|
|
from: points.fork,
|
|
|
|
to: points.styleWaistIn,
|
|
|
|
x: points.fork.x - sa - 15,
|
|
|
|
})
|
|
|
|
macro('vd', {
|
|
|
|
from: points.floorIn,
|
|
|
|
to: points.styleWaistIn,
|
|
|
|
x: points.fork.x - sa - 30,
|
|
|
|
})
|
|
|
|
macro('vd', {
|
|
|
|
from: points.crossSeamCurveStart,
|
|
|
|
to: points.styleWaistIn,
|
|
|
|
x: points.crossSeamCurveStart.x - sa - 15,
|
|
|
|
})
|
|
|
|
macro('hd', {
|
|
|
|
from: points.styleWaistIn,
|
|
|
|
to: points.grainlineTop,
|
|
|
|
y: points.styleWaistIn.y - sa - 15,
|
|
|
|
})
|
|
|
|
macro('hd', {
|
|
|
|
from: points.crossSeamCurveStart,
|
|
|
|
to: points.grainlineTop,
|
|
|
|
y: points.styleWaistIn.y - sa - 30,
|
|
|
|
})
|
|
|
|
macro('hd', {
|
|
|
|
from: points.crossSeamCurveMax,
|
|
|
|
to: points.grainlineTop,
|
|
|
|
y: points.styleWaistIn.y - sa - 45,
|
|
|
|
})
|
|
|
|
macro('hd', {
|
|
|
|
from: points.fork,
|
|
|
|
to: points.grainlineTop,
|
|
|
|
y: points.styleWaistIn.y - sa - 60,
|
|
|
|
})
|
|
|
|
macro('hd', {
|
|
|
|
from: points.grainlineTop,
|
|
|
|
to: points.styleWaistOut,
|
|
|
|
y: points.styleWaistIn.y - sa - 15,
|
|
|
|
})
|
|
|
|
if (points.seatOut.x > points.styleWaistOut.x) {
|
2020-08-08 16:38:43 +02:00
|
|
|
macro('hd', {
|
2021-11-08 19:36:47 +01:00
|
|
|
from: points.grainlineTop,
|
|
|
|
to: points.seatOut,
|
|
|
|
y: points.styleWaistIn.y - sa - 30,
|
2020-08-08 16:38:43 +02:00
|
|
|
})
|
2021-11-08 19:36:47 +01:00
|
|
|
}
|
|
|
|
if (options.frontPockets) {
|
|
|
|
macro('ld', {
|
|
|
|
from: points.styleWaistOut,
|
|
|
|
to: points.pocketFlapTopIn,
|
|
|
|
d: -15,
|
2020-08-08 16:38:43 +02:00
|
|
|
})
|
2021-11-08 19:36:47 +01:00
|
|
|
macro('ld', {
|
|
|
|
from: points.pocketFlapTopIn,
|
|
|
|
to: points.pocketFlapBottomIn,
|
|
|
|
d: -15,
|
2020-08-08 16:38:43 +02:00
|
|
|
})
|
2021-11-08 19:36:47 +01:00
|
|
|
macro('ld', {
|
|
|
|
from: points.pocketFlapTopIn,
|
|
|
|
to: points.pocketFlapTopOut,
|
|
|
|
d: -15,
|
2020-08-08 16:38:43 +02:00
|
|
|
})
|
2021-11-08 19:36:47 +01:00
|
|
|
}
|
|
|
|
if (options.backPockets) {
|
|
|
|
macro('ld', {
|
2020-08-08 16:38:43 +02:00
|
|
|
from: points.styleWaistIn,
|
2021-11-08 19:36:47 +01:00
|
|
|
to: points.pocketBagWaistLeft,
|
|
|
|
d: -15 - sa,
|
2020-08-08 16:38:43 +02:00
|
|
|
})
|
2021-11-08 19:36:47 +01:00
|
|
|
macro('ld', {
|
|
|
|
from: points.styleWaistIn,
|
|
|
|
to: points.pocketWaistCenter,
|
|
|
|
d: -30 - sa,
|
2020-08-08 16:38:43 +02:00
|
|
|
})
|
2021-11-08 19:36:47 +01:00
|
|
|
macro('ld', {
|
|
|
|
from: points.pocketCenter,
|
|
|
|
to: points.pocketWaistCenter,
|
|
|
|
d: -15,
|
2020-08-08 16:38:43 +02:00
|
|
|
})
|
2021-11-08 19:36:47 +01:00
|
|
|
macro('ld', {
|
|
|
|
from: points.pocketBagBottomRight,
|
|
|
|
to: points.pocketBagWaistRight,
|
|
|
|
d: -15,
|
2020-08-08 16:38:43 +02:00
|
|
|
})
|
2020-08-08 16:01:46 +02:00
|
|
|
}
|
2020-08-08 15:19:43 +02:00
|
|
|
}
|
2020-08-02 19:17:06 +02:00
|
|
|
|
|
|
|
return part
|
|
|
|
}
|