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

214 lines
6 KiB
JavaScript
Raw Normal View History

2019-08-03 15:03:33 +02:00
import { constructMainDart, shapeSideSeam, dartPath } from './shared'
2019-02-17 20:42:05 +01:00
export default (part) => {
2019-02-17 20:42:05 +01:00
let {
points,
Point,
paths,
Path,
measurements,
options,
macro,
complete,
sa,
paperless,
2021-04-24 10:16:31 +02:00
snippets,
2019-08-03 15:03:33 +02:00
} = part.shorthand()
2019-02-17 20:42:05 +01:00
// Cleanup from Brian
2019-08-03 15:03:33 +02:00
for (let i of Object.keys(paths)) delete paths[i]
delete snippets.armholePitchNotch
2019-02-17 20:42:05 +01:00
// Back inset
2019-08-03 15:03:33 +02:00
let shoulderLen = points.shoulder.dist(points.neck)
let backInset = shoulderLen * options.backInset
points.armholePitch = points.armholePitch.shift(180, backInset)
points.armholePitchCp1 = points.armholePitchCp1.shift(180, backInset)
points.armholePitchCp2 = points.armholePitchCp2.shift(180, backInset)
points.armholeHollow = points.armholeHollow.shift(180, backInset / 2)
points.armholeHollowCp2 = points.armholeHollowCp2.shift(180, backInset / 2)
points.armholeHollowCp1 = points.armholeHollowCp1.shift(180, backInset / 2)
2019-02-17 20:42:05 +01:00
// Shoulder inset
2019-08-03 15:03:33 +02:00
points.shoulder = points.shoulder.shiftTowards(points.neck, shoulderLen * options.shoulderInset)
2019-02-17 20:42:05 +01:00
points.shoulderCp1 = points.shoulderCp1.shift(
points.shoulder.angle(points.neck),
shoulderLen * options.shoulderInset
2019-08-03 15:03:33 +02:00
)
2019-02-17 20:42:05 +01:00
// Neck inset
2019-08-03 15:03:33 +02:00
points.neck = points.neck.shiftTowards(points.shoulder, shoulderLen * options.neckInset)
points.neckCp2 = points.neck.shift(points.shoulder.angle(points.neck) + 90, shoulderLen * 0.1)
2019-02-17 20:42:05 +01:00
// Center back dart
points.cbNeck = new Path()
.move(points.cbNeck)
._curve(points.neckCp2, points.neck)
2019-08-03 15:03:33 +02:00
.shiftAlong(measurements.shoulderToShoulder * options.centerBackDart)
points.cbNeckCp2 = new Point(0, points.armholePitch.y)
2019-02-17 20:42:05 +01:00
// Construct main dart
2019-08-03 15:03:33 +02:00
constructMainDart(part)
2019-02-17 20:42:05 +01:00
// Add dart start and end point regardless of style or front or back
2019-08-03 15:03:33 +02:00
points.dartStart = points.dartHemLeft
points.dartEnd = points.dartHemRight
2019-02-17 20:42:05 +01:00
// Shape side seam
2019-08-03 15:03:33 +02:00
shapeSideSeam(part)
2019-02-17 20:42:05 +01:00
// Back scye dart
points._dartWidth = points.cbNeckCp2.shiftFractionTowards(
points.armholePitch.rotate(options.backScyeDart, points.cbNeckCp2),
1.2
2019-08-03 15:03:33 +02:00
)
2019-02-17 20:42:05 +01:00
points.armholePitchTop = new Path()
.move(points.armholePitch)
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
.intersects(new Path().move(points.cbNeckCp2).line(points._dartWidth))
2019-08-03 15:03:33 +02:00
.pop()
2019-02-17 20:42:05 +01:00
// Rotate back scye dart into center back
2019-08-03 15:03:33 +02:00
let toRotate = ['cbNeck', 'neckCp2', 'neck', 'shoulder', 'shoulderCp1']
2019-02-17 20:42:05 +01:00
for (let p of toRotate) {
2019-08-03 15:03:33 +02:00
points[p] = points[p].rotate(options.backScyeDart, points.cbNeckCp2)
2019-02-17 20:42:05 +01:00
}
// Seam line
2019-08-03 15:03:33 +02:00
delete paths.cutonfold
delete paths.saBase
delete paths.sa
2019-02-17 20:42:05 +01:00
paths.saBase = new Path()
.move(points.hem)
.line(points.hips)
.curve(points.hipsCp2, points.waistCp1, points.waist)
.curve_(points.waistCp2, points.armhole)
.curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow)
.curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch)
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
.line(points.neck)
.curve_(points.neckCp2, points.cbNeck)
._curve(points.cbNeckCp2, points.cbArmhole)
2019-08-03 15:03:33 +02:00
.line(points.cbHem)
paths.hemBase = new Path().move(points.cbHem).line(points.hem)
paths.dart = dartPath(part)
2019-02-17 20:42:05 +01:00
paths.seam = paths.saBase
.clone()
.line(points.dartHemLeft)
.join(paths.dart)
.line(points.hem)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
paths.saBase.render = false
paths.hemBase.render = false
paths.hemBase.render = false
paths.dart.render = false
2019-02-17 20:42:05 +01:00
if (complete) {
macro('scalebox', { at: new Point(points.logo.x, points.armholePitchCp2.y) })
2019-02-17 20:42:05 +01:00
if (sa) {
paths.sa = paths.saBase
.offset(sa)
.join(paths.hemBase.offset(sa * 3))
2019-08-03 15:03:33 +02:00
.close()
.attr('class', 'fabric sa')
2019-02-17 20:42:05 +01:00
}
if (paperless) {
2019-08-03 15:03:33 +02:00
macro('ld', {
2019-02-17 20:42:05 +01:00
from: points.neck,
to: points.shoulder,
2021-04-24 10:16:31 +02:00
d: 15 + sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-02-17 20:42:05 +01:00
from: points.cbArmhole,
to: points.cbNeck,
2021-04-24 10:16:31 +02:00
y: points.cbNeck.y - 15 - sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-02-17 20:42:05 +01:00
from: points.cbArmhole,
to: points.neck,
2021-04-24 10:16:31 +02:00
y: points.cbNeck.y - 30 - sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-02-17 20:42:05 +01:00
from: points.cbArmhole,
to: points.shoulder,
2021-04-24 10:16:31 +02:00
y: points.cbNeck.y - 45 - sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-02-17 20:42:05 +01:00
from: points.cbArmhole,
to: points.armholePitch,
2021-04-24 10:16:31 +02:00
y: points.armholePitch.y,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-02-17 20:42:05 +01:00
from: points.cbArmhole,
to: points.dartTop,
2021-04-24 10:16:31 +02:00
y: points.dartTop.y - 15,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-02-17 20:42:05 +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('vd', {
2019-02-17 20:42:05 +01:00
from: points.armhole,
to: points.shoulder,
2021-04-24 10:16:31 +02:00
x: points.armhole.x + 30 + sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-02-17 20:42:05 +01:00
from: points.armhole,
to: points.neck,
2021-04-24 10:16:31 +02:00
x: points.armhole.x + 45 + sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-02-17 20:42:05 +01:00
from: points.hem,
to: points.waist,
2021-04-24 10:16:31 +02:00
x: points.armhole.x + 15 + sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-02-17 20:42:05 +01:00
from: points.hem,
to: points.armhole,
2021-04-24 10:16:31 +02:00
x: points.armhole.x + 30 + sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-02-17 20:42:05 +01:00
from: points.dartHemRight,
to: points.hem,
2021-04-24 10:16:31 +02:00
y: points.hem.y + 3 * sa + 15,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-02-17 20:42:05 +01:00
from: points.cbHem,
to: points.dartHemLeft,
2021-04-24 10:16:31 +02:00
y: points.hem.y + 3 * sa + 15,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-02-17 20:42:05 +01:00
from: points.cbHem,
to: points.hem,
2021-04-24 10:16:31 +02:00
y: points.hem.y + 3 * sa + 30,
2019-08-03 15:03:33 +02:00
})
macro('ld', {
2019-02-17 20:42:05 +01:00
from: points.dartWaistLeft,
2021-04-24 10:16:31 +02:00
to: points.dartWaistRight,
2019-08-03 15:03:33 +02:00
})
macro('ld', {
2019-02-17 20:42:05 +01:00
from: points.dartHipLeft,
2021-04-24 10:16:31 +02:00
to: points.dartHipRight,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-02-17 20:42:05 +01:00
from: points.cbHem,
to: points.cbArmhole,
2021-04-24 10:16:31 +02:00
x: points.cbHem.x - 15 - sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-02-17 20:42:05 +01:00
from: points.cbHem,
to: points.cbNeck,
2021-04-24 10:16:31 +02:00
x: points.cbHem.x - 30 - sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-02-17 20:42:05 +01:00
from: points.cbHem,
to: points.neck,
2021-04-24 10:16:31 +02:00
x: points.cbHem.x - 45 - sa,
2019-08-03 15:03:33 +02:00
})
2019-02-17 20:42:05 +01:00
}
}
2019-08-03 15:03:33 +02:00
return part
}