1
0
Fork 0
freesewing/packages/jaeger/src/shared.js

65 lines
2.4 KiB
JavaScript
Raw Normal View History

2019-03-16 11:39:06 +01:00
/**
* This calculates a bunch of helper variables and stores them
*/
export const calculateRatios = part => {
2019-08-03 15:03:33 +02:00
let { store, measurements, options } = part.shorthand()
2019-03-16 11:39:06 +01:00
// Make sure collar height makes sense
2019-08-03 15:03:33 +02:00
if (options.collarHeight * 2 < options.rollLineCollarHeight)
options.rollLineCollarHeight = options.collarHeight * 2
2019-03-16 11:39:06 +01:00
// Calculate different values for reducing from chest to hips via waist
2019-08-03 15:03:33 +02:00
store.set('chest', measurements.chestCircumference * (1 + options.chestEase))
store.set('waist', measurements.naturalWaist * (1 + options.waistEase))
store.set('hips', measurements.hipsCircumference * (1 + options.hipsEase))
2019-03-16 11:39:06 +01:00
2019-08-03 15:03:33 +02:00
store.set('waistReduction', store.get('chest') - store.get('waist'))
store.set('hipsReduction', store.get('chest') - store.get('hips'))
}
2019-03-16 11:39:06 +01:00
/**
* Draws the line seperating side panel (back-side boundary, aka bs)
* Note that this is without shaping, but rather the style line
* that will be the starting point for shaping the back/side seam
*
* On the back, this will be drawn as-is. On the front, it will be
* drawn, than mirrored so the part that's cut off from the back is
* added to the front (to become the side later).
*
* The optional flip parameter mirrors this for the front part
*/
2019-08-03 15:03:33 +02:00
export const backSideBoundary = (part, flip = false) => {
let { points, Point, paths, Path } = part.shorthand()
2019-03-16 11:39:06 +01:00
2019-08-03 15:03:33 +02:00
points.bsArmholeHollow = points.armholeHollow.clone()
points.bsArmholeHollowCp2 = points.armholeHollowCp2.rotate(90, points.armholeHollow)
points.bsWaist = new Point(points.bsArmholeHollowCp2.x, points.waist.y)
points.bsHips = new Point(points.bsWaist.x, points.hips.y)
points.bsHem = new Point(points.bsWaist.x, points.hem.y)
2019-03-16 11:39:06 +01:00
if (flip) {
2019-08-03 15:03:33 +02:00
points.bsArmholeHollowCp1 = points.armholeHollowCp1.clone()
points.bsArmholeCp2 = points.armholeCp2.clone()
2019-03-16 11:39:06 +01:00
for (let p of [
2019-08-03 15:03:33 +02:00
'bsArmholeHollow',
'bsArmholeHollowCp2',
'bsWaist',
'bsHips',
'bsHem',
'bsArmholeHollowCp1',
'bsArmholeCp2'
2019-03-16 11:39:06 +01:00
]) {
2019-08-03 15:03:33 +02:00
points[p] = points[p].flipX(points.armhole)
2019-03-16 11:39:06 +01:00
}
}
/** Uncomment this to see the style line without shaping
*/
paths.bs = new Path()
.move(points.bsHem)
.line(points.bsWaist)
._curve(points.bsArmholeHollowCp2, points.bsArmholeHollow)
2019-08-03 15:03:33 +02:00
.attr('class', 'stroke-xl lining lashed')
if (flip) paths.bs.curve(points.bsArmholeHollowCp1, points.bsArmholeCp2, points.armhole)
2019-03-16 11:39:06 +01:00
}