1
0
Fork 0
freesewing/designs/simon/src/sleeve.mjs

317 lines
9.5 KiB
JavaScript
Raw Normal View History

2022-09-04 15:55:34 +02:00
import { front } from './front.mjs'
import { sleeve as brianSleeve } from '@freesewing/brian'
import { hidePresets } from '@freesewing/core'
2022-09-04 15:55:34 +02:00
import {
cuffOverlap,
cuffDrape,
cuffEase,
cuffLength,
cuffStyle,
sleeveLengthBonus,
sleevePlacketLength,
} from './options.mjs'
2022-09-11 16:54:43 +02:00
function simonSleeve({
measurements,
sa,
Point,
points,
Path,
paths,
complete,
macro,
options,
snippets,
Snippet,
store,
part,
}) {
// Update the back armhole notch because the one from Brian is not correct
2022-01-19 16:22:32 +01:00
points.backNotch = paths.sleevecap.reverse().shiftAlong(store.get('backArmholeToArmholePitch'))
// Remove inherited paths, snippets, and scalebox
for (const p in paths) delete paths[p]
for (const s in snippets) delete snippets[s]
2023-09-18 18:40:19 +02:00
macro('rmscalebox')
// Determine the sleeve length
const len = measurements.shoulderToWrist * (1 + options.sleeveLengthBonus)
paths.sleevecap = new Path()
.move(points.bicepsRight)
._curve(points.capQ1Cp1, points.capQ1)
.curve(points.capQ1Cp2, points.capQ2Cp1, points.capQ2)
.curve(points.capQ2Cp2, points.capQ3Cp1, points.capQ3)
.curve(points.capQ3Cp2, points.capQ4Cp1, points.capQ4)
.curve_(points.capQ4Cp2, points.bicepsLeft)
2022-09-18 17:01:19 +02:00
.hide()
points.top = new Point(0, paths.sleevecap.edge('top').y)
points.bottom = points.top.shift(-90, len)
2018-12-23 17:25:53 +01:00
// Sleeve width depends on cuff style
let width = measurements.wrist * (1 + options.cuffEase + options.cuffOverlap)
2018-12-23 17:25:53 +01:00
if (
options.cuffStyle === 'straightFrenchCuff' ||
options.cuffStyle === 'roundedFrenchCuff' ||
2019-08-03 15:03:33 +02:00
options.cuffStyle === 'angledFrenchCuff'
2018-12-23 17:25:53 +01:00
)
width = measurements.wrist * (1 + options.cuffEase + options.cuffOverlap * 1.5)
const cuffLength = measurements.shoulderToWrist * options.cuffLength
2022-05-31 16:01:26 +02:00
points.wristRight = points.bottom.shift(0, width / 2).shift(90, cuffLength)
points.wristLeft = points.wristRight.flipX()
2018-12-23 17:25:53 +01:00
2019-08-03 15:03:33 +02:00
points.cuffMid = new Point(0, points.wristLeft.y)
points.cuffLeftMid = points.cuffMid.shiftFractionTowards(points.wristLeft, 0.5)
points.cuffRightMid = points.cuffMid.shiftFractionTowards(points.wristRight, 0.5)
points.cuffLeftCusp = points.cuffLeftMid.shift(90, width / 50)
points.cuffRightCusp = points.cuffRightMid.shift(-90, width / 50)
points.cuffLeftCuspCp1 = points.cuffLeftCusp.shift(180, width / 10)
points.cuffLeftCuspCp2 = points.cuffLeftCusp.shift(0, width / 10)
points.cuffRightCuspCp1 = points.cuffRightCusp.shift(180, width / 10)
points.cuffRightCuspCp2 = points.cuffRightCusp.shift(0, width / 10)
2018-12-23 17:25:53 +01:00
2018-12-27 16:42:27 +01:00
// Cuff pleats
const drape = options.cuffDrape * measurements.shoulderToWrist
2019-08-03 15:03:33 +02:00
let pleats = 0
const pleatLength = measurements.shoulderToWrist * 0.15
2018-12-27 16:42:27 +01:00
if (drape > 0) {
const shiftRight = [
2019-08-03 15:03:33 +02:00
'cuffRightCuspCp1',
'cuffRightCusp',
'cuffRightCuspCp2',
'wristRight',
2021-04-24 10:16:31 +02:00
'cuffRightMid',
2019-08-03 15:03:33 +02:00
]
const shiftLeft = ['cuffLeftCuspCp1', 'cuffLeftCusp', 'cuffLeftCuspCp2', 'wristLeft']
2019-08-03 15:03:33 +02:00
if (drape > 20) pleats = 2
else pleats = 1
for (const id of shiftRight) points[id] = points[id].shift(0, drape / (2 * pleats))
for (const id of shiftLeft) points[id] = points[id].shift(180, drape / (2 * pleats))
2019-08-03 15:03:33 +02:00
points.cuffPleat1Fold = points.cuffMid.shift(0, drape / (2 * pleats))
points.cuffPleat1Edge = points.cuffMid.shift(0, drape / pleats)
points.cuffMidTop = points.cuffMid.shift(90, pleatLength)
points.cuffPleat1FoldTop = points.cuffPleat1Fold.shift(90, pleatLength)
points.cuffPleat1EdgeTop = points.cuffPleat1Edge.shift(90, pleatLength)
2018-12-27 16:42:27 +01:00
if (pleats === 2) {
const moreRight = ['cuffRightCuspCp2', 'wristRight']
const shift = shiftRight.concat(shiftLeft)
for (const id of shift) {
2019-08-03 15:03:33 +02:00
if (moreRight.indexOf(id) === -1) points[id] = points[id].shift(180, drape / 4)
else points[id] = points[id].shift(0, drape / 4)
2018-12-27 16:42:27 +01:00
}
2019-08-03 15:03:33 +02:00
points.cuffPleat2Fold = points.cuffRightCusp.shift(0, drape / 4)
points.cuffPleat2Edge = points.cuffRightCusp.shift(0, drape / 2)
points.cuffPleat2FoldTop = points.cuffPleat2Fold.shift(90, pleatLength)
points.cuffPleat2EdgeTop = points.cuffPleat2Edge.shift(90, pleatLength)
points.cuffPleat2Top = points.cuffRightCusp.shift(90, pleatLength)
2018-12-27 16:42:27 +01:00
}
}
2018-12-23 17:25:53 +01:00
paths.frenchBase = new Path()
.move(points.wristRight)
.line(points.bicepsRight)
._curve(points.capQ1Cp1, points.capQ1)
.curve(points.capQ1Cp2, points.capQ2Cp1, points.capQ2)
.curve(points.capQ2Cp2, points.capQ3Cp1, points.capQ3)
.curve(points.capQ3Cp2, points.capQ4Cp1, points.capQ4)
2019-08-03 15:03:33 +02:00
.curve_(points.capQ4Cp2, points.bicepsLeft)
2022-09-18 17:01:19 +02:00
paths.frenchBase.hide()
2018-12-23 17:25:53 +01:00
2019-08-03 15:03:33 +02:00
paths.saBase = new Path().move(points.bicepsLeft).line(points.wristLeft)
2022-09-18 17:01:19 +02:00
paths.saBase.hide()
2018-12-23 17:25:53 +01:00
paths.cuffBase = new Path()
.move(points.wristLeft)
2019-08-03 15:03:33 +02:00
._curve(points.cuffLeftCuspCp1, points.cuffLeftCusp)
2018-12-27 16:42:27 +01:00
if (pleats > 0) {
2019-08-03 15:03:33 +02:00
paths.cuffBase.curve_(points.cuffLeftCuspCp2, points.cuffMid).line(points.cuffPleat1Edge)
2018-12-27 16:42:27 +01:00
}
2019-08-03 15:03:33 +02:00
paths.cuffBase._curve(points.cuffRightCuspCp1, points.cuffRightCusp)
if (pleats === 2) paths.cuffBase.line(points.cuffPleat2Edge)
paths.cuffBase.curve_(points.cuffRightCuspCp2, points.wristRight)
2022-09-18 17:01:19 +02:00
paths.cuffBase.hide()
2018-12-23 17:25:53 +01:00
paths.seam = paths.frenchBase
.clone()
.line(points.wristLeft)
.join(paths.cuffBase)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
2018-12-23 17:25:53 +01:00
2023-09-18 18:40:19 +02:00
if (sa) {
paths.sa = paths.frenchBase.offset(sa * options.ffsa)
paths.frenchSa = paths.sa.clone().attr('class', 'hidden')
paths.sa = paths.sa
.join(paths.saBase.offset(sa))
.join(paths.cuffBase.offset(sa))
.close()
.attr('class', 'fabric sa')
macro('banner', {
path: paths.frenchSa.reverse(),
text: 'simon:flatFelledSeamAllowance',
repeat: 30,
classes: 'text-sm fill-note center',
dy: 7,
})
}
2018-12-23 17:25:53 +01:00
if (complete) {
2018-12-27 16:42:27 +01:00
points.placketEnd = points.cuffLeftCusp.shift(
90,
options.sleevePlacketLength * measurements.shoulderToWrist
2019-08-03 15:03:33 +02:00
)
2018-12-27 16:42:27 +01:00
paths.placketCut = new Path()
.move(points.cuffLeftCusp)
.line(points.placketEnd)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
2018-12-27 16:42:27 +01:00
if (pleats > 0) {
paths.pleats = new Path()
.move(points.cuffMid)
.line(points.cuffMidTop)
.move(points.cuffPleat1Fold)
.line(points.cuffPleat1FoldTop)
.move(points.cuffPleat1Edge)
2019-08-03 15:03:33 +02:00
.line(points.cuffPleat1EdgeTop)
2018-12-27 16:42:27 +01:00
if (pleats === 2) {
paths.pleats
.move(points.cuffRightCusp)
.line(points.cuffPleat2Top)
.move(points.cuffPleat2Fold)
.line(points.cuffPleat2FoldTop)
.move(points.cuffPleat2Edge)
2019-08-03 15:03:33 +02:00
.line(points.cuffPleat2EdgeTop)
2018-12-27 16:42:27 +01:00
}
2019-08-03 15:03:33 +02:00
paths.pleats.attr('class', 'dotted')
2018-12-27 16:42:27 +01:00
}
2018-12-23 17:25:53 +01:00
}
2023-09-18 18:40:19 +02:00
/*
* Annotations
*/
// Notches
snippets.backNotch = new Snippet('bnotch', points.backNotch)
snippets.frontNotch = new Snippet('notch', points.frontNotch)
// Title
macro('title', { at: points.centerBiceps, nr: 5, title: 'sleeve' })
// Grainline
macro('grainline', {
from: points.cuffMid,
to: new Point(points.cuffMid.x, points.sleeveTip.y),
})
// Dimensions
macro('hd', {
id: 'wCenterToBackNotch',
from: points.backNotch,
to: points.sleeveTip,
y: points.sleeveTip.y - 15 - sa * options.ffsa,
})
macro('hd', {
id: 'wCenterToFrontNotch',
from: points.sleeveTip,
to: points.frontNotch,
y: points.sleeveTip.y - 15 - sa * options.ffsa,
})
macro('hd', {
id: 'wFrontHalf',
from: points.bicepsLeft,
to: points.sleeveTip,
y: points.sleeveTip.y - 30 - sa * options.ffsa,
})
macro('hd', {
id: 'wBackHalf',
from: points.sleeveTip,
to: points.bicepsRight,
y: points.sleeveTip.y - 30 - sa * options.ffsa,
})
macro('hd', {
id: 'wFull',
from: points.bicepsLeft,
to: points.bicepsRight,
y: points.sleeveTip.y - 45 - sa * options.ffsa,
})
macro('pd', {
id: 'lSleevecap',
path: new Path()
.move(points.bicepsRight)
._curve(points.capQ1Cp1, points.capQ1)
.curve(points.capQ1Cp2, points.capQ2Cp1, points.capQ2)
.curve(points.capQ2Cp2, points.capQ3Cp1, points.capQ3)
.curve(points.capQ3Cp2, points.capQ4Cp1, points.capQ4)
.curve_(points.capQ4Cp2, points.bicepsLeft)
.reverse(),
d: 15,
})
macro('vd', {
id: 'hCuffToSleevecap',
from: points.wristRight,
to: points.bicepsRight,
x: points.bicepsRight.x + 15 + sa * options.ffsa,
})
macro('vd', {
id: 'hSleevecapToFrontNotch',
from: points.bicepsRight,
to: points.frontNotch,
x: points.bicepsRight.x + 15 + sa * options.ffsa,
})
macro('vd', {
id: 'hSleevecapToBackNotch',
from: points.bicepsLeft,
to: points.backNotch,
x: points.bicepsLeft.x - 15 - sa,
})
if (complete)
2019-08-03 15:03:33 +02:00
macro('vd', {
2023-09-18 18:40:19 +02:00
id: 'hCut',
from: points.cuffLeftCusp,
to: points.placketEnd,
x: points.placketEnd.x - 15,
2019-08-03 15:03:33 +02:00
})
2023-09-18 18:40:19 +02:00
macro('vd', {
id: 'hSleevecap',
from: points.bicepsRight,
to: points.sleeveTip,
x: points.bicepsRight.x + 30 + sa * options.ffsa,
})
macro('hd', {
id: 'wCuff',
from: points.wristLeft,
to: points.wristRight,
y: points.wristLeft.y + 15 + sa,
})
if (pleats > 0)
macro('hd', {
id: 'wPleat',
from: points.cuffMidTop,
to: points.cuffPleat1EdgeTop,
y: points.cuffMidTop.y - 15,
2019-08-03 15:03:33 +02:00
})
2023-09-18 18:40:19 +02:00
if (pleats === 2)
2019-08-03 15:03:33 +02:00
macro('hd', {
2023-09-18 18:40:19 +02:00
id: 'wPleat2',
from: points.cuffPleat2Top,
to: points.cuffPleat2EdgeTop,
y: points.cuffPleat2Top.y - 15,
2019-08-03 15:03:33 +02:00
})
2018-12-23 17:25:53 +01:00
2019-08-03 15:03:33 +02:00
return part
}
2022-09-04 15:55:34 +02:00
export const sleeve = {
name: 'simon.sleeve',
from: brianSleeve,
2022-09-14 15:02:39 +02:00
after: front,
hide: hidePresets.HIDE_TREE,
2022-09-04 15:55:34 +02:00
options: {
cuffOverlap,
cuffDrape,
cuffEase,
cuffLength,
cuffStyle,
sleeveLengthBonus,
sleevePlacketLength,
},
draft: simonSleeve,
}