1
0
Fork 0
freesewing/designs/jaeger/src/innerpocketbag.mjs

128 lines
2.8 KiB
JavaScript
Raw Normal View History

2022-09-05 18:47:21 +02:00
import { front } from './front.mjs'
2022-09-11 15:48:48 +02:00
function jaegerInnerPocketBag({
sa,
store,
complete,
points,
options,
2023-09-17 17:06:47 +02:00
expand,
units,
2022-09-11 15:48:48 +02:00
macro,
Point,
paths,
Path,
part,
}) {
2022-09-05 18:47:21 +02:00
const width = store.get('innerPocketWidth')
const welt = store.get('innerPocketWeltHeight')
const height = width * options.innerPocketDepth
2019-03-16 11:39:06 +01:00
2023-09-17 17:06:47 +02:00
if (expand) {
store.flag.preset('expandIsOn')
} else {
// Expand is off, do not draw the part but flag this to the user
const extraSa = sa ? 2 * sa : 0
2023-09-17 17:06:47 +02:00
store.flag.note({
msg: `jaeger:cutInnerPocketBag`,
notes: [sa ? 'flag:saIncluded' : 'flag:saExcluded', 'flag:partHiddenByExpand'],
2023-09-17 17:06:47 +02:00
replace: {
width: units(width + extraSa),
length: units(height + extraSa),
2023-09-17 17:06:47 +02:00
},
suggest: {
text: 'flag:show',
icon: 'expand',
update: {
settings: ['expand', 1],
},
},
})
// Also hint about expand
store.flag.preset('expandIsOff')
return part.hide()
}
2019-08-03 15:03:33 +02:00
points.topLeft = new Point(0, 0)
points.topRight = new Point(width, 0)
points.foldLeft = new Point(0, height)
points.foldRight = new Point(width, height)
points.bottomLeft = new Point(0, height * 2 + welt * 2)
points.bottomRight = new Point(width, height * 2 + welt * 2)
2019-03-16 11:39:06 +01:00
// Paths
paths.seam = new Path()
.move(points.topLeft)
.line(points.bottomLeft)
.line(points.bottomRight)
.line(points.topRight)
.line(points.topLeft)
.close()
2019-08-03 15:03:33 +02:00
.attr('class', 'lining')
2019-03-16 11:39:06 +01:00
2023-09-17 17:06:47 +02:00
if (complete)
paths.fold = new Path()
.move(points.foldLeft)
.line(points.foldRight)
.addClass('stroke-sm lining dashed')
.addText('foldAlongThisLine', 'center fill-note')
2019-03-16 11:39:06 +01:00
2023-09-17 17:06:47 +02:00
if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'lining sa')
2019-03-16 18:36:19 +01:00
2023-09-17 17:06:47 +02:00
/*
* Annotations
*/
// Cutlist
store.cutlist.setCut({ cut: 2, from: 'lining' })
2019-03-16 18:36:19 +01:00
2023-09-17 17:06:47 +02:00
// Title
points.title = points.topLeft.shiftFractionTowards(points.foldRight, 0.5)
macro('title', {
at: points.title,
nr: 14,
title: 'innerPocketBag',
align: 'center',
})
2019-03-16 18:36:19 +01:00
2023-09-17 17:06:47 +02:00
// Grainline
macro('grainline', {
from: points.bottomLeft.shift(0, 10),
to: points.topLeft.shift(0, 10),
})
2019-03-17 17:25:03 +01:00
2023-09-17 17:06:47 +02:00
// Dimensions
macro('hd', {
id: 'wFull',
from: points.topLeft,
to: points.topRight,
y: points.topRight.y - sa - 15,
})
macro('vd', {
id: 'hToFold',
from: points.bottomRight,
to: points.foldRight,
x: points.topRight.x + sa + 15,
})
macro('vd', {
id: 'hFromFold',
from: points.foldRight,
to: points.topRight,
x: points.topRight.x + sa + 15,
})
macro('vd', {
id: 'hFull',
from: points.bottomRight,
to: points.topRight,
x: points.topRight.x + sa + 30,
})
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
}
2022-09-05 18:47:21 +02:00
export const innerPocketBag = {
name: 'jaeger.innerPocketBag',
after: front,
draft: jaegerInnerPocketBag,
}