fix(charlie): Curved waistband title rotation as other parts
This commit is contained in:
parent
cd4709ee3b
commit
60cd1e294e
1 changed files with 279 additions and 267 deletions
|
@ -18,37 +18,44 @@ export default (part) => {
|
|||
} = part.shorthand()
|
||||
|
||||
if (options.waistbandCurve == 0) {
|
||||
return part;
|
||||
return part
|
||||
}
|
||||
|
||||
const fullWaist = 2 * (store.get('waistbandBack') + store.get('waistbandFront'));
|
||||
const sideSeamFraction = 0.5 * store.get('waistbandFront') / (store.get('waistbandBack') + store.get('waistbandFront'))
|
||||
const radius = fullWaist / (2 * Math.PI * options.waistbandCurve);
|
||||
const angle = 360 * options.waistbandCurve;
|
||||
const fullWaist = 2 * (store.get('waistbandBack') + store.get('waistbandFront'))
|
||||
const sideSeamFraction =
|
||||
(0.5 * store.get('waistbandFront')) / (store.get('waistbandBack') + store.get('waistbandFront'))
|
||||
const radius = fullWaist / (2 * Math.PI * options.waistbandCurve)
|
||||
const angle = 360 * options.waistbandCurve
|
||||
|
||||
points.center = new Point(0, 0);
|
||||
points.center = new Point(0, 0)
|
||||
|
||||
points.cfLeftBottom = points.center.shift(0, radius);
|
||||
points.cbBottom = points.cfLeftBottom.rotate(0.5 * angle, points.center);
|
||||
points.cfRightBottom = points.cfLeftBottom.rotate(angle, points.center);
|
||||
points.cfLeftBottom = points.center.shift(0, radius)
|
||||
points.cbBottom = points.cfLeftBottom.rotate(0.5 * angle, points.center)
|
||||
points.cfRightBottom = points.cfLeftBottom.rotate(angle, points.center)
|
||||
|
||||
points.cfLeftTop = points.cfLeftBottom.shiftTowards(points.center, options.waistbandWidth);
|
||||
points.cbTop = points.cfLeftTop.rotate(0.5 * angle, points.center);
|
||||
points.cfRightTop = points.cfRightBottom.shiftTowards(points.center, options.waistbandWidth);
|
||||
points.cfLeftTop = points.cfLeftBottom.shiftTowards(points.center, options.waistbandWidth)
|
||||
points.cbTop = points.cfLeftTop.rotate(0.5 * angle, points.center)
|
||||
points.cfRightTop = points.cfRightBottom.shiftTowards(points.center, options.waistbandWidth)
|
||||
|
||||
// Calculate control points for circle arc
|
||||
// https://math.stackexchange.com/questions/873224/calculate-control-points-of-cubic-bezier-curve-approximating-a-part-of-a-circle
|
||||
const a = (4 / 3) * Math.tan(2 * Math.PI * options.waistbandCurve / 4);
|
||||
const a = (4 / 3) * Math.tan((2 * Math.PI * options.waistbandCurve) / 4)
|
||||
|
||||
points.cfLeftBottomCp = points.cfLeftBottom.shift(90, a * radius);
|
||||
points.cfRightBottomCp = points.cfRightBottom.shift(angle - 90, a * radius);
|
||||
points.cfLeftBottomCp = points.cfLeftBottom.shift(90, a * radius)
|
||||
points.cfRightBottomCp = points.cfRightBottom.shift(angle - 90, a * radius)
|
||||
|
||||
points.cfLeftTopCp = points.cfLeftTop.shift(90, a * (radius - options.waistbandWidth))
|
||||
points.cfRightTopCp = points.cfRightTop.shift(angle - 90, a * (radius - options.waistbandWidth))
|
||||
|
||||
// Add fly underlap
|
||||
points.edgeRightTop = points.cfRightTop.shiftTowards(points.cfRightTopCp, - store.get('waistbandFly'))
|
||||
points.edgeRightBottom = points.cfRightBottom.shiftTowards(points.cfRightBottomCp, - store.get('waistbandFly'))
|
||||
points.edgeRightTop = points.cfRightTop.shiftTowards(
|
||||
points.cfRightTopCp,
|
||||
-store.get('waistbandFly')
|
||||
)
|
||||
points.edgeRightBottom = points.cfRightBottom.shiftTowards(
|
||||
points.cfRightBottomCp,
|
||||
-store.get('waistbandFly')
|
||||
)
|
||||
|
||||
paths.waistbandTop = new Path()
|
||||
.move(points.cfRightTop)
|
||||
|
@ -59,12 +66,11 @@ export default (part) => {
|
|||
.move(points.cfRightBottom)
|
||||
.curve(points.cfRightBottomCp, points.cfLeftBottomCp, points.cfLeftBottom)
|
||||
|
||||
points.ssRightBottom = paths.waistbandBottom.shiftFractionAlong(sideSeamFraction);
|
||||
points.ssLeftBottom = paths.waistbandBottom.shiftFractionAlong(1 - sideSeamFraction);
|
||||
|
||||
points.ssRightTop = paths.waistbandTop.shiftFractionAlong(sideSeamFraction);
|
||||
points.ssLeftTop = paths.waistbandTop.shiftFractionAlong(1 - sideSeamFraction);
|
||||
points.ssRightBottom = paths.waistbandBottom.shiftFractionAlong(sideSeamFraction)
|
||||
points.ssLeftBottom = paths.waistbandBottom.shiftFractionAlong(1 - sideSeamFraction)
|
||||
|
||||
points.ssRightTop = paths.waistbandTop.shiftFractionAlong(sideSeamFraction)
|
||||
points.ssLeftTop = paths.waistbandTop.shiftFractionAlong(1 - sideSeamFraction)
|
||||
|
||||
paths.saBase = new Path()
|
||||
.move(points.cfLeftBottom)
|
||||
|
@ -79,20 +85,27 @@ export default (part) => {
|
|||
paths.seam = paths.saBase.clone().attr('class', 'fabric').setRender(true)
|
||||
|
||||
if (complete) {
|
||||
raise.info(
|
||||
`Top of waistband: ${units(paths.waistbandTop.length())}`
|
||||
)
|
||||
raise.info(`Top of waistband: ${units(paths.waistbandTop.length())}`)
|
||||
macro('sprinkle', {
|
||||
snippet: 'notch',
|
||||
on: ['cfRightBottom', 'cfRightTop', 'cbBottom', 'cbTop', 'ssLeftBottom', 'ssRightBottom', 'ssLeftTop', 'ssRightTop']
|
||||
on: [
|
||||
'cfRightBottom',
|
||||
'cfRightTop',
|
||||
'cbBottom',
|
||||
'cbTop',
|
||||
'ssLeftBottom',
|
||||
'ssRightBottom',
|
||||
'ssLeftTop',
|
||||
'ssRightTop'
|
||||
]
|
||||
})
|
||||
|
||||
points.titleAnchor = points.cfLeftBottom.shiftFractionTowards(points.ssLeftTop, 0.4)
|
||||
points.titleAnchor = points.cfLeftTop.shiftFractionTowards(points.ssLeftBottom, 0.5)
|
||||
macro('title', {
|
||||
at: points.titleAnchor,
|
||||
nr: 11,
|
||||
title: 'waistband',
|
||||
rotation: -90
|
||||
rotation: 90
|
||||
})
|
||||
|
||||
macro('grainline', {
|
||||
|
@ -122,16 +135,16 @@ export default (part) => {
|
|||
let buttonScale = options.waistbandWidth / 14
|
||||
points.button = points.edgeRightBottom.shiftFractionTowards(points.cfRightTop, 0.6)
|
||||
snippets.button = new Snippet('button', points.button).attr('data-scale', buttonScale)
|
||||
points.buttonhole = new Point(points.cfLeftTop.x + 0.4 * options.waistbandWidth, points.cfLeftTop.y - store.get('waistbandFly') * 0.4)
|
||||
points.buttonhole = new Point(
|
||||
points.cfLeftTop.x + 0.4 * options.waistbandWidth,
|
||||
points.cfLeftTop.y - store.get('waistbandFly') * 0.4
|
||||
)
|
||||
snippets.buttonhole = new Snippet('buttonhole-start', points.buttonhole).attr(
|
||||
'data-scale',
|
||||
buttonScale
|
||||
)
|
||||
if (sa) {
|
||||
paths.sa = paths.saBase
|
||||
.offset(sa)
|
||||
.close()
|
||||
.attr('class', 'fabric sa')
|
||||
paths.sa = paths.saBase.offset(sa).close().attr('class', 'fabric sa')
|
||||
}
|
||||
|
||||
if (paperless) {
|
||||
|
@ -263,7 +276,6 @@ export default (part) => {
|
|||
to: points.cfLeftTop,
|
||||
x: points.ssLeftTop.x - sa - 15
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue