1
0
Fork 0
freesewing/packages/florent/src/briminterfacing.js

73 lines
2.2 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, complete, points, macro, paths, Path } = part.shorthand()
2019-04-07 17:01:58 +02:00
2019-08-03 15:03:33 +02:00
paths.hint = paths.seam.clone().attr('class', 'dashed stroke-sm')
2019-04-07 17:01:58 +02:00
paths.outset = new Path()
.move(points.tipLeft)
.curve(points.tipLeftCp2, points.outerMidCp1, points.outerMid)
.curve(points.outerMidCp2, points.tipRightCp1, points.tipRight)
2019-08-03 15:03:33 +02:00
.attr('class', 'lining')
points.outsetStart = paths.outset.shiftAlong(5)
points.outsetEnd = paths.outset.reverse().shiftAlong(5)
2021-01-31 09:22:15 +01:00
paths.outset = paths.outset.split(points.outsetStart).pop().split(points.outsetEnd).shift()
2019-04-07 17:01:58 +02:00
paths.inset = new Path()
.move(points.tipLeft)
.curve(points.tipLeftCp1, points.innerMidCp2, points.innerMid)
.curve(points.innerMidCp1, points.tipRightCp2, points.tipRight)
2019-08-03 15:03:33 +02:00
.attr('class', 'various')
points.insetStart = paths.inset.shiftAlong(5)
points.insetEnd = paths.inset.reverse().shiftAlong(5)
2021-01-31 09:22:15 +01:00
paths.inset = paths.inset.split(points.insetStart).pop().split(points.insetEnd).shift()
2019-08-03 15:03:33 +02:00
paths.inset.render = false
paths.outset.render = false
2019-04-07 17:01:58 +02:00
2019-08-03 15:03:33 +02:00
paths.hint = paths.seam.clone().attr('class', 'dashed stroke-sm')
2019-04-07 17:01:58 +02:00
paths.seam = paths.outset
.clone()
.line(paths.inset.end())
.join(paths.inset.reverse())
.line(paths.outset.start())
.close()
2019-08-03 15:03:33 +02:00
.attr('class', 'interfacing')
2019-04-07 17:01:58 +02:00
2019-04-08 18:25:01 +02:00
// Clean up
for (let i of Object.keys(paths)) {
2019-08-03 15:03:33 +02:00
if (['seam', 'inset', 'outset'].indexOf(i) === -1) delete paths[i]
2019-04-08 18:25:01 +02:00
}
2019-04-07 17:01:58 +02:00
if (complete) {
2019-08-03 15:03:33 +02:00
points.title = points.innerMid.shiftFractionTowards(points.outerMidCp2, 0.35)
macro('title', {
2019-04-08 18:25:01 +02:00
at: points.title,
nr: 5,
2019-08-03 15:03:33 +02:00
title: 'brimInterfacing'
})
macro('grainline', {
2019-04-08 18:25:01 +02:00
from: points.outerMid,
to: points.innerMid
2019-08-03 15:03:33 +02:00
})
2019-04-08 18:25:01 +02:00
2019-04-07 17:01:58 +02:00
if (paperless) {
2019-08-03 15:03:33 +02:00
macro('hd', {
from: paths.seam.edge('left'),
to: paths.seam.edge('right'),
2019-04-08 18:25:01 +02:00
y: points.tipLeft.y - sa - 15
2019-08-03 15:03:33 +02:00
})
macro('vd', {
from: paths.outset.edge('bottom'),
to: paths.inset.edge('bottom'),
2019-04-08 18:25:01 +02:00
x: points.innerMid.x - 15
2019-08-03 15:03:33 +02:00
})
macro('vd', {
from: paths.outset.edge('bottom'),
to: paths.inset.edge('topRight'),
2019-04-08 18:25:01 +02:00
x: points.tipRight.x + sa + 18
2019-08-03 15:03:33 +02:00
})
2019-04-07 17:01:58 +02:00
}
}
2019-08-03 15:03:33 +02:00
return part
2019-04-07 17:01:58 +02:00
}