1
0
Fork 0
freesewing/packages/carlton/src/pocketlining.js

75 lines
2.1 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 { paperless, sa, store, complete, points, options, macro, Point, paths, Path } =
part.shorthand()
2019-03-30 19:01:32 +01:00
2019-08-03 15:03:33 +02:00
points.topLeft = points.bottomLeft.shiftFractionTowards(points.topLeft, 0.75)
points.topRight = new Point(points.bottomRight.x, points.topLeft.y)
2019-03-30 19:01:32 +01:00
if (options.pocketRadius > 0) {
2019-08-03 15:03:33 +02:00
macro('round', {
2019-03-30 19:01:32 +01:00
from: points.topLeft,
to: points.bottomRight,
via: points.bottomLeft,
2019-08-03 15:03:33 +02:00
radius: store.get('pocketRadius'),
2021-04-24 10:16:31 +02:00
prefix: 'roundLeft',
2019-08-03 15:03:33 +02:00
})
macro('round', {
2019-03-30 19:01:32 +01:00
from: points.bottomLeft,
to: points.topRight,
via: points.bottomRight,
2019-08-03 15:03:33 +02:00
radius: store.get('pocketRadius'),
2021-04-24 10:16:31 +02:00
prefix: 'roundRight',
2019-08-03 15:03:33 +02:00
})
2019-03-30 19:01:32 +01:00
paths.seam = new Path()
.move(points.topLeft)
.line(points.roundLeftStart)
.curve(points.roundLeftCp1, points.roundLeftCp2, points.roundLeftEnd)
.line(points.roundRightStart)
.curve(points.roundRightCp1, points.roundRightCp2, points.roundRightEnd)
} else {
2021-01-31 09:22:15 +01:00
paths.seam = new Path().move(points.topLeft).line(points.bottomLeft).line(points.bottomRight)
2019-03-30 19:01:32 +01:00
}
2021-01-31 09:22:15 +01:00
paths.seam = paths.seam.line(points.topRight).line(points.topLeft).close().attr('class', 'lining')
2019-03-30 19:01:32 +01:00
2019-08-03 15:03:33 +02:00
delete paths.fold
2019-03-30 19:01:32 +01:00
if (complete) {
2019-08-03 15:03:33 +02:00
points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
macro('title', {
2019-03-30 19:01:32 +01:00
at: points.title,
nr: 16,
2021-04-24 10:16:31 +02:00
title: 'pocketLining',
2019-08-03 15:03:33 +02:00
})
2019-03-30 19:01:32 +01:00
2019-08-03 15:03:33 +02:00
macro('grainline', {
from: points.bottomLeft.shift(0, 10 + (store.get('pocketRadius') || 0)),
2021-04-24 10:16:31 +02:00
to: points.topLeft.shift(0, 10 + (store.get('pocketRadius') || 0)),
2019-08-03 15:03:33 +02:00
})
2019-03-30 19:01:32 +01:00
2019-08-03 15:03:33 +02:00
if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'lining sa')
2019-03-30 19:01:32 +01:00
if (paperless) {
2019-08-03 15:03:33 +02:00
macro('vd', {
2019-03-30 19:01:32 +01:00
from: points.bottomRight,
to: points.topRight,
2021-04-24 10:16:31 +02:00
x: points.topRight.x + sa + 15,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2019-03-30 19:01:32 +01:00
from: points.topLeft,
to: points.topRight,
2021-04-24 10:16:31 +02:00
y: points.topRight.y - sa - 15,
2019-08-03 15:03:33 +02:00
})
2019-03-30 19:01:32 +01:00
if (options.pocketRadius > 0) {
2019-08-03 15:03:33 +02:00
macro('hd', {
2019-03-30 19:01:32 +01:00
from: points.roundRightStart,
to: points.roundRightEnd,
2021-04-24 10:16:31 +02:00
y: points.bottomRight.y + sa + 15,
2019-08-03 15:03:33 +02:00
})
2019-03-30 19:01:32 +01:00
}
}
}
2019-08-03 15:03:33 +02:00
return part
2019-03-30 19:01:32 +01:00
}