1
0
Fork 0
freesewing/packages/simon/src/front.js

140 lines
4.5 KiB
JavaScript
Raw Normal View History

2019-08-03 15:03:33 +02:00
import { calculateReduction } from './shared'
2018-12-21 19:38:05 +01:00
export default (part) => {
2018-12-27 15:04:32 +01:00
let {
store,
measurements,
sa,
Point,
points,
Path,
paths,
complete,
macro,
2021-06-19 12:50:46 +02:00
snippets,
2021-04-24 10:16:31 +02:00
options,
2019-08-03 15:03:33 +02:00
} = part.shorthand()
2018-12-21 19:38:05 +01:00
2021-06-19 12:50:46 +02:00
// Clean up
for (let i in paths) {
if (['frontArmhole', 'frontCollar'].indexOf(i) === -1) delete paths[i]
}
for (let i in snippets) {
if (i.indexOf('otch')) delete snippets[i]
}
2018-12-21 19:38:05 +01:00
// Populare store with data we need
2019-08-03 15:03:33 +02:00
calculateReduction(part)
store.set(
2019-08-03 15:03:33 +02:00
'frontArmholeLength',
new Path()
2018-12-21 19:38:05 +01:00
.move(points.armhole)
.curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow)
2019-08-03 15:03:33 +02:00
.curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch)
2021-06-19 12:50:46 +02:00
.join(paths.frontArmhole)
.length()
2019-08-03 15:03:33 +02:00
)
2018-12-21 19:38:05 +01:00
2018-12-29 09:03:11 +01:00
// Hip shaping
2019-08-03 15:03:33 +02:00
points.hips = points.hips.shift(180, store.get('hipsReduction') / 4)
points.hem = points.hem.shift(180, store.get('hipsReduction') / 4)
2018-12-29 09:03:11 +01:00
2018-12-21 19:38:05 +01:00
// Waist shaping
2019-08-03 15:03:33 +02:00
let reduce = store.get('waistReduction')
2019-09-25 18:01:17 +02:00
if (store.get('backDarts')) reduce = (reduce * (1 - options.backDartShaping)) / 4
2019-08-03 15:03:33 +02:00
else reduce = reduce / 4
points.waist = points.waist.shift(180, reduce)
points.waistCp1 = points.waist.shift(-90, measurements.waistToHips * 0.5)
2019-08-03 15:03:33 +02:00
points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 2)
points.hipsCp2 = points.hips.shift(90, points.waist.dy(points.hips) / 4)
2018-12-21 19:38:05 +01:00
2019-09-25 18:01:17 +02:00
// Never make the hips more narrow than the waist because that looks silly
if (points.hem.x < points.waist.x) {
points.hem.x = points.waist.x
points.hips.x = points.waist.x
points.hipsCp2.x = points.waist.x
}
2018-12-21 19:38:05 +01:00
// Draft hem
paths.saBaseFromHips = new Path()
.move(points.hips)
.curve(points.hipsCp2, points.waistCp1, points.waist)
2019-08-03 15:03:33 +02:00
.curve_(points.waistCp2, points.armhole)
2018-12-21 19:38:05 +01:00
paths.saBaseFromArmhole = new Path()
.move(points.armhole)
.curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow)
.curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch)
2021-06-19 12:50:46 +02:00
.join(paths.frontArmhole)
.line(points.s3CollarSplit)
.join(paths.frontCollar)
switch (options.hemStyle) {
2019-08-03 15:03:33 +02:00
case 'baseball':
points.bballStart = points.cfHem.shiftFractionTowards(points.hem, 0.5)
points.bballEnd = points.hem.shiftFractionTowards(points.hips, options.hemCurve)
points.bballCp1 = points.bballStart.shiftFractionTowards(points.hem, 0.5)
points.bballCp2 = new Point(points.bballCp1.x, points.bballEnd.y)
paths.saBase = new Path().move(points.bballEnd).line(points.hips).join(paths.saBaseFromHips)
paths.hemBase = new Path()
2018-12-21 19:38:05 +01:00
.move(points.cfHem)
.line(points.bballStart)
2019-08-03 15:03:33 +02:00
.curve(points.bballCp1, points.bballCp2, points.bballEnd)
break
case 'slashed':
macro('round', {
2018-12-21 19:38:05 +01:00
from: points.hips,
to: points.cfHem,
via: points.hem,
radius: points.hips.dist(points.hem) * options.hemCurve,
2021-04-24 10:16:31 +02:00
prefix: 'slash',
2019-08-03 15:03:33 +02:00
})
paths.saBase = new Path().move(points.hips).join(paths.saBaseFromHips)
2018-12-21 19:38:05 +01:00
paths.hemBase = new Path()
.move(points.cfHem)
.line(points.slashEnd)
2019-08-03 15:03:33 +02:00
.curve(points.slashCp2, points.slashCp1, points.slashStart)
break
2018-12-21 19:38:05 +01:00
default:
paths.saBase = new Path().move(points.hem).line(points.hips).join(paths.saBaseFromHips)
2019-08-03 15:03:33 +02:00
paths.hemBase = new Path().move(points.cfHem).line(points.hem)
2018-12-21 19:38:05 +01:00
}
// Paths
2019-08-03 15:03:33 +02:00
paths.saBase.render = false
paths.saBaseFromHips.render = false
paths.saBaseFromArmhole.render = false
paths.hemBase.render = false
paths.seam = paths.hemBase
.join(paths.saBase)
.join(paths.saBaseFromArmhole)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
2018-12-21 19:38:05 +01:00
// Complete pattern?
if (complete) {
2019-08-03 15:03:33 +02:00
delete paths.cutonfold
macro('grainline', {
2018-12-21 19:38:05 +01:00
from: points.cfHem.shift(0, 45),
2021-04-24 10:16:31 +02:00
to: points.cfNeck.shift(0, 45),
2019-08-03 15:03:33 +02:00
})
macro('title', { at: points.title, nr: 'X', title: 'front' })
macro('sprinkle', {
snippet: 'notch',
2021-04-24 10:16:31 +02:00
on: ['waist', 'armholePitch', 'hips', 'cfHips', 'cfWaist', 'armhole', 'cfArmhole'],
2019-08-03 15:03:33 +02:00
})
2018-12-21 19:38:05 +01:00
if (sa) {
2019-08-03 15:03:33 +02:00
paths.saFrench = paths.saBase.offset(sa * 2).attr('class', 'fabric sa')
paths.saFromArmhole = paths.saBaseFromArmhole.offset(sa).attr('class', 'fabric sa')
paths.hemSa = paths.hemBase.offset(sa * 3).attr('class', 'fabric sa')
2018-12-21 19:38:05 +01:00
paths.saConnect = new Path()
.move(paths.hemSa.end())
.line(paths.saFrench.start())
.move(paths.saFrench.end())
.line(paths.saFromArmhole.start())
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric sa')
delete paths.sa
2018-12-21 19:38:05 +01:00
}
}
2019-08-03 15:03:33 +02:00
return part
}