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

78 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-03-16 11:39:06 +01:00
export default function(part) {
2019-08-03 15:03:33 +02:00
let {
paperless,
sa,
store,
complete,
points,
options,
macro,
Point,
paths,
Path
} = part.shorthand()
2019-03-16 11:39:06 +01:00
2019-08-03 15:03:33 +02:00
let width = store.get('chestPocketWidth')
let height = store.get('chestPocketWeltHeight')
let angle = options.chestPocketAngle
2019-03-16 11:39:06 +01:00
2019-08-03 15:03:33 +02:00
points.anchor = new Point(0, 0)
points.top = points.anchor.shift(90 - angle, height / 2)
points.bottom = points.anchor.shift(-90 - angle, height / 2)
points.topLeft = points.top.shift(180, width / 2)
points.topRight = points.topLeft.rotate(180, points.top)
points.bottomLeft = points.bottom.shift(180, width / 2)
points.bottomRight = points.bottomLeft.rotate(180, points.bottom)
points.foldLeft = points.bottomLeft.flipY(points.topLeft)
points.foldRight = points.bottomRight.flipY(points.topLeft)
2019-03-16 11:39:06 +01:00
// Paths
paths.seam = new Path()
.move(points.foldLeft)
.line(points.topLeft)
.line(points.bottomLeft)
.line(points.bottomRight)
.line(points.topRight)
.line(points.foldRight)
.line(points.foldLeft)
.close()
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
2019-03-16 11:39:06 +01:00
paths.fold = new Path()
.move(points.topLeft)
.line(points.topRight)
2019-08-03 15:03:33 +02:00
.attr('class', 'stroke-sm dashed')
2019-03-16 11:39:06 +01:00
2019-03-16 18:36:19 +01:00
if (complete) {
// Title
2019-08-03 15:03:33 +02:00
macro('title', {
2019-03-16 18:36:19 +01:00
at: points.top,
nr: 11,
2019-08-03 15:03:33 +02:00
title: 'chestPocketWelt'
})
2019-03-16 18:36:19 +01:00
// Grainline
2019-08-03 15:03:33 +02:00
macro('grainline', {
2019-03-16 18:36:19 +01:00
from: points.bottomLeft.shift(0, 10),
to: points.bottomLeft.shiftFractionTowards(points.topLeft, 2).shift(0, 10)
2019-08-03 15:03:33 +02:00
})
2019-03-16 18:36:19 +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:22:41 +01:00
if (paperless) {
2019-08-03 15:03:33 +02:00
macro('hd', {
2019-03-17 17:22:41 +01:00
from: points.foldLeft,
to: points.foldRight,
y: points.foldLeft.y - sa - 15
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-03-17 17:22:41 +01:00
from: points.bottomRight,
to: points.foldRight,
x: points.bottomRight.x + sa + 15
2019-08-03 15:03:33 +02:00
})
2019-03-17 17:22:41 +01:00
}
2019-03-16 18:36:19 +01:00
}
2019-08-03 15:03:33 +02:00
return part
2019-03-16 11:39:06 +01:00
}