1
0
Fork 0
freesewing/designs/tristan/src/backpoints.mjs

108 lines
3.5 KiB
JavaScript
Raw Normal View History

2023-10-22 18:58:54 +00:00
import { backPoints as nobleBackPoints } from '@freesewing/noble'
2023-10-19 15:24:06 +00:00
import { hidePresets } from '@freesewing/core'
import * as options from './options.mjs'
2023-10-22 18:58:54 +00:00
import { frontPoints } from './frontpoints.mjs'
2023-10-19 15:24:06 +00:00
export const backPoints = {
2023-10-22 18:58:54 +00:00
name: 'tristan.backPoints',
from: nobleBackPoints,
after: frontPoints,
2023-10-19 15:24:06 +00:00
hide: hidePresets.HIDE_ALL,
options,
2023-10-22 18:58:54 +00:00
draft: ({ points, Path, paths, options, snippets, log, store, part }) => {
// Hide Noble paths
2023-10-19 15:24:06 +00:00
for (const key of Object.keys(paths)) paths[key].hide()
for (const i in snippets) delete snippets[i]
delete points.bustDartLeft
delete points.bustDartLeftCp
2023-10-22 18:58:54 +00:00
const strapWidth = store.get('strapWidth')
console.log({ BP_options: JSON.parse(JSON.stringify(options)) })
console.log({ BP_points: JSON.parse(JSON.stringify(points)) })
console.log({ BP_paths: JSON.parse(JSON.stringify(paths)) })
points.strapInside = points.shoulderDart.shiftTowards(points.hps, strapWidth / 2)
points.strapOutside = points.shoulderDart.shiftTowards(points.shoulder, strapWidth / 2)
points.shoulder = points.strapOutside
2023-10-19 15:24:06 +00:00
2023-10-22 18:58:54 +00:00
// points.cbCut = points.cbNeck.shiftFractionTowards(points.waistCenter, options.cutDepthBack)
points.cbCut = new Path()
.move(points.cbNeck)
.curve_(points.cbNeckCp2, points.waistCenter)
.shiftFractionAlong(options.cutDepthBack)
2023-10-19 15:24:06 +00:00
2023-10-22 18:58:54 +00:00
points.cbCutCp2 = new Path()
.move(points.cbNeck)
.curve_(points.cbNeckCp2, points.waistCenter)
.split(points.cbCut)[1].ops[1].cp2
2023-10-19 15:24:06 +00:00
2023-10-22 18:58:54 +00:00
points.cutSeamInside = new Path()
.move(points.dartBottomLeft)
.curve(points.dartLeftCp, points.shoulderDartCpDown, points.dartTip)
.curve(points.shoulderDartCpUp, points.shoulderDart, points.shoulderDart)
.intersectsY(points.cbCut.y)[0]
points.cutSeamOutside = new Path()
.move(points.shoulderDart)
.curve(points.shoulderDart, points.shoulderDartCpUp, points.dartTip)
.curve(points.shoulderDartCpDown, points.dartRightCp, points.dartBottomRight)
.intersectsY(points.cbCut.y)[0]
points.cbCutCp = points.cbCut.shiftFractionTowards(
points.cutSeamInside,
1 - options.cutRoundnessBack
2023-10-19 15:24:06 +00:00
)
2023-10-22 18:58:54 +00:00
points.strapInsideCp = points.strapInside.shiftFractionTowards(
points.cutSeamInside.shift(
points.cutSeamInside.angle(points.shoulderDart) + 90,
strapWidth / 2
),
1 - options.cutRoundnessBack
2023-10-19 15:24:06 +00:00
)
2023-10-22 18:58:54 +00:00
points.armholeCutCp = points.armhole.shiftFractionTowards(
points.cutSeamOutside,
1 - options.cutRoundnessBack
)
points.strapOutsideCp = points.strapOutside.shiftFractionTowards(
points.cutSeamOutside.shift(
points.cutSeamOutside.angle(points.shoulderDart) - 90,
strapWidth / 2
),
1 - options.cutRoundnessBack
)
const armHole = new Path()
.move(points.armhole)
.curve(points.armholeCp2, points.armholePitchCp1, points.armholePitch)
.curve_(points.armholePitchCp2, points.shoulder)
console.log({
intersects: armHole.intersects(
new Path()
.move(points.strapOutside)
.curve(points.strapOutsideCp, points.armholeCutCp, points.armhole)
).length,
})
2023-10-19 15:24:06 +00:00
2023-10-22 18:58:54 +00:00
var iter = 0
while (
armHole.intersects(
new Path()
.move(points.strapOutside)
.curve(points.strapOutsideCp, points.armholeCutCp, points.armhole)
).length != 0 &&
++iter < 250
) {
points.armholeCutCp = points.armholeCutCp.shiftFractionTowards(points.cutSeamOutside, 0.05)
2023-10-19 15:24:06 +00:00
}
return part
},
}