1
0
Fork 0
freesewing/packages/hugo/src/hoodcenter.js

73 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-12-20 11:41:35 +01:00
export default function(part) {
let {
store,
sa,
Point,
points,
Path,
paths,
complete,
paperless,
macro,
units
2019-08-03 15:03:33 +02:00
} = part.shorthand()
2018-09-21 21:30:20 +02:00
2019-08-03 15:03:33 +02:00
let width = store.get('hoodCenterWidth')
points.topLeft = new Point(0, 0)
points.bottomLeft = new Point(0, width)
points.topMidLeft = new Point(width, 0)
points.bottomMidLeft = new Point(width, width)
points.topMidRight = new Point(width * 1.5, 0)
points.bottomMidRight = new Point(width * 1.5, width)
points.topRight = new Point(width * 2.5, 0)
points.bottomRight = new Point(width * 2.5, width)
2018-09-21 21:30:20 +02:00
2018-12-20 11:41:35 +01:00
paths.seam = new Path()
.move(points.topMidLeft)
.line(points.topLeft)
.line(points.bottomLeft)
.line(points.bottomMidLeft)
.move(points.bottomMidRight)
.line(points.bottomRight)
.line(points.topRight)
.line(points.topMidRight)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
2018-12-20 11:41:35 +01:00
paths.hint = new Path()
.move(points.topMidLeft)
.line(points.topMidRight)
.move(points.bottomMidLeft)
.line(points.bottomMidRight)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric dashed')
2018-09-21 21:30:20 +02:00
2018-12-20 11:41:35 +01:00
// Complete pattern?
if (complete) {
if (sa) {
2019-08-03 15:03:33 +02:00
paths.sa = paths.seam.offset(sa)
2018-09-21 21:30:20 +02:00
}
2019-08-03 15:03:33 +02:00
points.title = points.bottomLeft.shiftFractionTowards(points.topRight, 0.5)
macro('title', { at: points.title, nr: 7, title: 'hoodCenter' })
macro('grainline', {
2018-12-20 11:41:35 +01:00
from: points.topLeft.shift(-90, width / 2),
to: points.topRight.shift(-90, width / 2)
2019-08-03 15:03:33 +02:00
})
// Always include this dimension as we don't print the entire part
macro('hd', {
from: points.bottomLeft,
to: points.bottomRight,
y: points.bottomRight.y + sa + 15,
text: units(store.get('hoodCenterLength'))
})
2018-12-20 11:41:35 +01:00
}
2018-09-21 21:30:20 +02:00
2018-12-20 11:41:35 +01:00
// Paperless?
if (paperless) {
2019-08-03 15:03:33 +02:00
macro('vd', {
2018-12-20 11:41:35 +01:00
from: points.bottomRight,
to: points.topRight,
x: points.topRight.x + sa + 15
2019-08-03 15:03:33 +02:00
})
2018-09-21 21:30:20 +02:00
}
2019-08-03 15:03:33 +02:00
return part
}