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

92 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-03-30 19:01:32 +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-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'),
prefix: 'roundLeft'
})
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'),
prefix: 'roundRight'
})
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 {
2019-08-03 15:03:33 +02:00
paths.seam = new Path()
.move(points.topLeft)
.line(points.bottomLeft)
.line(points.bottomRight)
2019-03-30 19:01:32 +01:00
}
paths.seam = paths.seam
.line(points.topRight)
.line(points.topLeft)
.close()
2019-08-03 15:03:33 +02:00
.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,
2019-08-03 15:03:33 +02:00
title: 'pocketLining'
})
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)),
to: points.topLeft.shift(0, 10 + (store.get('pocketRadius') || 0))
})
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,
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,
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,
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
}