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

157 lines
4.2 KiB
JavaScript
Raw Normal View History

2021-02-18 07:47:53 -08:00
export default function (part) {
2021-02-25 07:50:08 -08:00
let {
Path,
points,
paths,
Snippet,
snippets,
2021-03-09 17:43:06 +01:00
complete,
2021-02-25 07:50:08 -08:00
sa,
store,
paperless,
macro
} = part.shorthand()
2021-02-18 07:47:53 -08:00
2021-03-09 17:43:06 +01:00
let halfInch = store.get('halfInch')
2021-02-18 07:47:53 -08:00
2021-03-09 17:43:06 +01:00
paths.waistSeam = paths.waistSeam.split(points.pocketFacingTL)[0].setRender(false)
2021-02-18 07:47:53 -08:00
2021-03-09 17:43:06 +01:00
paths.sideSeam = paths.sideSeam.split(points.pocketFacingBR)[1].setRender(false)
points.brCPtl = points.pocketFacingBR.shift(
points.pocketFacingBR.angle(points.pocketSide) + 90,
halfInch * 3
)
points.tlCPbr = points.pocketFacingTL.shift(
points.pocketFacingTL.angle(points.pocketWaist) - 90,
halfInch * 6
)
2021-02-18 07:47:53 -08:00
2021-02-25 07:50:08 -08:00
paths.facingInside = new Path()
2021-03-09 17:43:06 +01:00
.move(points.pocketFacingTL)
.curve(points.tlCPbr, points.brCPtl, points.pocketFacingBR)
.setRender(false)
2021-02-18 07:47:53 -08:00
2021-02-25 07:50:08 -08:00
paths.pocketFold = new Path()
.move(points.pocketTL)
.line(points.pocketBL)
.attr('class', 'fabric dashed')
2021-02-18 07:47:53 -08:00
2021-03-09 17:43:06 +01:00
points.pocketBLcpBR = points.pocketBL.shift(0, points.pocketBL.dist(points.pocketFacingBR) * 0.75)
points.pocketBRcpBL = points.pocketFacingBR.shift(
180,
points.pocketBL.dist(points.pocketFacingBR) * 0.35
)
2021-02-25 07:50:08 -08:00
// Mirror a bunch of points
2021-03-09 17:43:06 +01:00
points.mpocketBLcpBR = points.pocketBLcpBR.flipX(points.pocketTL)
points.mpocketBRcpBL = points.pocketBRcpBL.flipX(points.pocketTL)
points.mpocketFacingBR = points.pocketFacingBR.flipX(points.pocketTL)
points.mpocketSide = points.pocketSide.flipX(points.pocketTL)
points.mpocketWaist = points.pocketWaist.flipX(points.pocketTL)
2021-02-25 07:50:08 -08:00
paths.pocketBottom = new Path()
2021-03-09 17:43:06 +01:00
.move(points.mpocketFacingBR)
.curve(points.mpocketBRcpBL, points.mpocketBLcpBR, points.pocketBL)
.curve(points.pocketBLcpBR, points.pocketBRcpBL, points.pocketFacingBR)
2021-02-25 07:50:08 -08:00
.attr('class', 'fabric')
paths.seam = paths.waistSeam
2021-03-09 17:43:06 +01:00
.line(points.mpocketWaist)
.line(points.mpocketSide)
.join(paths.pocketBottom)
.join(paths.sideSeam)
2021-02-25 07:50:08 -08:00
.close()
2021-03-09 17:43:06 +01:00
.setRender(true)
2021-02-25 07:50:08 -08:00
.attr('class', 'fabric')
2021-03-09 17:43:06 +01:00
if (complete) {
snippets.n1 = new Snippet('notch', points.pocketWaist)
snippets.n2 = new Snippet('notch', points.pocketSide)
snippets.n3 = new Snippet('notch', points.mpocketWaist)
snippets.n4 = new Snippet('notch', points.mpocketSide)
2021-02-25 07:50:08 -08:00
2021-03-09 17:43:06 +01:00
points.logo = points.pocketSide.shiftFractionTowards(points.pocketTL, 0.5)
2021-02-25 07:50:08 -08:00
snippets.logo = new Snippet('logo', points.logo)
points.title = points.logo.shift(270, 50)
macro('title', {
nr: 2,
at: points.title,
title: 'Pocket'
})
points.__titleNr.attr('data-text-class', 'center')
points.__titleName.attr('data-text-class', 'center')
points.__titlePattern.attr('data-text-class', 'center')
2021-03-09 17:43:06 +01:00
if (sa) {
2021-02-25 07:50:08 -08:00
paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
2021-02-18 07:47:53 -08:00
}
}
2021-02-25 07:50:08 -08:00
// Paperless?
if (paperless) {
macro('hd', {
from: points.mpocketFacingBR,
to: points.mpocketWaist,
2021-03-09 17:43:06 +01:00
y: points.pU.y - sa - 15
2021-02-25 07:50:08 -08:00
})
macro('hd', {
from: points.mpocketWaist,
to: points.pocketTL,
2021-03-09 17:43:06 +01:00
y: points.pU.y - sa - 15
2021-02-25 07:50:08 -08:00
})
macro('hd', {
from: points.pocketTL,
to: points.pocketWaist,
2021-03-09 17:43:06 +01:00
y: points.pU.y - sa - 15
2021-02-25 07:50:08 -08:00
})
macro('hd', {
from: points.pocketWaist,
to: points.pU,
2021-03-09 17:43:06 +01:00
y: points.pU.y - sa - 15
2021-02-25 07:50:08 -08:00
})
macro('hd', {
from: points.pU,
to: points.pocketFacingBR,
2021-03-09 17:43:06 +01:00
y: points.pU.y - sa - 15
2021-02-25 07:50:08 -08:00
})
macro('hd', {
from: points.pocketWaist,
to: points.pocketFacingTL,
2021-03-09 17:43:06 +01:00
y: points.pU.y - sa - 15
2021-02-25 07:50:08 -08:00
})
macro('vd', {
from: points.pU,
to: points.pocketSide,
2021-03-09 17:43:06 +01:00
x: points.pocketSide.x + sa + 15
2021-02-25 07:50:08 -08:00
})
macro('vd', {
from: points.pocketTL,
to: points.pocketBL,
2021-03-09 17:43:06 +01:00
x: points.pocketTL.x + 15
2021-02-25 07:50:08 -08:00
})
macro('vd', {
from: points.pocketSide,
to: points.mpocketWaist,
2021-03-09 17:43:06 +01:00
x: points.pocketSide.x + sa + 15
2021-02-25 07:50:08 -08:00
})
macro('vd', {
from: points.pocketSide,
to: points.pocketFacingBR,
2021-03-09 17:43:06 +01:00
x: points.pocketSide.x + sa + 15
2021-02-25 07:50:08 -08:00
})
macro('vd', {
from: points.mpocketWaist,
to: points.mpocketSide,
2021-03-09 17:43:06 +01:00
x: points.mpocketSide.x - sa - 15
2021-02-25 07:50:08 -08:00
})
macro('vd', {
from: points.mpocketSide,
to: points.mpocketFacingBR,
2021-03-09 17:43:06 +01:00
x: points.mpocketSide.x - sa - 15
2021-02-25 07:50:08 -08:00
})
}
2021-03-09 17:43:06 +01:00
2021-02-25 07:50:08 -08:00
return part
}