import { constructMainDart, shapeSideSeam } from "./shared"; export default part => { let { points, Point, paths, Path, measurements, options, utils, macro, snippets, Snippet, complete, sa, paperless } = part.shorthand(); // Cleanup from Brian for (let i of Object.keys(paths)) delete paths[i]; delete snippets.armholePitchNotch; // Neck cutout points.closureTop = new Point( measurements.chestCircumference * options.frontOverlap * -1, points.armhole.y * options.necklineDrop ); if (options.frontStyle === "classic") points.closureTopCp1 = new Point( points.neck.x, (points.armhole.y * options.necklineDrop) / 2 ); else points.closureTopCp1 = new Point(points.neck.x, points.p300.y); // Front inset let shoulderLen = points.shoulder.dist(points.neck); let frontInset = shoulderLen * options.frontInset; points.armholePitch = points.armholePitch.shift(180, frontInset); points.armholePitchCp1 = points.armholePitchCp1.shift(180, frontInset); points.armholePitchCp2 = points.armholePitchCp2.shift(180, frontInset); points.armholeHollow = points.armholeHollow.shift(180, frontInset / 2); points.armholeHollowCp2 = points.armholeHollowCp2.shift(180, frontInset / 2); points.armholeHollowCp1 = points.armholeHollowCp1.shift(180, frontInset / 2); // Shoulder inset points.shoulder = points.shoulder.shiftTowards( points.neck, shoulderLen * options.shoulderInset ); points.shoulderCp1 = points.shoulderCp1.shift( points.shoulder.angle(points.neck), shoulderLen * options.shoulderInset ); // Neck inset points.neck = points.neck.shiftTowards( points.shoulder, shoulderLen * options.neckInset ); points.neckCp2 = points.neck.shift( points.shoulder.angle(points.neck) + 90, shoulderLen * 0.2 ); // Construct main dart constructMainDart(part); // Shape side seam shapeSideSeam(part); // Hem if (options.hemStyle === "classic") { // Construct cutaway let cutaway = points.closureTop.dx(points.hem) / 4; points.closureBottom = new Point( points.closureTop.x, points.hem.y - cutaway / 2 ); points.hemTip = new Point( points.closureBottom.x + cutaway, points.closureBottom.y + cutaway ); // Shifting hem point to have a continious hem curve to work from let shift = points.dartHemLeft.dx(points.dartHemRight); points.splitHem = points.hem.shift(180, shift); // Split hem curve on left side of dart points.hemSplit = utils.curveIntersectsX( points.hemTip, points.hemTip, points.dartHemLeft, points.splitHem, points.dartHemLeft.x ); // Split the hem curve let [c1, c2] = utils.splitCurve( points.hemTip, points.hemTip, points.dartHemLeft, points.splitHem, points.hemSplit ); points.splitDartHemLeftCp1 = c1.cp2; points.splitDartHemRightCp2 = c2.cp1.shift(0, shift); points.splitHemCp1 = c2.cp2.shift(0, shift); points.splitDartHemLeft = utils.curveIntersectsX( points.hemTip, points.hemTip, points.dartHemLeft, points.splitHem, points.dartHemLeft.x ); points.splitDartHemRight = points.splitDartHemLeft.shift(0, shift); points.lastButton = new Point(0, points.closureBottom.y); } else { points.closureBottom = new Point(points.closureTop.x, points.hem.y); // Draw rounded hem let radius = measurements.hipsCircumference * options.hemRadius; // Avoid radius extending beyond the dart if (radius > points.closureTop.dx(points.dartHemLeft)) radius = points.closureTop.dx(points.dartHemLeft); macro("round", { from: points.closureTop, to: points.hem, via: points.closureBottom, radius, prefix: "round" }); points.lastButton = new Point(0, points.roundStart.y); } // Pockets let pw = measurements.hipsCircumference * options.pocketWidth; // Pocket width let pwh = pw * options.weltHeight; // Pocket welt height let pwvh = pwh / Math.cos(utils.deg2rad(options.pocketAngle)); // Pocket welt vertical height let pbh = pw * 1.3; // Pocket bag height points.pocketTopMid = points.dartWaistCenter.shiftFractionTowards( points.dartHipCenter, options.pocketLocation ); points.pocketTopMidLeft = utils.curveIntersectsY( points.dartWaistLeft, points.dartWaistLeftCpBottom, points.dartHipLeftCpTop, points.dartHipLeft, points.pocketTopMid.y ); points.pocketBottomMidLeft = utils.curveIntersectsY( points.dartWaistLeft, points.dartWaistLeftCpBottom, points.dartHipLeftCpTop, points.dartHipLeft, points.pocketTopMid.y + pwvh ); points.pocketTopLeft = points.pocketTopMidLeft.shift( 180 + options.pocketAngle, pw / 2 ); points.pocketBottomLeft = points.pocketTopLeft.shift( options.pocketAngle - 90, pwh ); points.pocketTopMidRight = points.pocketTopMidLeft.flipX(points.pocketTopMid); points.pocketBottomMidRight = points.pocketBottomMidLeft.flipX( points.pocketTopMid ); points.pocketTopRight = points.pocketTopMidRight.shift( options.pocketAngle, pw / 2 ); points.pocketBottomRight = points.pocketTopRight.shift( options.pocketAngle - 90, pwh ); // Front scye dart points._dartWidth = points.dartTop.shiftFractionTowards( points.armholeHollow.rotate(options.frontScyeDart, points.dartTop), 1.5 ); points.armholeHollowTop = new Path() .move(points.armholeHollow) .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .intersects(new Path().move(points.dartTop).line(points._dartWidth)) .pop(); // Adjust control point points.armholeHollowCp2 = points.armholeHollowCp2.shift( points.armholeHollow.angle(points.armholeHollowTop), points.armholeHollow.dist(points.armholeHollowTop) ); // Rotate front scye dart into front dart let toRotate = [ "dartWaistRightCpTop", "dartWaistRight", "dartWaistRightCpBottom", "dartHipRightCpTop", "dartHipRight", "dartHemRight", "splitDartHemRight", "splitDartHemRightCp2", "splitHemCp1", "hem", "hips", "hipsCp2", "waistCp1", "waist", "waistCp2", "armhole", "armholeCp2", "armholeHollow", "pocketTopMidRight", "pocketBottomMidRight", "pocketTopRight", "pocketBottomRight" ]; for (let p of toRotate) { if (typeof points[p] !== "undefined") points[p] = points[p].rotate(options.frontScyeDart, points.dartTop); } points.armholeHollowCp1 = points.armholeHollowCp2.rotate( 180, points.armholeHollow ); // Seam line delete paths.cutonfold; delete paths.saBase; delete paths.sa; if (options.hemStyle === "classic") { paths.saBase = new Path() .move(points.splitDartHemRight) .curve(points.splitDartHemRightCp2, points.splitHemCp1, points.hem); } else { paths.saBase = new Path().move(points.dartHemRight).line(points.hem); } paths.saBase .line(points.hips) .curve(points.hipsCp2, points.waistCp1, points.waist) .curve_(points.waistCp2, points.armhole) .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) .line(points.neck) .curve(points.neckCp2, points.closureTopCp1, points.closureTop); if (options.hemStyle === "classic") { paths.saBase .line(points.closureBottom) .line(points.hemTip) ._curve(points.splitDartHemLeftCp1, points.splitDartHemLeft); } else { paths.saBase .line(points.roundStart) .curve(points.roundCp1, points.roundCp2, points.roundEnd) .line(points.dartHemLeft); } paths.dart = new Path() .move(paths.saBase.end()) .line(points.dartHipLeft) .curve( points.dartHipLeftCpTop, points.dartWaistLeftCpBottom, points.dartWaistLeft ) .curve_(points.dartWaistLeftCpTop, points.dartTop) ._curve(points.dartWaistRightCpTop, points.dartWaistRight) .curve( points.dartWaistRightCpBottom, points.dartHipRightCpTop, points.dartHipRight ) .line(paths.saBase.start()); paths.seam = paths.saBase.join(paths.dart).attr("class", "fabric"); paths.saBase.render = false; paths.dart.render = false; if (complete) { // Buttons points.button1 = new Point(0, points.closureTop.y); let delta = points.button1.dist(points.lastButton) / (options.buttons - 1); for (let i = 1; i <= options.buttons; i++) { points["button" + i] = points.button1.shift(-90, delta * (i - 1)); if (complete) { snippets["button" + i] = new Snippet("button", points["button" + i]); snippets["buttonhole" + i] = new Snippet( "buttonhole", points["button" + i] ).attr("data-rotate", 90); } } // Facing/Lining boundary (flb) points.flbTop = points.neck.shiftFractionTowards(points.shoulder, 0.5); points.flbCp = points.dartTop.shift( 90, points.dartTop.dist(points.flbTop) / 2 ); paths.flbFacing = new Path() .move(points.dartTop) .curve_(points.flbCp, points.flbTop) .attr("class", "fabric"); paths.flbLining = paths.flbFacing.clone().attr("class", "lining dashed"); // Pocket path paths.pocket = new Path() .move(points.pocketTopMidLeft) .line(points.pocketTopLeft) .line(points.pocketBottomLeft) .line(points.pocketBottomMidLeft) .move(points.pocketBottomMidRight) .line(points.pocketBottomRight) .line(points.pocketTopRight) .line(points.pocketTopMidRight) .attr("class", "fabric dashed"); if (sa) paths.sa = paths.saBase.offset(sa).close(); if (paperless) { macro("hd", { from: points.closureTop, to: points.neck, y: points.neck.y - 15 - sa }); macro("hd", { from: points.closureTop, to: points.shoulder, y: points.neck.y - 30 - sa }); macro("hd", { from: points.closureTop, to: points.armhole, y: points.neck.y - 45 - sa }); macro("ld", { from: points.neck, to: points.shoulder, d: 15 + sa }); macro("ld", { from: points.neck, to: points.flbTop, d: -15 }); macro("vd", { from: points.armhole, to: points.shoulder, x: points.armhole.x + 15 + sa }); macro("vd", { from: points.armhole, to: points.neck, x: points.armhole.x + 30 + sa }); macro("vd", { from: points.hem, to: points.armhole, x: (points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) + 15 + sa }); macro("vd", { from: options.hemStyle === "classic" ? points.splitDartHemRight : points.dartHemRight, to: points.armhole, x: (points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) + 30 + sa }); macro("vd", { from: options.hemStyle === "classic" ? points.splitDartHemLeft : points.dartHemLeft, to: points.armhole, x: (points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) + 45 + sa }); macro("ld", { from: points.dartHemRight, to: points.hem, d: 15 }); if (options.hemStyle === "classic") { macro("hd", { from: points.closureBottom, to: points.hemTip, y: points.hemTip.y + 15 + sa }); macro("hd", { from: points.closureBottom, to: points.splitDartHemLeft, y: points.hemTip.y + 30 + sa }); macro("hd", { from: points.closureBottom, to: points.splitDartHemRight, y: points.hemTip.y + 45 + sa }); macro("hd", { from: points.closureBottom, to: points.hem, y: points.hemTip.y + 60 + sa }); macro("vd", { from: points.hemTip, to: points.closureBottom, x: points.closureBottom.x - 15 - sa }); macro("vd", { from: points.hemTip, to: points.pocketTopMidLeft, x: points.closureBottom.x - 30 - sa }); macro("vd", { from: points.hemTip, to: points.dartWaistLeft, x: points.closureBottom.x - 45 - sa }); macro("vd", { from: points.hemTip, to: points.closureTop, x: points.closureBottom.x - 60 - sa }); } else { macro("hd", { from: points.roundStart, to: points.roundEnd, y: points.roundEnd.y + 15 + sa }); macro("hd", { from: points.roundStart, to: points.dartHemLeft, y: points.roundEnd.y + 30 + sa }); macro("hd", { from: points.roundStart, to: points.dartHemRight, y: points.roundEnd.y + 45 + sa }); macro("hd", { from: points.roundStart, to: points.hem, y: points.roundEnd.y + 60 + sa }); macro("vd", { from: points.roundEnd, to: points.roundStart, x: points.roundStart.x - 15 - sa }); macro("vd", { from: points.roundEnd, to: points.pocketTopMidLeft, x: points.roundStart.x - 30 - sa }); macro("vd", { from: points.roundEnd, to: points.dartWaistLeft, x: points.roundStart.x - 45 - sa }); macro("vd", { from: points.roundEnd, to: points.closureTop, x: points.roundStart.x - 60 - sa }); } macro("vd", { from: points.closureTop, to: points.neck, x: points.closureTop.x - 15 - sa }); macro("vd", { from: points.button2, to: points.button1, x: points.button1.x + 15 }); macro("hd", { from: points.closureTop, to: points.button2, y: points.button2.y + 15 }); macro("ld", { from: points.dartWaistLeft, to: points.dartWaistRight }); macro("ld", { from: points.dartHipLeft, to: points.dartHipRight }); macro("ld", { from: points.pocketTopLeft, to: points.pocketTopMidLeft, d: 15 }); macro("ld", { from: points.pocketTopMidRight, to: points.pocketTopRight, d: 15 }); macro("ld", { from: points.pocketBottomRight, to: points.pocketTopRight, d: -15 }); macro("vd", { from: points.pocketTopMidLeft, to: points.dartTop, x: points.closureTop.x - 30 - sa }); } } return part; };