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

180 lines
4.7 KiB
JavaScript
Raw Normal View History

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
} = part.shorthand();
2018-08-11 16:42:35 +02:00
2018-12-19 09:17:42 +01:00
// Hide Brian paths
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
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)
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,
options.necklineDrop *
(measurements.centerBackNeckToWaist + measurements.naturalWaistToHip)
2018-12-19 09:17:42 +01:00
);
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
);
points.strapLeft = points.strapCenter.shiftTowards(
points.neck,
points.neck.dist(points.shoulder) * options.shoulderStrapWidth
);
2018-12-19 09:17:42 +01:00
points.strapRight = points.strapLeft.rotate(180, points.strapCenter);
points.necklineCorner = utils.beamsIntersect(
points.strapLeft,
points.strapRight.rotate(-90, points.strapLeft),
points.cfNeck.shift(0, points.armholePitch.x / 4),
points.cfNeck
);
points.strapLeftCp2 = points.strapLeft.shiftFractionTowards(
points.necklineCorner,
options.necklineBend
);
points.cfNeckCp1 = points.cfNeck.shiftFractionTowards(
points.necklineCorner,
options.necklineBend
2018-12-19 09:17:42 +01:00
);
2018-12-19 09:17:42 +01:00
// Hips
points.hips.x =
((measurements.hipsCircumference +
options.hipsEase * measurements.hipsCircumference) /
4) *
(1 - options.stretchFactor);
2018-12-19 09:17:42 +01:00
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
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)
.curve(points.waistCp2, points.armhole, points.armhole);
let split = side
.intersectsY(points.armhole.y * (1 + options.armholeDrop))
.pop();
2018-12-19 09:17:42 +01:00
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)
);
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()
.attr("class", "fabric");
2018-12-19 09:17:42 +01:00
// Store length of armhole and neck opening
store.set(
"frontArmholeLength",
2018-12-19 09:17:42 +01:00
new Path()
.move(points.aaronArmhole)
.curve(points.armholeCp2, points.strapRightCp1, points.strapRight)
.length()
);
store.set(
"frontNeckOpeningLength",
2018-12-19 09:17:42 +01:00
new Path()
.move(points.strapLeft)
.curve(points.cfNeckCp1, points.cfNeckCp1, points.cfNeck)
.length()
);
// Complete pattern?
if (complete) {
macro("cutonfold", {
from: points.cfNeck,
to: points.cfHem,
2018-12-19 09:17:42 +01:00
grainline: true
});
points.title = new Point(points.waist.x / 2, points.waist.y);
2018-12-19 09:17:42 +01:00
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)
.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)
.attr("class", "fabric sa");
paths.saHem = new Path()
.move(points.cfHem)
.line(points.hem)
.offset(sa * 2.5)
.attr("class", "fabric sa")
2018-12-19 09:17:42 +01:00
.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) {
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
2018-12-19 09:17:42 +01:00
});
2018-08-11 16:42:35 +02:00
}
2018-12-19 09:17:42 +01:00
return part;
}