2022-06-19 23:23:10 +00:00
|
|
|
export default function (part) {
|
2022-07-10 16:09:59 +02:00
|
|
|
const {
|
|
|
|
points,
|
|
|
|
Path,
|
|
|
|
paths,
|
|
|
|
options,
|
|
|
|
snippets,
|
|
|
|
} = part.shorthand()
|
2022-06-19 23:23:10 +00:00
|
|
|
|
2022-07-10 16:09:59 +02:00
|
|
|
// Hide Bella paths
|
2022-06-19 23:23:10 +00:00
|
|
|
for (let key of Object.keys(paths)) paths[key].render = false
|
|
|
|
for (let i in snippets) delete snippets[i]
|
2022-06-20 21:25:06 +00:00
|
|
|
|
2022-06-19 23:23:10 +00:00
|
|
|
delete points.__titleNr
|
|
|
|
delete points.__titleName
|
|
|
|
delete points.__titlePattern
|
|
|
|
delete points.scaleboxAnchor
|
|
|
|
delete points.__scaleboxImperialBottomLeft
|
|
|
|
delete points.__scaleboxMetricBottomLeft
|
|
|
|
delete points.__scaleboxImperialTopLeft
|
|
|
|
delete points.__scaleboxMetricTopLeft
|
|
|
|
delete points.__scaleboxImperialTopRight
|
|
|
|
delete points.__scaleboxMetricTopRight
|
|
|
|
delete points.__scaleboxImperialBottomRight
|
|
|
|
delete points.__scaleboxMetricBottomRight
|
|
|
|
delete points.__scaleboxLead
|
|
|
|
delete points.__scaleboxTitle
|
|
|
|
delete points.__scaleboxText
|
|
|
|
delete points.__scaleboxLink
|
|
|
|
delete points.__scaleboxImperial
|
|
|
|
delete points.__scaleboxMetric
|
|
|
|
delete points.bustDartLeft
|
|
|
|
delete points.bustDartLeftCp
|
2022-06-22 09:32:12 +02:00
|
|
|
|
2022-06-19 23:23:10 +00:00
|
|
|
points.shoulderDart = points.hps.shiftFractionTowards( points.shoulder, options.shoulderDartPosition )
|
2022-06-22 09:32:12 +02:00
|
|
|
|
2022-06-19 23:23:10 +00:00
|
|
|
let aUp = points.dartTip.angle( points.shoulderDart )
|
|
|
|
let aDown = points.dartBottomRight.angle( points.dartTip )
|
|
|
|
let aDiff = Math.abs( aUp - aDown )
|
2022-06-22 09:32:12 +02:00
|
|
|
|
2022-06-19 23:23:10 +00:00
|
|
|
// let dartCpAdjustment = Math.abs( options.shoulderDartPosition -.5) +.05
|
|
|
|
let dartCpAdjustment = aDiff /50
|
|
|
|
|
2022-06-22 09:32:12 +02:00
|
|
|
points.shoulderDartCpUp = points.shoulderDart.shiftFractionTowards( points.dartTip, 1 - dartCpAdjustment)
|
2022-06-19 23:23:10 +00:00
|
|
|
points.shoulderDartCpDown = points.shoulderDart.shiftFractionTowards( points.dartTip, 1 +dartCpAdjustment )
|
2022-06-22 09:32:12 +02:00
|
|
|
|
|
|
|
const length = {
|
|
|
|
i: new Path()
|
|
|
|
.move(points.dartBottomLeft)
|
|
|
|
.curve(points.dartLeftCp, points.shoulderDartCpDown, points.dartTip)
|
|
|
|
.curve(points.shoulderDartCpUp, points.shoulderDart, points.shoulderDart)
|
|
|
|
.length()
|
|
|
|
}
|
2022-06-19 23:23:10 +00:00
|
|
|
|
|
|
|
let iteration = 0
|
|
|
|
let diff = 0
|
|
|
|
let angle = 0
|
|
|
|
do {
|
2022-06-22 09:32:12 +02:00
|
|
|
if (length?.o) angle = diff*( length.o > length.i ? -.1 : .1 )
|
|
|
|
|
2022-06-19 23:23:10 +00:00
|
|
|
points.dartBottomRight = points.dartBottomRight.rotate( angle, points.waistSide )
|
|
|
|
|
2022-06-22 09:32:12 +02:00
|
|
|
length.o = new Path()
|
2022-06-19 23:23:10 +00:00
|
|
|
.move(points.shoulderDart)
|
|
|
|
.curve(points.shoulderDart, points.shoulderDartCpUp, points.dartTip)
|
2022-06-22 09:32:12 +02:00
|
|
|
.curve(points.shoulderDartCpDown, points.dartRightCp, points.dartBottomRight)
|
|
|
|
.length()
|
2022-06-19 23:23:10 +00:00
|
|
|
|
2022-06-22 09:32:12 +02:00
|
|
|
diff = length.o - length.i
|
2022-06-19 23:23:10 +00:00
|
|
|
iteration ++
|
|
|
|
|
|
|
|
} while( diff < -.5 || diff > .5 && iteration < 100 )
|
|
|
|
if( iteration >= 100 ) {
|
|
|
|
raise.error('Something is not quite right here!')
|
|
|
|
}
|
2022-06-22 09:32:12 +02:00
|
|
|
|
2022-06-19 23:23:10 +00:00
|
|
|
return part
|
2022-06-22 09:32:12 +02:00
|
|
|
}
|