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

215 lines
5.8 KiB
JavaScript
Raw Normal View History

2022-09-05 19:21:51 +02:00
import { front as brianFront } from '@freesewing/brian'
import {
collarEase,
armholeDepthFactor,
shoulderEase,
shoulderSlopeReduction,
frontArmholeDeeper,
s3Collar,
s3Armhole,
chestEase,
hipsEase,
lengthBonus,
ribbingHeight,
} from './options.mjs'
2022-09-11 15:41:29 +02:00
function hugoFront({
utils,
store,
sa,
Point,
points,
Path,
paths,
Snippet,
snippets,
options,
measurements,
complete,
paperless,
macro,
part,
}) {
2018-12-20 11:41:35 +01:00
// Remove clutter
2022-09-14 15:02:39 +02:00
for (const key in paths) {
if (key !== 'seam') delete paths[key]
}
2018-09-21 21:30:20 +02:00
// Remove notch inherited from Brian
delete snippets.armholePitchNotch
// Fit the hips
points.hem.x = (measurements.hips * (1 + options.hipsEase)) / 4
points.hemCp2 = new Point(points.hem.x, points.cfWaist.y)
2018-12-20 11:41:35 +01:00
// Absolute values for percentages
store.set(
'lengthBonus',
options.lengthBonus * (measurements.hpsToWaistBack + measurements.waistToHips)
)
store.set(
'ribbing',
(measurements.hpsToWaistBack + measurements.waistToHips) * options.ribbingHeight
)
2018-09-21 21:30:20 +02:00
2018-12-20 11:41:35 +01:00
// Ribbing
2019-08-03 15:03:33 +02:00
points.cfRibbing = points.cfHem.shift(90, store.get('ribbing'))
points.ribbing = points.hem.shift(90, store.get('ribbing'))
2018-09-21 21:30:20 +02:00
2018-12-20 11:41:35 +01:00
// Raglan tip
let neckOpening = new Path()
.move(points.cfNeck)
.curve(points.cfNeckCp1, points.neckCp2, points.neck)
2019-08-03 15:03:33 +02:00
points.raglanTipFront = neckOpening.shiftFractionAlong(0.8)
let neckOpeningParts = neckOpening.split(points.raglanTipFront)
2018-09-21 21:30:20 +02:00
2018-12-20 11:41:35 +01:00
// Pocket
2019-08-03 15:03:33 +02:00
points.pocketHem = points.cfRibbing.shiftFractionTowards(points.ribbing, 0.6)
points.pocketCf = points.cfHem.shift(
90,
measurements.hpsToWaistBack * 0.33 + store.get('ribbing')
2019-08-03 15:03:33 +02:00
)
points.pocketTop = new Point(points.pocketHem.x, points.pocketCf.y)
2018-12-20 11:41:35 +01:00
points.pocketTip = points.pocketHem
.shift(90, points.pocketHem.x / 3)
2019-08-03 15:03:33 +02:00
.rotate(-30, points.pocketHem)
points.pocketTopCp = utils.beamsIntersect(
points.pocketTop,
points.pocketHem,
points.pocketTip,
points.pocketHem.rotate(90, points.pocketTip)
2019-08-03 15:03:33 +02:00
)
2018-12-20 11:41:35 +01:00
// Paths
paths.saBase = new Path()
.move(points.cfRibbing)
.line(points.ribbing)
.curve_(points.hemCp2, points.armhole)
2018-12-20 11:41:35 +01:00
.curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow)
.line(points.raglanTipFront)
2019-08-03 15:03:33 +02:00
.join(neckOpeningParts[0].reverse())
2022-09-11 15:41:29 +02:00
paths.saBase.render = false
paths.seam = paths.saBase.clone().close().attr('class', 'fabric')
2022-09-11 15:41:29 +02:00
// FIXME: This pocket path is not getting set on the paths object
// It's something to do with the paths proxy which -- I assume -- is proxying the wrong object?
2018-12-20 11:41:35 +01:00
paths.pocket = new Path()
.move(points.pocketHem)
.line(points.pocketTip)
.curve(points.pocketTip, points.pocketTopCp, points.pocketTop)
.line(points.pocketCf)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric help')
2022-09-11 15:41:29 +02:00
.setRender(false)
2018-12-20 11:41:35 +01:00
// Store shoulder seam length, neck opening path, shoulder slope and raglan length
2019-08-03 15:03:33 +02:00
store.set('shoulderLength', points.neck.dist(points.shoulder))
store.set('neckOpeningPartFront', neckOpeningParts[1])
store.set('neckOpeningAnchorFront', points.neck)
store.set('shoulderSlopeDeltaY', points.neck.dy(points.shoulder))
2018-12-20 11:41:35 +01:00
store.set(
2019-08-03 15:03:33 +02:00
'raglen',
2018-12-20 11:41:35 +01:00
new Path()
.move(points.raglanTipFront)
.line(points.armholeHollow)
.curve(points.armholeHollowCp1, points.armholeCp2, points.armhole)
.length()
2019-08-03 15:03:33 +02:00
)
store.set('neckOpeningLenFront', neckOpening.length())
store.set('neckCutoutFront', points.cfNeck.y)
2018-09-21 21:30:20 +02:00
2018-12-20 11:41:35 +01:00
// Complete pattern?
if (complete) {
2022-09-11 15:41:29 +02:00
//paths.pocket.setRender(true)
2019-08-03 15:03:33 +02:00
macro('cutonfold', {
2018-12-20 11:41:35 +01:00
from: points.cfNeck,
to: points.cfRibbing,
2021-04-24 10:16:31 +02:00
grainline: true,
2019-08-03 15:03:33 +02:00
})
points.title = new Point(points.armhole.x / 2, points.armhole.y)
macro('title', { at: points.title, nr: 1, title: 'front' })
store.set('notchFront', points.raglanTipFront.dist(points.armholeHollow) / 2)
2018-12-20 11:41:35 +01:00
points.sleeveNotch = points.raglanTipFront.shiftTowards(
points.armholeHollow,
2019-08-03 15:03:33 +02:00
store.get('notchFront')
)
snippets.sleeveNotch = new Snippet('notch', points.sleeveNotch)
store.set('frontRaglanTipToNotch', points.raglanTipFront.dist(points.sleeveNotch))
points.logo = points.title.shift(-90, 70)
snippets.logo = new Snippet('logo', points.logo)
2018-12-20 11:41:35 +01:00
if (sa) {
paths.sa = paths.saBase.offset(sa).line(points.cfNeck).attr('class', 'fabric sa')
2019-08-03 15:03:33 +02:00
paths.sa.move(points.cfRibbing).line(paths.sa.start())
2018-09-21 21:30:20 +02:00
}
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.cfRibbing,
to: points.cfNeck,
2021-04-24 10:16:31 +02:00
x: points.cfNeck.x - 15,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-20 11:41:35 +01:00
from: points.cfRibbing,
to: points.raglanTipFront,
2021-04-24 10:16:31 +02:00
x: points.cfNeck.x - 30,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-20 11:41:35 +01:00
from: points.ribbing,
to: points.armhole,
2021-04-24 10:16:31 +02:00
x: points.ribbing.x + 15 + sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-20 11:41:35 +01:00
from: points.cfNeck,
to: points.raglanTipFront,
2021-04-24 10:16:31 +02:00
y: points.raglanTipFront.y - 15 - sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-20 11:41:35 +01:00
from: points.raglanTipFront,
to: points.armhole,
2021-04-24 10:16:31 +02:00
y: points.raglanTipFront.y - 15 - sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-20 11:41:35 +01:00
from: points.cfRibbing,
to: points.pocketTop,
2021-04-24 10:16:31 +02:00
y: points.cfRibbing.y + 15 + sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-20 11:41:35 +01:00
from: points.cfRibbing,
to: points.pocketTip,
2021-04-24 10:16:31 +02:00
y: points.cfRibbing.y + 30 + sa,
2019-08-03 15:03:33 +02:00
})
macro('hd', {
2018-12-20 11:41:35 +01:00
from: points.cfRibbing,
to: points.ribbing,
2021-04-24 10:16:31 +02:00
y: points.cfRibbing.y + 45 + sa,
2019-08-03 15:03:33 +02:00
})
macro('vd', {
2018-12-20 11:41:35 +01:00
from: points.pocketHem,
to: points.pocketTop,
2021-04-24 10:16:31 +02:00
x: points.pocketTip.x + 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
}
2022-09-05 19:21:51 +02:00
export const front = {
name: 'hugo.front',
from: brianFront,
2022-09-11 15:41:29 +02:00
hideDependencies: true,
2022-09-05 19:21:51 +02:00
measurements: ['hips', 'waistToHips'],
options: {
collarEase,
armholeDepthFactor,
shoulderEase,
shoulderSlopeReduction,
frontArmholeDeeper,
s3Collar,
s3Armhole,
chestEase,
hipsEase,
lengthBonus,
ribbingHeight,
},
draft: hugoFront,
}