1
0
Fork 0
freesewing/packages/aaron/src/front.js

166 lines
4.6 KiB
JavaScript
Raw Normal View History

2019-08-03 15:03:33 +02:00
import { dimensions } from './shared'
2018-08-11 16:42:35 +02:00
2018-12-19 09:17:42 +01:00
export default function(part) {
let {
utils,
store,
sa,
Point,
points,
Path,
paths,
Snippet,
snippets,
options,
measurements,
complete,
paperless,
macro
2019-08-03 15:03:33 +02:00
} = part.shorthand()
2018-08-11 16:42:35 +02:00
2018-12-19 09:17:42 +01:00
// Hide Brian paths
2019-08-03 15:03:33 +02:00
for (let key of Object.keys(paths)) paths[key].render = false
2018-08-11 16:42:35 +02:00
2018-12-19 09:17:42 +01:00
// Handle stretch
2019-08-03 15:03:33 +02:00
for (let i in points) points[i].x = points[i].x * (1 - options.stretchFactor)
2018-08-11 16:42:35 +02:00
2018-12-19 09:17:42 +01:00
// Rename cb (center back) to cf (center front)
2019-08-03 15:03:33 +02:00
for (let key of ['Neck', 'Shoulder', 'Armhole', 'Waist', 'Hips', 'Hem']) {
points[`cf${key}`] = new Point(points[`cb${key}`].x, points[`cb${key}`].y)
2018-12-19 09:17:42 +01:00
//delete points[`cb${key}`];
}
2018-08-11 16:42:35 +02:00
2018-12-19 09:17:42 +01:00
// Neckline
points.cfNeck = points.cfNeck.shift(
-90,
2019-08-03 15:03:33 +02:00
options.necklineDrop * (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip)
)
2018-08-11 16:42:35 +02:00
2018-12-19 09:17:42 +01:00
// Strap
points.strapCenter = points.neck.shiftFractionTowards(
points.shoulder,
options.shoulderStrapPlacement
2019-08-03 15:03:33 +02:00
)
points.strapLeft = points.strapCenter.shiftTowards(
points.neck,
points.neck.dist(points.shoulder) * options.shoulderStrapWidth
2019-08-03 15:03:33 +02:00
)
points.strapRight = points.strapLeft.rotate(180, points.strapCenter)
2018-12-19 09:17:42 +01:00
points.necklineCorner = utils.beamsIntersect(
points.strapLeft,
points.strapRight.rotate(-90, points.strapLeft),
points.cfNeck.shift(0, points.armholePitch.x / 4),
points.cfNeck
2019-08-03 15:03:33 +02:00
)
points.strapLeftCp2 = points.strapLeft.shiftFractionTowards(
points.necklineCorner,
options.necklineBend
2019-08-03 15:03:33 +02:00
)
points.cfNeckCp1 = points.cfNeck.shiftFractionTowards(points.necklineCorner, options.necklineBend)
2018-12-19 09:17:42 +01:00
// Hips
points.hips.x =
2019-08-03 15:03:33 +02:00
((measurements.hipsCircumference + options.hipsEase * measurements.hipsCircumference) / 4) *
(1 - options.stretchFactor)
points.waist.x = points.hips.x // Because stretch
points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 2)
2018-08-11 16:42:35 +02:00
// Hem
2019-08-03 15:03:33 +02:00
points.hem.x = points.hips.x
2018-12-19 09:17:42 +01:00
// Armhole drop
let side = new Path()
.move(points.hem)
2018-12-19 09:17:42 +01:00
.line(points.waist)
2019-08-03 15:03:33 +02:00
.curve(points.waistCp2, points.armhole, points.armhole)
let split = side.intersectsY(points.armhole.y * (1 + options.armholeDrop)).pop()
paths.side = side.split(split)[0]
paths.side.render = false
points.aaronArmhole = split
2018-12-19 09:17:42 +01:00
// Armhole
points.armholeCorner = utils.beamsIntersect(
points.aaronArmhole,
points.aaronArmhole.shift(180, 10),
2018-12-19 09:17:42 +01:00
points.strapRight,
points.strapLeft.rotate(90, points.strapRight)
2019-08-03 15:03:33 +02:00
)
points.armholeCp2 = points.aaronArmhole.shiftFractionTowards(points.armholeCorner, 0.8)
points.strapRightCp1 = points.strapRight.shiftFractionTowards(points.armholeCorner, 0.6)
2018-12-19 09:17:42 +01:00
// Seamline
paths.seam = new Path()
.move(points.cfNeck)
.line(points.cfHem)
.line(points.hem)
2018-12-19 09:17:42 +01:00
.line(points.waist)
.join(paths.side)
.curve(points.armholeCp2, points.strapRightCp1, points.strapRight)
.line(points.strapLeft)
.curve(points.strapLeftCp2, points.cfNeckCp1, points.cfNeck)
.close()
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric')
2018-12-19 09:17:42 +01:00
// Store length of armhole and neck opening
store.set(
2019-08-03 15:03:33 +02:00
'frontArmholeLength',
2018-12-19 09:17:42 +01:00
new Path()
.move(points.aaronArmhole)
.curve(points.armholeCp2, points.strapRightCp1, points.strapRight)
.length()
2019-08-03 15:03:33 +02:00
)
2018-12-19 09:17:42 +01:00
store.set(
2019-08-03 15:03:33 +02:00
'frontNeckOpeningLength',
2018-12-19 09:17:42 +01:00
new Path()
.move(points.strapLeft)
.curve(points.cfNeckCp1, points.cfNeckCp1, points.cfNeck)
.length()
2019-08-03 15:03:33 +02:00
)
2018-12-19 09:17:42 +01:00
// Complete pattern?
if (complete) {
2019-08-03 15:03:33 +02:00
macro('cutonfold', {
2018-12-19 09:17:42 +01:00
from: points.cfNeck,
to: points.cfHem,
2018-12-19 09:17:42 +01:00
grainline: true
2019-08-03 15:03:33 +02:00
})
points.title = new Point(points.waist.x / 2, points.waist.y)
macro('title', { at: points.title, nr: 1, title: 'front' })
points.logo = points.title.shift(-90, 75)
snippets.logo = new Snippet('logo', points.logo)
2018-08-11 16:42:35 +02:00
2018-12-19 09:17:42 +01:00
if (sa) {
paths.saShoulder = new Path()
.move(points.strapRight)
.line(points.strapLeft)
.offset(sa)
.line(points.strapLeft)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric sa')
paths.saShoulder.move(points.strapRight).line(paths.saShoulder.start())
2018-12-19 09:17:42 +01:00
paths.saSide = paths.side
.offset(sa)
.line(points.aaronArmhole)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric sa')
2018-12-19 09:17:42 +01:00
paths.saHem = new Path()
.move(points.cfHem)
.line(points.hem)
.offset(sa * 2.5)
2019-08-03 15:03:33 +02:00
.attr('class', 'fabric sa')
.line(paths.saSide.start())
paths.saHem.move(points.cfHem).line(paths.saHem.start())
2018-08-11 16:42:35 +02:00
}
2018-12-19 09:17:42 +01:00
}
2018-12-19 09:17:42 +01:00
// Paperless?
if (paperless) {
2019-08-03 15:03:33 +02:00
dimensions(macro, points, sa)
macro('vd', {
from: points.cfHem,
2018-12-19 09:17:42 +01:00
to: points.cfNeck,
x: points.cfHem.x - sa - 15
2019-08-03 15:03:33 +02:00
})
2018-08-11 16:42:35 +02:00
}
2019-08-03 15:03:33 +02:00
return part
}