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

123 lines
3.3 KiB
JavaScript
Raw Normal View History

2021-01-31 09:22:15 +01:00
export default (part) => {
2018-12-27 15:04:32 +01:00
let {
sa,
Point,
points,
Path,
paths,
Snippet,
snippets,
complete,
paperless,
macro,
options
2019-08-03 15:03:33 +02:00
} = part.shorthand()
2018-12-23 14:54:34 +01:00
2019-08-03 15:03:33 +02:00
for (let id of Object.keys(part.paths)) delete part.paths[id]
2018-12-23 14:54:34 +01:00
// Cut off at yoke
2019-08-03 15:03:33 +02:00
points.cbYoke = new Point(0, points.armholePitch.y)
2018-12-23 14:54:34 +01:00
// Paths
paths.saBase = new Path()
.move(points.cbYoke)
.line(points.armholePitch)
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
.line(points.neck)
2019-08-03 15:03:33 +02:00
.curve_(points.neckCp2, points.cbNeck)
if (options.splitYoke) paths.saBase = paths.saBase.line(points.cbYoke).close()
else {
for (let p of ['neckCp2', 'neck', 'shoulder', 'shoulderCp1', 'armholePitchCp2', 'armholePitch'])
points['_' + p] = points[p].flipX()
paths.saBase
._curve(points._neckCp2, points._neck)
.line(points._shoulder)
.curve(points._shoulderCp1, points._armholePitchCp2, points._armholePitch)
.line(points.cbYoke)
.close()
}
2019-08-03 15:03:33 +02:00
paths.seam = paths.saBase.clone()
paths.saBase.render = false
paths.seam = paths.seam.close().attr('class', 'fabric')
2018-12-23 14:54:34 +01:00
// Complete pattern?
2018-12-23 17:25:53 +01:00
if (complete) {
2019-08-03 15:03:33 +02:00
delete snippets.armholePitchNotch
points.title = new Point(points.neck.x, points.cbYoke.y / 3)
macro('title', { at: points.title, nr: 4, title: 'yoke', scale: 0.8 })
points.logo = points.title.shift(-90, 50)
snippets.logo = new Snippet('logo', points.logo)
snippets.logo.attr('data-scale', 0.8)
if (options.splitYoke) {
macro('cutonfold', {
from: points.cbNeck,
to: points.cbYoke,
grainline: true
})
snippets.sleeveNotch = new Snippet('bnotch', points.armholePitch)
} else {
2019-08-03 15:03:33 +02:00
points.grainlineFrom = points.cbYoke.shift(0, 20)
points.grainlineTo = points.cbNeck.shift(0, 20)
macro('grainline', {
2018-12-23 14:54:34 +01:00
from: points.grainlineFrom,
to: points.grainlineTo
2019-08-03 15:03:33 +02:00
})
snippets.sleeveNotchA = new Snippet('bnotch', points.armholePitch)
snippets.sleeveNotchB = new Snippet('bnotch', points._armholePitch)
2018-12-23 14:54:34 +01:00
}
if (sa) {
2019-08-03 15:03:33 +02:00
paths.sa = paths.saBase.offset(sa).attr('class', 'fabric sa')
if (options.splitYoke) {
2021-01-31 09:22:15 +01:00
paths.sa = paths.sa.line(points.cbNeck).move(points.cbYoke).line(paths.sa.start())
2018-12-23 14:54:34 +01:00
}
}
}
// Paperless?
if (paperless) {
2019-08-03 15:03:33 +02:00
macro('pd', {
2018-12-27 15:04:32 +01:00
path: new Path().move(points.cbNeck)._curve(points.neckCp2, points.neck),
d: 15
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-27 15:04:32 +01:00
from: points.cbNeck,
to: points.neck,
y: points.neck.y - 15 - sa
2019-08-03 15:03:33 +02:00
})
macro('ld', {
2018-12-27 15:04:32 +01:00
from: points.neck,
to: points.shoulder,
d: 15 + sa
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-27 15:04:32 +01:00
from: points.cbYoke,
to: points.armholePitch,
y: points.cbYoke.y + 15 + sa
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-27 15:04:32 +01:00
from: points.cbYoke,
to: points.shoulder,
y: points.cbYoke.y + 30 + sa
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-27 15:04:32 +01:00
from: points.cbYoke,
to: points.cbNeck,
x: points.cbYoke.x - 15 - sa
2019-08-03 15:03:33 +02:00
})
macro('pd', {
2018-12-27 15:04:32 +01:00
path: new Path()
.move(points.armholePitch)
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder),
d: 15 + sa
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-27 15:04:32 +01:00
from: points.armholePitch,
to: points.shoulder,
x: points.shoulder.x + 30 + sa
2019-08-03 15:03:33 +02:00
})
2018-12-23 14:54:34 +01:00
}
2019-08-03 15:03:33 +02:00
return part
}