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

358 lines
11 KiB
JavaScript
Raw Normal View History

2019-08-03 15:03:33 +02:00
import { calculateReduction } from './shared'
2018-12-21 18:19:21 +01:00
export default (part) => {
2019-08-03 15:03:33 +02:00
part.paths = {} // Removes paperless dimensions from brian
2018-12-27 15:04:32 +01:00
let {
store,
measurements,
utils,
sa,
Point,
points,
Path,
paths,
Snippet,
snippets,
complete,
paperless,
macro,
2021-04-24 10:16:31 +02:00
options,
2019-08-03 15:03:33 +02:00
} = part.shorthand()
2018-12-21 18:19:21 +01:00
// Populare store with data we need
2019-08-03 15:03:33 +02:00
calculateReduction(part)
2018-12-24 17:35:06 +01:00
store.set(
2019-08-03 15:03:33 +02:00
'backArmholeLength',
2018-12-24 17:35:06 +01:00
new Path()
2018-12-21 18:19:21 +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)
2018-12-21 18:19:21 +01:00
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
2018-12-24 17:35:06 +01:00
.length()
2019-08-03 15:03:33 +02:00
)
2018-12-21 18:19:21 +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
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')) {
2018-12-21 18:19:21 +01:00
// Add darts in the back
2019-09-25 18:01:17 +02:00
let darts = (reduce * options.backDartShaping) / 4
let nonDarts = (reduce * (1 - options.backDartShaping)) / 4
points.waist = points.waist.shift(180, nonDarts)
2019-08-03 15:03:33 +02:00
points.dartCenter = points.cbWaist.shiftFractionTowards(points.waist, 0.6)
points.dartTop = points.dartCenter.shift(90, points.armhole.dy(points.waist) * 0.75)
points.dartBottom = points.dartCenter.shift(-90, measurements.waistToHips * 0.75)
2019-09-25 18:01:17 +02:00
points.dartCenterIn = points.dartCenter.shift(180, darts)
points.dartCenterOut = points.dartCenter.shift(0, darts)
2018-12-24 17:35:06 +01:00
points.dartCenterInCp1 = points.dartCenterIn.shift(
90,
points.dartTop.dy(points.dartCenter) * 0.2
2019-08-03 15:03:33 +02:00
)
2018-12-24 17:35:06 +01:00
points.dartCenterInCp2 = points.dartCenterIn.shift(
90,
points.dartBottom.dy(points.dartCenter) * 0.2
2019-08-03 15:03:33 +02:00
)
2018-12-24 17:35:06 +01:00
points.dartCenterOutCp1 = points.dartCenterOut.shift(
90,
points.dartBottom.dy(points.dartCenter) * 0.2
2019-08-03 15:03:33 +02:00
)
2018-12-24 17:35:06 +01:00
points.dartCenterOutCp2 = points.dartCenterOut.shift(
90,
points.dartTop.dy(points.dartCenter) * 0.2
2019-08-03 15:03:33 +02:00
)
2018-12-21 18:19:21 +01:00
paths.dart = new Path()
.move(points.dartTop)
._curve(points.dartCenterInCp1, points.dartCenterIn)
.curve_(points.dartCenterInCp2, points.dartBottom)
._curve(points.dartCenterOutCp1, points.dartCenterOut)
.curve_(points.dartCenterOutCp2, points.dartTop)
.close()
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
2018-12-21 18:19:21 +01:00
} else {
// No darts in the back
2019-08-03 15:03:33 +02:00
points.waist = points.waist.shift(180, reduce / 4)
2018-12-21 18:19:21 +01:00
}
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 18:19:21 +01:00
// Cut off at yoke
points.cbYoke = new Point(0, points.armholePitch.y)
// Box pleat
if (options.boxPleat) {
points.boxPleatLeft = points.cbYoke.shift(0, options.boxPleatWidth / 2)
points.boxPleatMid = points.boxPleatLeft.shift(0, options.boxPleatFold)
points.boxPleatRight = points.boxPleatMid.shift(0, options.boxPleatFold)
points.boxPleatLeftBottom = new Point(points.boxPleatLeft.x, points.armholeHollowCp2.y)
points.boxPleatMidBottom = new Point(points.boxPleatMid.x, points.armholeHollowCp2.y)
points.boxPleatRightBottom = new Point(points.boxPleatRight.x, points.armholeHollowCp2.y)
for (let p of [
'armholePitch',
'armholePitchCp1',
'armholeHollowCp2',
'armholeHollow',
'armholeHollowCp1',
'armholeCp2',
2021-04-24 10:16:31 +02:00
'armhole',
])
points[p] = points[p].shift(0, options.boxPleatFold * 2)
}
2018-12-21 18:19:21 +01:00
// Yoke dart
paths.armhole = new Path()
.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)
paths.armhole.render = false
2018-12-24 17:35:06 +01:00
if (options.yokeDart > 0) {
points.tmp1 = points.armholePitch.shift(
-90,
points.armholePitch.dy(points.armhole) * options.yokeDart
2019-08-03 15:03:33 +02:00
)
points.tmp2 = points.tmp1.shift(180, 50)
points.tmp3 = points.tmp1.shift(0, 50)
2018-12-21 18:19:21 +01:00
points.yokeDartEdge = utils.lineIntersectsCurve(
points.tmp2,
points.tmp3,
points.armholePitch,
points.armholePitchCp1,
points.armholeHollowCp2,
points.armholeHollow
2019-08-03 15:03:33 +02:00
)
points.yokeDartTip = points.armholePitch.shift(180, points.armholePitch.x * 0.4)
points.yokeDartTipCp1 = points.armholePitch.shiftFractionTowards(points.yokeDartTip, 0.4)
paths.armhole = paths.armhole.split(points.yokeDartEdge)[0]
paths.armhole._curve(points.yokeDartTipCp1, points.yokeDartTip)
2018-12-21 19:38:05 +01:00
// Adapt armhole length to accomodate dart
store.set(
2019-08-03 15:03:33 +02:00
'backArmholeLength',
store.get('backArmholeLength') - points.yokeDartEdge.dist(points.armholePitch)
)
2018-12-21 18:19:21 +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 18:19:21 +01:00
// Draft hem
2018-12-24 17:35:06 +01:00
switch (options.hemStyle) {
2019-08-03 15:03:33 +02:00
case 'baseball':
points.bballStart = points.cbHem.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)
2018-12-21 18:19:21 +01:00
paths.saBase = new Path()
.move(points.bballEnd)
.line(points.hips)
.curve(points.hipsCp2, points.waistCp1, points.waist)
.curve_(points.waistCp2, points.armhole)
.join(paths.armhole)
2019-08-03 15:03:33 +02:00
.line(points.cbYoke)
2018-12-21 18:19:21 +01:00
paths.hemBase = new Path()
.move(points.cbHem)
.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 18:19:21 +01:00
from: points.hips,
to: points.cbHem,
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
})
2018-12-21 18:19:21 +01:00
paths.saBase = new Path()
.move(points.hips)
.curve(points.hipsCp2, points.waistCp1, points.waist)
.curve_(points.waistCp2, points.armhole)
.join(paths.armhole)
2019-08-03 15:03:33 +02:00
.line(points.cbYoke)
2018-12-21 18:19:21 +01:00
paths.hemBase = new Path()
.move(points.cbHem)
.line(points.slashEnd)
2019-08-03 15:03:33 +02:00
.curve(points.slashCp2, points.slashCp1, points.slashStart)
break
2018-12-21 18:19:21 +01:00
default:
paths.saBase = new Path()
.move(points.hem)
.line(points.hips)
.curve(points.hipsCp2, points.waistCp1, points.waist)
.curve_(points.waistCp2, points.armhole)
.join(paths.armhole)
2019-08-03 15:03:33 +02:00
.line(points.cbYoke)
paths.hemBase = new Path().move(points.cbHem).line(points.hem)
2018-12-21 18:19:21 +01:00
}
// Paths
2019-08-03 15:03:33 +02:00
paths.saBase.render = false
paths.hemBase.render = false
paths.seam = paths.hemBase.join(paths.saBase).close().attr('class', 'fabric')
2018-12-21 18:19:21 +01:00
// Complete pattern?
if (complete) {
2019-08-03 15:03:33 +02:00
delete snippets.armholePitchNotch
macro('cutonfold', {
2018-12-21 18:19:21 +01:00
from: points.cbYoke,
to: points.cbHem,
2021-04-24 10:16:31 +02:00
grainline: true,
2019-08-03 15:03:33 +02:00
})
points.title = new Point(points.armhole.x / 4, points.armhole.y)
macro('title', { at: points.title, nr: 3, title: 'back' })
points.logo = points.title.shift(-90, 70)
snippets.logo = new Snippet('logo', points.logo)
if (options.boxPleat) {
paths.boxPleat = new Path()
.move(points.boxPleatLeft)
.line(points.boxPleatLeftBottom)
.move(points.boxPleatMid)
.line(points.boxPleatMidBottom)
.move(points.boxPleatRight)
.line(points.boxPleatRightBottom)
.attr('class', 'fabric stroke-sm dashed')
}
2018-12-21 18:19:21 +01:00
2018-12-24 17:35:06 +01:00
if (sa) {
2019-08-03 15:03:33 +02:00
paths.sa = paths.saBase.offset(sa).attr('class', 'fabric sa')
paths.hemSa = paths.hemBase.offset(sa * 3).attr('class', 'fabric sa')
2018-12-21 18:19:21 +01:00
paths.saConnect = new Path()
.move(points.cbHem)
.line(paths.hemSa.start())
.move(paths.hemSa.end())
.line(paths.sa.start())
.move(paths.sa.end())
.line(points.cbYoke)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric sa')
macro('banner', {
path: 'hemSa',
2021-04-24 10:16:31 +02:00
text: ['hem', ': 3x', 'seamAllowance'],
2019-08-03 15:03:33 +02:00
})
2018-12-21 18:19:21 +01:00
}
}
// Paperless?
if (paperless) {
2019-09-25 18:01:17 +02:00
if (store.get('backDarts')) {
2019-08-03 15:03:33 +02:00
macro('vd', {
2018-12-27 18:56:35 +01:00
from: points.dartBottom,
to: points.dartCenterIn,
2021-04-24 10:16:31 +02:00
x: points.dartCenterIn.x - 15,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-27 18:56:35 +01:00
from: points.dartCenterIn,
to: points.dartTop,
2021-04-24 10:16:31 +02:00
x: points.dartCenterIn.x - 15,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-27 18:56:35 +01:00
from: points.dartCenterIn,
to: points.dartCenterOut,
2021-04-24 10:16:31 +02:00
y: points.dartBottom.y + 15,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-27 18:56:35 +01:00
from: points.dartCenterOut,
2021-04-24 10:16:31 +02:00
to: points.waist,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-27 18:56:35 +01:00
from: points.cbWaist,
2021-04-24 10:16:31 +02:00
to: points.dartCenterIn,
2019-08-03 15:03:33 +02:00
})
2018-12-27 18:56:35 +01:00
} else {
2019-08-03 15:03:33 +02:00
macro('hd', {
2018-12-27 18:56:35 +01:00
from: points.cbWaist,
2021-04-24 10:16:31 +02:00
to: points.waist,
2019-08-03 15:03:33 +02:00
})
2018-12-27 18:56:35 +01:00
}
2019-08-03 15:03:33 +02:00
let bottomRight
if (typeof points.slashEnd !== 'undefined') {
macro('hd', {
2018-12-27 18:56:35 +01:00
from: points.cbHem,
to: points.slashEnd,
2021-04-24 10:16:31 +02:00
y: points.cbHem.y + 15 + 3 * sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-27 18:56:35 +01:00
from: points.slashEnd,
to: points.slashStart,
2021-04-24 10:16:31 +02:00
x: points.slashStart.x + 15 + 3 * sa,
2019-08-03 15:03:33 +02:00
})
bottomRight = points.slashEnd
} else if (typeof points.bballStart !== 'undefined') {
macro('hd', {
2018-12-27 18:56:35 +01:00
from: points.cbHem,
to: points.bballStart,
2021-04-24 10:16:31 +02:00
y: points.cbHem.y + 15 + 3 * sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-27 18:56:35 +01:00
from: points.bballStart,
to: points.bballEnd,
2021-04-24 10:16:31 +02:00
x: points.hips.x + 15 + sa,
2019-08-03 15:03:33 +02:00
})
bottomRight = points.bballStart
} else bottomRight = points.hem
macro('hd', {
2018-12-27 18:56:35 +01:00
from: points.cbHem,
to: points.hips,
2021-04-24 10:16:31 +02:00
y: points.cbHem.y + 30 + 3 * sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-27 18:56:35 +01:00
from: bottomRight,
to: points.hips,
2021-04-24 10:16:31 +02:00
x: points.hips.x + 30 + sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-27 18:56:35 +01:00
from: bottomRight,
to: points.waist,
2021-04-24 10:16:31 +02:00
x: points.hips.x + 45 + sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-27 18:56:35 +01:00
from: bottomRight,
to: points.armhole,
2021-04-24 10:16:31 +02:00
x: points.hips.x + 60 + sa,
2019-08-03 15:03:33 +02:00
})
2018-12-27 18:56:35 +01:00
if (options.yokeDart > 0) {
2019-08-03 15:03:33 +02:00
macro('vd', {
2018-12-27 18:56:35 +01:00
from: points.armhole,
to: points.yokeDartEdge,
2021-04-24 10:16:31 +02:00
x: points.armhole.x + 15 + sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-27 18:56:35 +01:00
from: points.armhole,
to: points.yokeDartTip,
2021-04-24 10:16:31 +02:00
x: points.armhole.x + 30 + sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-27 18:56:35 +01:00
from: points.cbYoke,
to: points.yokeDartTip,
2021-04-24 10:16:31 +02:00
y: points.cbYoke.y - 15 - sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-27 18:56:35 +01:00
from: points.cbYoke,
to: points.yokeDartEdge,
2021-04-24 10:16:31 +02:00
y: points.cbYoke.y - 30 - sa,
2019-08-03 15:03:33 +02:00
})
2018-12-27 18:56:35 +01:00
} else {
2019-08-03 15:03:33 +02:00
macro('vd', {
2018-12-27 18:56:35 +01:00
from: points.armhole,
to: points.armholePitch,
2021-04-24 10:16:31 +02:00
x: points.armhole.x + 15 + sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-27 18:56:35 +01:00
from: points.cbYoke,
to: points.armholePitch,
2021-04-24 10:16:31 +02:00
y: points.cbYoke.y - 15 - sa,
2019-08-03 15:03:33 +02:00
})
2018-12-27 18:56:35 +01:00
}
2019-08-03 15:03:33 +02:00
macro('vd', {
2018-12-27 18:56:35 +01:00
from: points.cbHem,
to: points.cbYoke,
2021-04-24 10:16:31 +02:00
x: points.cbHem.x - 15,
2019-08-03 15:03:33 +02:00
})
2018-12-21 18:19:21 +01:00
}
2019-08-03 15:03:33 +02:00
return part
}