1
0
Fork 0
freesewing/designs/brian/src/front.mjs

212 lines
6.3 KiB
JavaScript
Raw Normal View History

2022-08-26 14:45:51 +02:00
import * as shared from './shared.mjs'
import { back } from './back.mjs'
2018-08-03 17:44:55 +02:00
2022-08-26 14:45:51 +02:00
export const front = {
from: back,
2022-08-26 14:45:51 +02:00
name: 'brian.front',
2022-09-10 19:37:33 +02:00
draft: ({
store,
sa,
Point,
points,
Path,
paths,
Snippet,
snippets,
options,
complete,
macro,
utils,
part,
}) => {
// Re-use points for deeper armhole at the front
points.armholePitchCp1 = points.frontArmholePitchCp1
points.armholePitch = points.frontArmholePitch
points.armholePitchCp2 = points.frontArmholePitchCp2
// Adapt the shoulder line according to the relevant options
// Don't bother with less than 10% as that's just asking for trouble
if (options.s3Collar < 0.1 && options.s3Collar > -0.1) {
points.s3CollarSplit = points.hps
paths.frontCollar = new Path()
.move(points.hps)
.curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck)
2022-09-18 17:01:19 +02:00
.hide()
} else if (options.s3Collar > 0) {
// Shift shoulder seam forward on the collar side
points.s3CollarSplit = utils.curveIntersectsY(
points.hps,
points.neckCp2Front,
points.cfNeckCp1,
points.cfNeck,
store.get('s3CollarMaxFront') * options.s3Collar
)
paths.frontCollar = new Path()
.move(points.hps)
.curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck)
.split(points.s3CollarSplit)[1]
2022-09-18 17:01:19 +02:00
.hide()
} else if (options.s3Collar < 0) {
// Shift shoulder seam backward on the collar side
points.s3CollarSplit = utils.curveIntersectsY(
points.mirroredCbNeck,
points.mirroredCbNeck,
points.mirroredNeckCp2,
points.hps,
store.get('s3CollarMaxBack') * options.s3Collar
)
paths.frontCollar = new Path()
.move(points.hps)
.curve_(points.mirroredNeckCp2, points.mirroredCbNeck)
.split(points.s3CollarSplit)[0]
.reverse()
2022-09-15 13:49:55 +02:00
.join(
new Path().move(points.hps).curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck)
)
2022-09-18 17:01:19 +02:00
.hide()
}
if (options.s3Armhole < 0.1 && options.s3Armhole > -0.1) {
points.s3ArmholeSplit = points.shoulder
paths.frontArmhole = new Path()
.move(points.armholePitch)
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
2022-09-18 17:01:19 +02:00
.hide()
} else if (options.s3Armhole > 0) {
// Shift shoulder seam forward on the armhole side
points.s3ArmholeSplit = utils.curveIntersectsY(
points.shoulder,
points.shoulderCp1,
points.armholePitchCp2,
points.armholePitch,
store.get('s3ArmholeMax') * options.s3Armhole + points.shoulder.y
)
paths.frontArmhole = new Path()
.move(points.armholePitch)
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
.split(points.s3ArmholeSplit)[0]
2022-09-18 17:01:19 +02:00
.hide()
} else if (options.s3Armhole < 0) {
// Shift shoulder seam forward on the armhole side
points.s3ArmholeSplit = utils.curveIntersectsY(
points.shoulder,
points.mirroredShoulderCp1,
points.mirroredFrontArmholePitchCp2,
points.mirroredFrontArmholePitch,
store.get('s3ArmholeMax') * options.s3Armhole + points.shoulder.y
)
paths.frontArmhole = new Path()
.move(points.armholePitch)
.curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder)
.join(
new Path()
.move(points.shoulder)
.curve(
points.mirroredShoulderCp1,
points.mirroredFrontArmholePitchCp2,
points.mirroredFrontArmholePitch
)
.split(points.s3ArmholeSplit)[0]
)
2022-09-18 17:01:19 +02:00
.hide()
}
// Rename cb (center back) to cf (center front)
for (let key of ['Shoulder', 'Armhole', 'Waist', 'Hips', 'Hem']) {
points[`cf${key}`] = new Point(points[`cb${key}`].x, points[`cb${key}`].y)
delete points[`cb${key}`]
}
// Front neckline points
points.neckCp2 = new Point(points.neckCp2Front.x, points.neckCp2Front.y)
// Seamline
paths.saBase = new Path()
.move(points.cfHem)
.line(points.hem)
.line(points.armhole)
.curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow)
.curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch)
.join(paths.frontArmhole)
.line(points.s3CollarSplit)
.join(paths.frontCollar)
2018-08-06 16:19:12 +02:00
2022-09-18 17:01:19 +02:00
paths.saBase.hide()
paths.seam = new Path()
.move(points.cfNeck)
.line(points.cfHem)
.join(paths.saBase)
.attr('class', 'fabric')
2023-09-07 17:51:35 +02:00
if (sa) {
paths.sa = paths.saBase
.offset(sa)
.attr('class', 'fabric sa')
.line(points.cfNeck)
.move(points.cfHips)
paths.sa.line(paths.sa.start())
}
// Store lengths to fit sleeve
store.set('frontArmholeLength', shared.armholeLength(points, Path))
store.set('frontArmholeToArmholePitch', shared.armholeToArmholePitch(points, Path))
2023-09-07 17:51:35 +02:00
/*
* Annotations
*/
// Cut on fold
macro('cutonfold', {
from: points.cfNeck,
to: points.cfHips,
grainline: true,
})
2023-09-07 17:51:35 +02:00
// Title
macro('title', { at: points.title, nr: 1, title: 'front' })
// Notches
snippets.armholePitchNotch = new Snippet('notch', points.armholePitch)
// Add notches if the shoulder seam is shifted
shared.s3Notches(snippets, Snippet, points, options, 'notch')
// Wait line
if (complete)
paths.waist = new Path().move(points.cfWaist).line(points.waist).attr('class', 'help')
2023-09-07 17:51:35 +02:00
// Dimensions
shared.dimensions(part, 'front')
2023-09-07 17:51:35 +02:00
macro('hd', {
id: 'wHem',
from: points.cfHips,
to: points.hips,
y: points.hem.y + sa + 15,
})
macro('vd', {
id: 'hHemToWaist',
from: points.cfHem,
to: points.cfWaist,
x: points.cfHips.x - sa - 15,
})
macro('vd', {
id: 'hHemToNeckOpeningBottom',
from: points.cfHem,
to: points.cfNeck,
x: points.cfHips.x - sa - 30,
})
macro('hd', {
id: 'wCFrontToHps',
from: points.cfNeck,
to: points.s3CollarSplit,
y: points.s3CollarSplit.y - sa - 15,
})
macro('hd', {
id: 'WCFrontToShoulder',
from: points.cfNeck,
to: points.s3ArmholeSplit,
y: points.s3CollarSplit.y - sa - 30,
})
2018-08-03 17:44:55 +02:00
return part
2022-09-15 13:49:55 +02:00
},
2019-08-03 15:03:33 +02:00
}