1
0
Fork 0
freesewing/packages/benjamin/src/ribbon.js

66 lines
1.4 KiB
JavaScript
Raw Normal View History

export default function (part) {
2019-07-08 15:54:19 +02:00
let {
Point,
Path,
measurements,
store,
options,
complete,
macro,
points,
paths,
sa,
paperless
2019-08-03 15:03:33 +02:00
} = part.shorthand()
2019-07-08 15:54:19 +02:00
2019-10-01 12:43:10 -07:00
if (options.adjustmentRibbon) {
2019-08-03 15:03:33 +02:00
part.render = false
return part
2019-07-08 15:54:19 +02:00
}
// Points
2019-08-03 15:03:33 +02:00
points.bottomLeft = new Point(0, 0.5 * store.get('ribbonWidth'))
points.topLeft = points.bottomLeft.flipY()
2020-08-13 18:10:42 -07:00
points.bottomRight = points.bottomLeft.shift(
0,
measurements.neck * (1 + options.collarEase) - store.get('knotWidth') * 2
)
2019-08-03 15:03:33 +02:00
points.topRight = points.bottomRight.flipY()
points.titleAnchor = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
2019-07-08 15:54:19 +02: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', 'fabric')
2019-07-08 15:54:19 +02:00
if (complete) {
2019-08-03 15:03:33 +02:00
if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
macro('title', {
2019-07-08 15:54:19 +02:00
at: points.titleAnchor,
2019-10-01 12:43:10 -07:00
nr: 2,
2019-08-03 15:03:33 +02:00
title: 'ribbon',
2019-10-01 12:43:10 -07:00
scale: 0.3
2019-08-03 15:03:33 +02:00
})
2019-07-08 15:54:19 +02:00
if (paperless) {
2019-08-03 15:03:33 +02:00
macro('hd', {
2019-07-08 15:54:19 +02:00
from: points.bottomLeft,
to: points.bottomRight,
y: points.bottomLeft.y + 15 + sa
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2019-07-08 15:54:19 +02:00
from: points.bottomRight,
to: points.topRight,
x: points.topRight.x + 15 + sa
2019-08-03 15:03:33 +02:00
})
2019-07-08 15:54:19 +02:00
}
}
2019-08-03 15:03:33 +02:00
return part
2019-07-08 15:54:19 +02:00
}