1
0
Fork 0
freesewing/packages/jaeger/src/pocket.js

114 lines
2.8 KiB
JavaScript
Raw Normal View History

2021-01-31 09:22:15 +01:00
export default function (part) {
2019-08-03 15:03:33 +02:00
let {
paperless,
sa,
store,
complete,
points,
options,
macro,
Point,
paths,
2021-04-24 10:16:31 +02:00
Path,
2019-08-03 15:03:33 +02:00
} = part.shorthand()
2019-03-16 11:39:06 +01:00
2019-08-03 15:03:33 +02:00
let width = store.get('pocketWidth')
let depth = store.get('pocketDepth')
2019-03-16 11:39:06 +01:00
2019-08-03 15:03:33 +02:00
points.topLeft = new Point(0, 0)
points.topRight = new Point(width, 0)
points.bottomLeft = new Point(0, depth)
points.bottomRight = new Point(width, depth)
2019-03-16 11:39:06 +01:00
// Add foldover points
points.edgeLeft = points.bottomLeft.shiftFractionTowards(
points.topLeft,
1 + options.pocketFoldover
2019-08-03 15:03:33 +02:00
)
points.edgeRight = new Point(points.topRight.x, points.edgeLeft.y)
2019-03-16 11:39:06 +01:00
2019-03-16 18:16:31 +01:00
// Round the pocket
if (options.frontPocketRadius > 0) {
2019-08-03 15:03:33 +02:00
macro('round', {
2019-03-16 18:16:31 +01:00
from: points.topLeft,
to: points.bottomRight,
via: points.bottomLeft,
radius: width * options.frontPocketRadius,
2021-04-24 10:16:31 +02:00
prefix: 'left',
2019-08-03 15:03:33 +02:00
})
macro('round', {
2019-03-16 18:16:31 +01:00
from: points.bottomLeft,
to: points.topRight,
via: points.bottomRight,
radius: width * options.frontPocketRadius,
2021-04-24 10:16:31 +02:00
prefix: 'right',
2019-08-03 15:03:33 +02:00
})
2019-03-16 18:16:31 +01:00
}
2019-03-16 11:39:06 +01:00
2019-03-16 18:16:31 +01:00
// Paths
if (options.frontPocketRadius > 0) {
paths.seam = new Path()
.move(points.edgeLeft)
.line(points.leftStart)
.curve(points.leftCp1, points.leftCp2, points.leftEnd)
.line(points.rightStart)
.curve(points.rightCp1, points.rightCp2, points.rightEnd)
.line(points.edgeRight)
.line(points.edgeLeft)
.close()
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
2019-03-16 18:16:31 +01:00
} else {
paths.seam = new Path()
.move(points.edgeLeft)
.line(points.bottomLeft)
.line(points.bottomRight)
.line(points.edgeRight)
.line(points.edgeLeft)
.close()
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
2019-03-16 18:16:31 +01:00
}
2021-01-31 09:22:15 +01:00
paths.fold = new Path().move(points.topLeft).line(points.topRight).attr('class', 'fabric dashed')
2019-03-16 11:39:06 +01:00
2019-03-16 18:16:31 +01:00
if (complete) {
// Title
2019-08-03 15:03:33 +02:00
points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
macro('title', {
2019-03-16 18:16:31 +01:00
at: points.title,
nr: 9,
2021-04-24 10:16:31 +02:00
title: 'pocket',
2019-08-03 15:03:33 +02:00
})
2019-03-16 18:16:31 +01:00
// Instructions
2019-08-03 15:03:33 +02:00
paths.fold.attr('data-text', 'foldAlongThisLine').attr('data-text-class', 'center')
2019-03-16 18:16:31 +01:00
// Grainline
2019-08-03 15:03:33 +02:00
macro('grainline', {
from: points.bottomLeft.shift(0, 10),
2021-04-24 10:16:31 +02:00
to: points.edgeLeft.shift(0, 10),
2019-08-03 15:03:33 +02:00
})
2019-03-16 18:16:31 +01:00
2019-08-03 15:03:33 +02:00
if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
2019-03-17 17:30:25 +01:00
if (paperless) {
2019-08-03 15:03:33 +02:00
macro('hd', {
2019-03-17 17:30:25 +01:00
from: points.edgeLeft,
to: points.edgeRight,
2021-04-24 10:16:31 +02:00
y: points.edgeLeft.y - sa - 15,
2019-08-03 15:03:33 +02:00
})
2019-03-17 17:30:25 +01:00
let corner = points.bottomRight
2019-08-03 15:03:33 +02:00
if (options.frontPocketRadius > 0) corner = points.rightStart
macro('vd', {
2019-03-17 17:30:25 +01:00
from: corner,
to: points.topRight,
2021-04-24 10:16:31 +02:00
x: points.edgeRight.x + sa + 15,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-17 17:30:25 +01:00
from: corner,
to: points.edgeRight,
2021-04-24 10:16:31 +02:00
x: points.edgeRight.x + sa + 30,
2019-08-03 15:03:33 +02:00
})
2019-03-17 17:30:25 +01:00
}
2019-03-16 18:16:31 +01:00
}
2019-08-03 15:03:33 +02:00
return part
2019-03-16 11:39:06 +01:00
}