1
0
Fork 0
freesewing/packages/huey/src/sleeve.js

79 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-01-31 09:22:15 +01:00
export default function (part) {
2021-08-30 11:40:16 +02:00
let { Point, Path, points, paths, store, options, complete, sa, paperless, macro } =
part.shorthand()
2019-03-03 16:04:24 +01:00
// Clear paths from Brian, but keep sleevecap
for (let p of Object.keys(paths)) {
2019-08-03 15:03:33 +02:00
if (p !== 'sleevecap') delete paths[p]
2019-03-03 16:04:24 +01:00
}
// Shorten sleeve to take ribbing into account
if (options.ribbing) {
2019-08-03 15:03:33 +02:00
for (let p of ['wristLeft', 'wristRight'])
points[p] = points[p].shift(90, store.get('ribbingHeight'))
2019-03-03 16:04:24 +01:00
}
// Paths
paths.saBase = new Path()
.move(points.wristRight)
.line(points.bicepsRight)
.join(paths.sleevecap)
.line(points.wristLeft)
2019-08-03 15:03:33 +02:00
.attr('class', 'various stroke-xxl')
2019-03-03 16:04:24 +01:00
paths.hemBase = new Path()
.move(points.wristLeft)
.line(points.wristRight)
2019-08-03 15:03:33 +02:00
.attr('class', 'various stroke-xxl')
paths.saBase.render = false
paths.hemBase.render = false
2019-03-03 16:04:24 +01:00
2021-01-31 09:22:15 +01:00
paths.seam = paths.saBase.join(paths.hemBase).close().attr('class', 'fabric')
2019-03-03 16:04:24 +01:00
// Complete?
if (complete) {
2019-08-03 15:03:33 +02:00
macro('grainline', {
2019-03-03 16:04:24 +01:00
from: new Point(0, points.wristLeft.y),
2021-04-24 10:16:31 +02:00
to: new Point(0, points.backPitch.y),
2019-08-03 15:03:33 +02:00
})
2019-03-03 16:04:24 +01:00
if (sa) {
2019-08-03 15:03:33 +02:00
if (options.ribbing) paths.sa = paths.seam.offset(sa)
2019-03-03 16:04:24 +01:00
else {
paths.sa = paths.saBase
.clone()
.offset(sa)
.join(paths.hemBase.offset(3 * sa))
2019-08-03 15:03:33 +02:00
.close()
2019-03-03 16:04:24 +01:00
}
2019-08-03 15:03:33 +02:00
paths.sa.attr('class', 'fabric sa')
2019-03-03 16:04:24 +01:00
}
}
// Paperless?
if (paperless) {
2019-08-03 15:03:33 +02:00
let hemSa = sa
if (!options.ribbing) hemSa = 3 * sa
macro('hd', {
2019-03-03 16:04:24 +01:00
from: points.wristLeft,
to: points.wristRight,
2021-04-24 10:16:31 +02:00
y: points.wristLeft.y + hemSa + 15,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-03 16:04:24 +01:00
from: points.bicepsLeft,
to: points.bicepsRight,
2021-04-24 10:16:31 +02:00
y: points.sleeveTip.y - sa - 15,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-03 16:04:24 +01:00
from: points.wristLeft,
to: points.bicepsLeft,
2021-04-24 10:16:31 +02:00
x: points.bicepsLeft.x - sa - 15,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-03 16:04:24 +01:00
from: points.wristLeft,
to: points.sleeveTip,
2021-04-24 10:16:31 +02:00
x: points.bicepsLeft.x - sa - 30,
2019-08-03 15:03:33 +02:00
})
2019-03-03 16:04:24 +01:00
}
2019-08-03 15:03:33 +02:00
return part
2019-03-03 16:04:24 +01:00
}