def pattern(self): """ Method defining a pattern design. This is where the designer places all elements of the design definition """ CM = CM_TO_PX IN = IN_TO_PX cd = self.cd # client data is prefaced with cd. self.cfg["clientdata"] = cd printer = '36" wide carriage plotter' if printer == '36" wide carriage plotter': self.cfg["paper_width"] = 36 * IN self.cfg["border"] = 5 * CM BORDER = self.cfg["border"] BORDER = self.cfg["border"] metainfo = { "companyName": "Seamly Patterns", # mandatory "designerName": "Susan Spencer", # mandatory "patternName": "pants Foundation", # mandatory "patternNumber": "WS010-xj1-1", # mandatory } self.cfg["metainfo"] = metainfo docattrs = {"currentscale": "0.5 : 1", "fitBoxtoViewport": "True", "preserveAspectRatio": "xMidYMid meet"} doc = Document(self.cfg, name="document", attributes=docattrs) TB = TitleBlock("notes", "titleblock", 0, 0, stylename="titleblock_text_style") doc.add(TB) TG = TestGrid("notes", "testgrid", self.cfg["paper_width"] / 3.0, 0, stylename="cuttingline_style") doc.add(TG) # All measurements are in pixels...CM=CM_TO_PX, IN=IN_TO_PX, etc. # Begin pants Pattern Set pants = Pattern("pants") doc.add(pants) pants.styledefs.update(self.styledefs) pants.markerdefs.update(self.markerdefs) # pants Front 'A' pants.add(PatternPiece("pattern", "front", letter="A", fabric=2, interfacing=0, lining=0)) A = pants.front ASTART = 0.0 AEND = FRONT_HIP_ARC + ((1 / 8.0) * IN) AStart = rPoint(A, "AStart", ASTART, ASTART) AEnd = rPoint(A, "AEnd", AEND, ASTART) AWaist = rPoint(A, "AWaist", ASTART, WAISTLINE) AHip = rPoint(A, "AHip", ASTART, HIPLINE) ARise = rPoint(A, "ARise", ASTART, RISELINE) Ap1 = rPoint(A, "Ap1", AEND, WAISTLINE) # right side of reference grid Ap5 = rPoint(A, "Ap5", AEND / 2.0, WAISTLINE) # dart midpoint Ap6 = rPoint(A, "Ap6", Ap5.x - (0.25 * IN), WAISTLINE) # dart outside leg (left on pattern) Ap7 = rPoint(A, "Ap7", Ap5.x + (0.25 * IN), WAISTLINE) # dart inside leg (right on pattern) Ap8 = rPoint(A, "Ap8", Ap5.x, Ap5.y + (2.5 * IN)) # dart point Ap2 = rPoint(A, "Ap2", Ap7.x + (FRONT_WAIST_ARC / 2.0), WAISTLINE) Ap3 = rPoint(A, "Ap3", Ap2.x, WAISTLINE - (0.25) * IN) # center waist Ap4 = rPoint(A, "Ap4", Ap6.x - (FRONT_WAIST_ARC / 2.0), WAISTLINE) # side waist Ap9 = rPoint(A, "Ap9", AEND, (RISELINE / 2.0)) # center front 'pivot' point from crotch curve to front fly Ap10 = rPoint(A, "Ap10", ASTART, HIPLINE) Ap11 = rPoint(A, "Ap11", AEND, HIPLINE) Ap12 = rPoint(A, "Ap12", ASTART, RISELINE) Ap13 = rPoint(A, "Ap13", AEND, RISELINE) Ap14 = rPointP( A, "Ap14", pntFromDistanceAndAngleP(Ap13, (1.25 * IN), angleFromSlope(1.0, 1.0)) ) # inside crotch curve point Ap15 = rPoint(A, "Ap15", Ap13.x + (2.0 * IN), RISELINE) # point of crotch Ap16 = rPoint(A, "Ap16", Ap15.x / 2.0, RISELINE) # creaseline point ACREASELINE = Ap16.x Ap17 = rPoint(A, "Ap17", Ap16.x, KNEELINE) Ap18 = rPoint(A, "Ap18", Ap16.x - (4.0 * IN), KNEELINE) # outside knee Ap19 = rPoint(A, "Ap19", Ap16.x + (4.0 * IN), KNEELINE) # inside knee Ap20 = rPoint(A, "Ap20", Ap16.x, HEMLINE) Ap21 = rPoint(A, "Ap21", Ap20.x - (3.5 * IN), HEMLINE) # outside hem Ap22 = rPoint(A, "Ap22", Ap20.x + (3.5 * IN), HEMLINE) # inside hem # front waist AW AW1 = rPointP(A, "AW1", Ap3) # front center seam at waist AW2 = rPointP(A, "AW2", pntIntersectLinesP(Ap3, Ap4, Ap8, Ap7)) # inside dart leg at waist # calculate dart DART_LEG_LENGTH = lineLengthP(Ap8, AW2) angle1 = angleFromSlopeP(Ap8, Ap5) # angle of center dart line angle2 = angleFromSlopeP(Ap8, Ap7) # angle of inside dart leg angle3 = angle1 - angle2 # half-angle of dart angle4 = angle1 + angle3 # angle of outside dart leg angle5 = angle1 + (2 * angle3) # angle of sewn dart fold, towards side seam AW4 = rPointP(A, "AW4", pntFromDistanceAndAngleP(Ap8, DART_LEG_LENGTH, angle4)) # outside dart leg at waist pnt1 = pntFromDistanceAndAngleP(Ap8, DART_LEG_LENGTH, angle5) # point along sewn dart fold pnt2 = pntIntersectLinesP(Ap8, pnt1, Ap4, AW4) # where sewn dart fold will cross waistline AW3 = rPointP(A, "AW3", pntOnLineP(Ap8, Ap5, lineLengthP(Ap8, pnt2))) # center dart line at waist AW5 = rPointP(A, "AW5", Ap4) # side waist # front waist control points distance = lineLengthP(AW4, AW5) / 3.0 cAW5b = cPoint(A, "cAW5b", AW5.x + distance, AW5.y) cAW5a = cPointP(A, "cAW5a", pntOnLineP(AW4, cAW5b, distance)) # front dart AD AD1 = rPointP(A, "AD1", Ap8) # point of dart AD2 = rPointP(A, "AD2", pntOffLineP(AW3, Ap8, (5 / 8 * IN))) # center dart line at cuttingline AD3 = rPointP( A, "AD3", pntIntersectLines(AW4.x, AW4.y - (5 / 8.0) * IN, AW5.x, AW5.y - (5 / 8.0) * IN, Ap8.x, Ap8.y, AW4.x, AW4.y), ) # outside dart leg AD4 = rPointP( A, "AD4", pntIntersectLines(AW1.x, AW1.y - (5 / 8.0) * IN, AW2.x, AW2.y - (5 / 8.0) * IN, Ap8.x, Ap8.y, AW2.x, AW2.y), ) # inside dart leg # front side seam AS AS1 = rPointP(A, "AS1", Ap10) AS2 = rPointP(A, "AS2", Ap12) AS3 = rPointP(A, "AS3", Ap18) AS4 = rPointP(A, "AS4", Ap21) # front side seam control points # if (FRONTNORMALTHIGH): if FRONT_NORMAL_WAIST: cAS3b = cPointP(A, "cAS3b", pntOffLineP(AS3, AS4, (lineLengthP(AS3, AS1) / 2.0))) # b/w AS1 & AS3 pnts = pointList(AW5, AS1, AS3) c1, c2 = myGetControlPoints("FrontSideSeam", pnts) cAS1a = cPoint(A, "cAS1a", c1[0].x, c1[0].y) # b/w AW5 & AS2 cAS1b = cPoint(A, "cAS1b", AS1.x, c2[0].y) # b/w AW5 & AS1 cAS3a = cPoint(A, "cAS3a", AS1.x, c1[1].y) # b/w AS1 & AW5 else: cAS2a = cPoint( A, "cAS2a", min(AS2.x, AW5.x), AW5.y + (lineLengthP(AW5, AS2) / 3.0) ) # waistline slightly less than hipline (ex: 1.25") use AS2 else AW5 cAS3b = cPointP(A, "cAS3b", pntOffLineP(AS3, AS4, (lineLengthP(AS2, AS3) / 3.0))) # b/w AS2 & AS3 pnts = pointList(cAS2a, AS2, cAS3b) c1, c2 = myGetControlPoints("BackSideSeam", pnts) cAS2b = cPoint(A, "cAS2b", c2[0].x, c2[0].y) # b/w AW5 & AS2 cAS3a = cPoint(A, "cAS3a", c1[1].x, c1[1].y) # b/w AS2 & AS3 # front inseam AI AI1 = rPointP(A, "AI1", Ap22) AI2 = rPointP(A, "AI2", Ap19) AI3 = rPointP(A, "AI3", Ap15) # front inseam control points cAI3a = cPointP(A, "cAI3a", pntOffLineP(AI2, AI1, (lineLengthP(AI2, AI3) / 2.0))) # b/w AI2 & AI3 cAI3b = cPointP(A, "cAI3b", pntOnLineP(AI3, cAI3a, (lineLengthP(AI2, AI3) / 3.0))) # b/w AI2 & AI3 # front center seam AC AC1 = rPointP(A, "AC1", Ap14) if AW1.x > Ap9.x: FRONTLARGERWAIST = 1 else: FRONTLARGERWAIST = 0 if FRONT_NORMAL_WAIST: AC2 = rPointP(A, "AC2", Ap9) # straight line for upper front center seam, control points for AC1 & AC2 only, with calculated control point cAC2b to smooth into straight line cAC2b = cPointP(A, "cAC2b", pntOffLine(AC2.x, AC2.y, AW1.x, AW1.y, (lineLengthP(AC1, AC2) / 2.0))) pnts = pointList(AI3, AC1, cAC2b) c1, c2 = myGetControlPoints("FrontCenterSeam", pnts) cAC1a = cPoint(A, "cAC1a", c1[0].x, c1[0].y) # b/w AI3 & AC1 cAC1b = cPoint(A, "cAC1b", c2[0].x, c2[0].y) # b/w AI3 & AC1 cAC2a = cPoint(A, "cAC2a", c1[1].x, c1[1].y) # b/w AC1 & AC2 else: if FRONTLARGERWAIST: # curve through AI3,AC2, straight to AW1 # move AC2 point towards center (x) AC2 = rPoint(A, "AC2", Ap9.x + (abs(AW1.x - Ap9.x) / 4.0), Ap9.y) cAC2b = cPointP(A, "cAC2b", pntIntersectLinesP(AC2, AW1, AS1, Ap11)) # intersection with Hipline else: # curve through AI3, AC2, then straight to AW1 AC2 = rPointP(A, "AC2", Ap9) cAC2b = cPointP(A, "cAC2b", pntOffLineP(AC2, AW1, (lineLengthP(AC2, AC1) / 3.0))) cAC2a = cPointP(A, "cAC2a", pntOnLineP(Ap14, Ap13, (lineLengthP(Ap14, Ap13) / 4.0))) # points to create pants Waistband pattern 'C' AWB1 = rPointP(A, "AWB1", pntOnLineP(AW1, AC2, WAISTBAND)) # waistband below center waist if FRONT_NORMAL_WAIST: pnt = pntOnLineP(AW5, cAS1a, WAISTBAND) else: pnt = pntOnLineP(AW5, cAS2a, WAISTBAND) AWB4 = rPointP(A, "AWB4", pnt) # waistband line 1in. below side waist AWB2 = rPointP(A, "AWB2", pntIntersectLinesP(AWB1, AWB4, Ap8, Ap7)) # waistband line at inside dart leg AWB3 = rPointP(A, "AWB3", pntIntersectLinesP(AWB1, AWB4, Ap8, Ap6)) # waistband line at outside dart leg # front grainline AG & label location AG1 = rPoint(A, "AG1", Ap16.x, HIPLINE) AG2 = rPoint(A, "AG2", Ap16.x, Ap18.y + abs(Ap21.y - Ap18.y) / 2.0) (A.label_x, A.label_y) = (AG2.x, AG2.y - (2.0 * IN)) # grid 'Agrid' path Agrid = path() # vertical Agrid addToPath( Agrid, "M", AStart, "L", ARise, "M", Ap5, "L", Ap8, "M", Ap16, "L", Ap20, "M", Ap3, "L", Ap2, "M", AEnd, "L", Ap13, ) # horizontal Agrid addToPath(Agrid, "M", AStart, "L", AEnd, "M", AWaist, "L", Ap1, "M", AHip, "L", Ap11) addToPath(Agrid, "M", ARise, "L", Ap15, "M", Ap18, "L", Ap19, "M", AWB1, "L", AWB2, "M", AWB3, "L", AWB4) # diagonal grid addToPath(Agrid, "M", Ap3, "L", Ap4, "M", Ap13, "L", Ap14) # dart 'd' path d = path() addToPath(d, "M", AD1, "L", AD2, "M", AD3, "L", AD1, "L", AD4) # seamline 's' & cuttingline 'c' paths s = path() c = path() paths = pointList(s, c) for p in paths: # - addToPath(p, 'M', AW1, 'L', AW2, 'L', AW3, 'L', AW4, 'C', cAW5a, cAW5b, AW5) --> waistband from waist to 1" below waist # - waistband from 1" below waist to 2" below waist addToPath(p, "M", AW1, "L", AW2, "L", AW3, "L", AW4, "C", cAW5a, cAW5b, AW5) # if (FRONTNORMALTHIGH): if FRONT_NORMAL_WAIST: addToPath(p, "C", cAS1a, cAS1b, AS1) else: addToPath(p, "C", cAS2a, cAS2b, AS2) # else: # addToPath(p, 'C', cAS1a, cAS1b, AS1, 'C', cAT1a, cAT1b, AT1) addToPath(p, "C", cAS3a, cAS3b, AS3, "L", AS4, "L", AI1, "L", AI2, "C", cAI3a, cAI3b, AI3) if FRONT_NORMAL_WAIST: cubicCurveP(p, cAC1a, cAC1b, AC1) addToPath(p, "C", cAC2a, cAC2b, AC2, "L", AW1) # add grainline, dart, seamline & cuttingline paths to pattern A.add(grainLinePath("grainLine", "pants Front Grainline", AG1, AG2)) A.add(Path("reference", "grid", "pants Front Gridline", Agrid, "gridline_style")) A.add(Path("pattern", "dartline", "pants Front Dartline", d, "dart_style")) A.add(Path("pattern", "seamLine", "pants Front Seamline", s, "seamline_path_style")) A.add(Path("pattern", "cuttingLine", "pants Front Cuttingline", c, "cuttingline_style")) # pants Back 'B' pants.add(PatternPiece("pattern", "back", letter="B", fabric=2, interfacing=0, lining=0)) B = pants.back BSTART = 0.0 BEND = BACK_HIP_ARC + 2 * SEAM_EASE BStart = rPoint(B, "BStart", BSTART, BSTART) BEnd = rPoint(B, "BEnd", BEND, BStart.y) BWaist = rPoint(B, "BWaist", BStart.x, WAISTLINE) BHip = rPoint(B, "BHip", BStart.x, HIPLINE + SEAM_EASE) BRise = rPoint(B, "BRise", BStart.x, RISELINE + 2 * SEAM_EASE) BRiseInside = rPoint(B, "BRiseInside", BRise.x - BACK_CROTCH_LENGTH, BRise.y) # crotch point BRiseOutside = rPoint(B, "BRiseOutside", BEnd.x, BRise.y) BCenterLeg = rPoint(B, "BCenterLeg", BRiseOutside.x - abs(BRiseOutside.x - BRiseInside.x) / 2.0, RISELINE) BKnee = rPoint(B, "BKnee", BCenterLeg.x, KNEELINE) BHem = rPoint(B, "BHem", BCenterLeg.x, HEMLINE) BKneeInside = rPoint(B, "BKneeInside", BKnee.x - BACK_KNEE_WIDTH / 2.0, KNEELINE) BKneeOutside = rPoint(B, "BKneeOutside", BKnee.x + BACK_KNEE_WIDTH / 2.0, KNEELINE) BHemInside = rPoint(B, "BHemInside", BHem.x - BACK_HEM_WIDTH / 2.0, HEMLINE) BHemOutside = rPoint(B, "BHemOutside", BHem.x + BACK_HEM_WIDTH / 2.0, HEMLINE) BGrainline1 = rPoint(B, "BGrainline1", BCenterLeg.x, HIPLINE) # grainline end 1 BGrainline2 = rPoint(B, "BGrainline2", BCenterLeg.x, KNEELINE + (HEMLINE - KNEELINE) / 2.0) # grainline end 2 (B.label_x, B.label_y) = (BGrainline1.x, BGrainline1.y + (2.0 * IN)) pnt1 = makePnt(BEnd.x, BHip.y) pnt2 = pntIntersectLinesP(BKneeOutside, BRiseOutside, BHip, pnt1) BHipOutside = rPointP(B, "BHipOutside", midPointP(pnt1, pnt2)) pnt = makePnt(BEnd.x, BWaist.y) BWaistOutside = rPointP( B, "BWaistOutside", midPointP(pnt, pntIntersectLinesP(BRiseOutside, BHipOutside, BWaist, pnt)) ) BInflection = rPoint(B, "BInflection", BStart.x, HIPLINE - (abs(RISELINE - HIPLINE) / 2.0)) pnt1 = rPoint(B, "NewWaistlinePnt1", BStart.x, WAISTLINE - abs(RISELINE - HIPLINE) / 2.0) pnt2 = rPoint(B, "NewWaistlinePnt2", BEnd.x, WAISTLINE - abs(RISELINE - HIPLINE) / 2.0) # pnt3=intersectLineCircleP(pnt1, pnt2, BWaistOutside, BACK_WAIST_ARC + BACK_DART_WIDTH + 2*SEAM_EASE) pnt3 = intersectLineCircleP(pnt1, pnt2, BHipOutside, BACK_RISE + 2 * SEAM_EASE) BWaistInside = rPointP(B, "BWaistInside", pnt3) # b + math.sqrt((y+BInflection.x)**2) # x1, y1, x2, y2 = intersectCircleCircleP(BInflection, BACK_RISE + SEAM_EASE, BWaistOutside, BACK_WAIST_ARC + BACK_DART_WIDTH + 2*SEAM_EASE) # BWaistInside=rPoint(B, 'BWaistInside', x2, y2) # dart BDartCenter = rPointP( B, "BDartCenter", pntOnLineP(BWaistOutside, BWaistInside, lineLengthP(BWaistOutside, BWaistInside) / 2.0) ) pnt1 = midPointP(BHip, BHipOutside) distance = lineLengthP(BDartCenter, pnt1) / 3.0 pnt2 = pntOnLineP(BDartCenter, pnt1, distance) BDartPoint = rPointP(B, "BDartPoint", pnt2) BDartOutside = rPoint(B, "BDartOutside", BDartCenter.x + BACK_DART_WIDTH / 2.0, BDartCenter.y) distance = lineLengthP(BDartPoint, BDartOutside) angle1 = angleFromSlope(-(BDartOutside.y - BDartPoint.y), BDartOutside.x - BDartPoint.x) P1 = rPointP(B, "P1", pntFromDistanceAndAngleP(BDartPoint, distance, angle1)) angle2 = angleFromSlope(-(BDartCenter.y - BDartPoint.y), BDartCenter.x - BDartPoint.x) p2 = rPointP(B, "P2", pntFromDistanceAndAngleP(BDartPoint, distance, angle2)) angle3 = angle2 - angle1 angle = angle2 + angle3 BDartInside = rPointP(B, "BDartInside", pntFromDistanceAndAngleP(BDartPoint, distance, angle)) # dart fold CENTER_ANGLE = angleFromSlopeP(BDartPoint, BDartCenter) # angle of dart center line INSIDE_ANGLE = angleFromSlopeP(BDartPoint, BDartInside) # angle of dart inside leg HALF_DART_ANGLE = abs(CENTER_ANGLE - INSIDE_ANGLE) # angle of half-dart FOLD_ANGLE = CENTER_ANGLE + ( 2 * HALF_DART_ANGLE ) # angle of center line after dart is folded towards inside = "dart fold" pnt1 = pntFromDistanceAndAngleP( BDartPoint, 1 * IN, FOLD_ANGLE ) # arbitrary point to find line from dart point that intersects with waistline PNT1 = rPointP(B, "PNT1", pnt1) pnt2 = pntIntersectLinesP(BDartPoint, pnt1, BWaistInside, BDartInside) # intersection on waistline PNT2 = rPointP(B, "PNT2", pnt2) distance = lineLengthP( BDartPoint, pnt2 ) # use intersection point to find length of center line of dart so that fold will not be too short BDartFold = rPointP(B, "BDartFold", pntOnLineP(BDartPoint, BDartCenter, distance)) # dart points at cuttingline pnt1 = pntIntersectLines( BDartOutside.x, BDartOutside.y - SEAM_ALLOWANCE, BWaistOutside.x, BWaistOutside.y - SEAM_ALLOWANCE, BDartPoint.x, BDartPoint.y, BDartOutside.x, BDartOutside.y, ) BDartOutsideCuttingLine = rPointP(B, "BDartOutsideCuttingLine", pnt1) BDartFoldCuttingLine = rPointP( B, "BDartCenterCuttingLine", pntOffLineP(BDartFold, BDartPoint, SEAM_ALLOWANCE) ) # dart center at cuttingline pnt2 = pntIntersectLines( BDartInside.x, BDartInside.y - SEAM_ALLOWANCE, BWaistInside.x, BWaistInside.y - SEAM_ALLOWANCE, BDartPoint.x, BDartPoint.y, BDartInside.x, BDartInside.y, ) BDartInsideCuttingLine = rPointP(B, "BDartInsideCuttingLine", pnt2) # dart inside leg at cuttingline # back waist control points b/w BDartOutside & BBWaistOutside x, y = BDartOutside.x, BDartOutside.y + abs(BWaist.y - BDartOutside.y) / 2.0 distance = lineLengthP(BDartOutside, BWaistOutside) / 3.0 cBWOb = cPointP(B, "cBWOb", pntOnLine(BWaistOutside.x, BWaistOutside.y, x, y, distance)) cBWOa = cPointP(B, "cBWOa", pntOnLineP(BDartOutside, cBWOb, distance)) # Outside control points pnts = pointList(BWaistOutside, BHipOutside, BRiseOutside, BKneeOutside) c1, c2 = myGetControlPoints("OutsideSeam", pnts) cBHOa = cPointP(B, "cBHOa", c1[0]) cBHOb = cPointP(B, "cBHOb", c2[0]) cBROa = cPointP(B, "cBROa", c1[1]) cBROb = cPointP(B, "cBROb", c2[1]) cBKOa = cPointP(B, "cBKOa", c1[2]) distance = lineLengthP(BKneeOutside, BRiseOutside) / 2.0 cBKOb = cPointP(B, "cBKOb", pnt=pntOffLineP(BKneeOutside, BHemOutside, distance)) # Inseam control points cBRIa = cPointP( B, "cBRIa", pntOffLineP(BKneeInside, BHemInside, lineLengthP(BKneeInside, BRiseInside) / 2.0) ) # b/w BO & BL cBRIb = cPointP( B, "cBRIb", pntOnLineP(BRiseInside, cBRIa, lineLengthP(BKneeInside, BRiseInside) / 3.0) ) # b/w BO & BL # center seam control points BRiseInside to BWaistInside cBIa = cPointP( B, "cBIa", pntOnLineP(BRiseInside, BRise, lineLengthP(BRiseInside, BInflection) / 2.0) ) # horizontal control line at crotch point if BACK_WAIST_ARC > BACK_HIP_ARC: # curve from BRiseInside to BInflection and BWaistInside cBIb = cPointP( B, "cBIb", BInflection.x, BInflection.y + lineLengthP(BRiseInside, BInflection) / 3.0 ) # vertical control line cBWIa = cPoint( B, "cBWIa", BInflection.x, BInflection.y - lineLengthP(BInflection, BWaistInside) / 3.0 ) # vertical control line cBWIb = cPoint( B, "cBWIb", BWaistInside.x, BWaistInside.y + lineLengthP(BInflection, BWaistInside) / 2.0 ) # vertical control line, longer distance else: # curve from BRiseInside to BInflection, then straight to BWaistInside cBIb = cPointP( B, "cBIb", pntOffLineP(BInflection, BWaistInside, lineLengthP(BInflection, BRiseInside) * (0.6)) ) # longer distance (.6) # back points to create pants Waistband pattern # back waistband, center section rise = -( BWaistInside.y - BDartInside.y ) # rise of dart inside leg to waist inside -- negate this b/c y increases from top to bottom of drawing run = BWaistInside.x - BDartInside.x # run of dart inside leg to waist inside angle1 = -angleFromSlope(run, rise) # negative inverse of rise/run --> perpendicular to waistline pnt1 = pntFromDistanceAndAngleP(BWaistInside, WAISTBAND, angle1) # top of waistband at BWaistInside pnt2 = pntFromDistanceAndAngleP(BDartInside, WAISTBAND, angle1) # top of waistband at dart inside leg BW1 = rPointP(B, "BW1", pnt1) BW2 = rPointP(B, "BW2", pnt2) # back waistband, side section rise = -( BDartOutside.y - BWaistOutside.y ) # rise of line dart outside leg to side seam at waist -- negate this b/c y increases from top to bottom of drawing run = BDartOutside.x - BWaistOutside.x # run of line dart outside leg to side seam at waist angle1 = -angleFromSlope(run, rise) # negative inverse of rise/run --> perpendicular pnt1 = pntFromDistanceAndAngleP(BDartOutside, WAISTBAND, angle1) # top of waistband at dart outside leg pnt2 = pntFromDistanceAndAngleP(BWaistOutside, WAISTBAND, angle1) # top of waistband at BE side seam at waist BW3 = rPointP(B, "BW3", pnt1) BW4 = rPointP(B, "BW4", pnt2) # grid 'Bgrid' path Bgrid = path() # vertical grid addToPath(Bgrid, "M", BStart, "L", BRise, "M", BCenterLeg, "L", BHem, "M", BEnd, "L", BRiseOutside) # horizontal grid addToPath( Bgrid, "M", BStart, "L", BEnd, "M", BWaist, "L", BWaistOutside, "M", BHip, "L", BHipOutside, "M", BRise, "L", BRiseOutside, "M", BKneeInside, "L", BKneeOutside, "M", BHemInside, "L", BHemOutside, ) # diagonal grid addToPath( Bgrid, "M", BWaistInside, "L", BW1, "L", BW2, "L", BDartInside, "L", BDartPoint, "L", BDartOutside, "L", BW3, "L", BW4, "L", BWaistOutside, ) addToPath(Bgrid, "M", BDartInsideCuttingLine, "L", BDartFoldCuttingLine, "L", BDartOutsideCuttingLine) # addToPath('M', BWaistInside, 'L', BWaistOutside, 'L', BDartInside) # dart 'd' path d = path() addToPath(d, "M", BDartInsideCuttingLine, "L", BDartPoint, "L", BDartOutsideCuttingLine) # seamline 's' & cuttingline 'c' paths s = path() c = path() paths = pointList(s, c) for p in paths: addToPath( p, "M", BWaistInside, "L", BDartInside, "L", BDartFold, "L", BDartOutside, "C", cBWOa, cBWOb, BWaistOutside, ) # waistline (BH to BE) addToPath( p, "C", cBHOa, cBHOb, BHipOutside, "C", cBROa, cBROb, BRiseOutside, "C", cBKOa, cBKOb, BKneeOutside, "L", BHemOutside, "L", BHemInside, "L", BKneeInside, "C", cBRIa, cBRIb, BRiseInside, ) if BACK_WAIST_ARC > BACK_HIP_ARC: addToPath(p, "C", cBIa, cBIb, BInflection, "C", cBWIa, cBWIb, BWaistInside) else: addToPath(p, "C", cBIa, cBIb, BInflection, "L", BWaistInside) # add grid, dart, grainline, seamline & cuttingline paths to pattern B.add(grainLinePath("grainLine", "pants Back Grainline", BGrainline1, BGrainline2)) B.add(Path("reference", "Bgrid", "Trousers Back Gridline", Bgrid, "gridline_style")) B.add(Path("pattern", "dartline", "pants Back Dartline", d, "dart_style")) B.add(Path("pattern", "seamLine", "pants Back Seamline", s, "seamline_path_style")) B.add(Path("pattern", "cuttingLine", "pants Back Cuttingline", c, "cuttingline_style")) # call draw once for the entire pattern doc.draw() return
def pattern(self): """ Method defining a pattern design. This is where the designer places all elements of the design definition """ CM=CM_TO_PX IN=IN_TO_PX #The following attributes are set before calling this method: #self.cd - Client Data, which has been loaded from the client data file #self.styledefs - the style difinition dictionary, loaded from the styles file #self.markerdefs - the marker definition dictionary #self.cfg - configuration settings from the main app framework #TODO - find a way to get this administrative cruft out of this pattern method cd=self.cd #client data is prefaced with cd. self.cfg['clientdata']=cd #TODO - also extract these from this file to somewhere else printer='36" wide carriage plotter' if (printer=='36" wide carriage plotter'): self.cfg['paper_width']=(36 * IN) self.cfg['border']=(5*CM)#document borders BORDER=self.cfg['border'] #self.cfg['verbose']=('')#debug statements BORDER=self.cfg['border'] # 1: womens=W, mens=M, teensgirls=TG, teenboys=TB, girls=G, boys=B, toddlers=T, babies=B, crafts=C # 2: streetwearable=S, period=P, fantasy=F # 3: 3digit year: 1870:870, 880, 890,900,910,920,930,940,950,960,970,980,990,000,010 # 4: none=x, Gaming=g, Futuristic=f, Cosplay=c, GothLolita=g, Military=m, BasicCostumes=c # 5: dress=d, pants=p, jeans=j, shirt/blouse=s, tshirt=t, jacket=j, coat=c, vest=v, hat=h, pjs=p, lingerie=l, swimsuits=s, # ....maternity=m, accessories=a # 6: casual=1, elegant=2, day&evening=3, grunge&skate=4, sports=5 # 7: followed by Absolute Number of patterns generated #TODO - abstract these into configuration file(s) metainfo={'companyName':'Seamly Patterns', #mandatory 'designerName':'Susan Spencer',#mandatory 'patternName':'Jeans Foundation',#mandatory 'patternNumber':'WS010-xj1-1' #mandatory } self.cfg['metainfo']=metainfo #attributes for the entire svg document docattrs={'currentscale' : "0.5 : 1", 'fitBoxtoViewport' : "True", 'preserveAspectRatio' : "xMidYMid meet", } doc=Document(self.cfg, name='document', attributes=docattrs) #Set up the Title Block and Test Grid for the top of the document TB=TitleBlock('notes', 'titleblock', 0, 0, stylename='titleblock_text_style') doc.add(TB) TG=TestGrid('notes', 'testgrid', self.cfg['paper_width']/3.0, 0, stylename='cuttingline_style') doc.add(TG) # All measurements are in pixels...CM=CM_TO_PX, IN=IN_TO_PX, etc. #client & pattern measurements SEAM_EASE=(1/8.0)*IN WAISTLINE=(1.0*IN) # Jeans waist is 1" lower than actual waist RISELINE=WAISTLINE + max(cd.front_rise, cd.side_rise, cd.back_rise) HIPLINE=WAISTLINE + (2/3.0)*(RISELINE) HEMLINE=RISELINE + cd.inside_leg KNEELINE=RISELINE+(abs(HEMLINE-RISELINE)/2.0)-(1.0*IN) FRONT_WAIST_ARC=(cd.front_waist_arc) FRONT_HIP_ARC=(cd.front_hip_arc) BACK_WAIST_ARC=(cd.waist_circumference - (2*FRONT_WAIST_ARC))/2.0 BACK_WAIST_WIDTH=(BACK_WAIST_ARC) BACK_HIP_ARC=(cd.hip_circumference - (2*FRONT_HIP_ARC))/2.0 BACK_HIP_HEIGHT=(cd.back_hip_height) BACK_DART_WIDTH=(6/8.0)*IN BACK_DART_LENGTH=(BACK_HIP_HEIGHT/3.0) WAISTBAND=(1.0*IN) # Height of Waistband FRONT_CROTCH_LENGTH=(cd.front_crotch_length) BACK_CROTCH_LENGTH=(cd.back_crotch_length) FRONT_RISE=(cd.front_rise) SIDE_RISE=(cd.side_rise) BACK_KNEE_WIDTH=10.0*IN BACK_HEM_WIDTH=8.0*IN FRONT_KNEE_WIDTH=8.0*IN FRONT_HEM_WIDTH=7.0*IN if ((FRONT_HIP_ARC-FRONT_WAIST_ARC)>= (2.0*IN)): FRONT_NORMAL_WAIST=1 else: FRONT_NORMAL_WAIST=0 if ((BACK_HIP_ARC-BACK_WAIST_ARC)>= (2.0*IN)): BACK_NORMAL_WAIST=1 else: BACK_NORMAL_WAIST=0 #Begin Jeans Pattern Set jeans=Pattern('jeans') doc.add(jeans) jeans.styledefs.update(self.styledefs) jeans.markerdefs.update(self.markerdefs) # Jeans Front 'A' jeans.add(PatternPiece('pattern', 'front', letter='A', fabric=2, interfacing=0, lining=0)) A=jeans.front ASTART=0.0 AEND=(FRONT_HIP_ARC+((1/8.0)*IN)) AStart=rPoint(A, 'AStart', ASTART, ASTART) AEnd=rPoint(A, 'AEnd', AEND, ASTART) AWaist=rPoint(A, 'AWaist', ASTART, WAISTLINE) AHip=rPoint(A, 'AHip', ASTART, HIPLINE) ARise=rPoint(A, 'ARise', ASTART, RISELINE) Ap1=rPoint(A, 'Ap1', AEND, WAISTLINE) # right side of reference grid Ap5=rPoint(A, 'Ap5', AEND/2.0, WAISTLINE) # dart midpoint Ap6=rPoint(A, 'Ap6', Ap5.x-(.25*IN), WAISTLINE) #dart outside leg (left on pattern) Ap7=rPoint(A, 'Ap7', Ap5.x+(.25*IN), WAISTLINE) # dart inside leg (right on pattern) Ap8=rPoint(A, 'Ap8', Ap5.x, Ap5.y+(2.5*IN)) # dart point Ap2=rPoint(A, 'Ap2', Ap7.x+(FRONT_WAIST_ARC/2.0), WAISTLINE) Ap3=rPoint(A, 'Ap3', Ap2.x, WAISTLINE-(0.25)*IN) # center waist Ap4=rPoint(A, 'Ap4', Ap6.x-(FRONT_WAIST_ARC/2.0), WAISTLINE) # side waist Ap9=rPoint(A, 'Ap9', AEND, (RISELINE/2.0)) # center front 'pivot' point from crotch curve to front fly Ap10=rPoint(A, 'Ap10', ASTART, HIPLINE) Ap11=rPoint(A, 'Ap11', AEND, HIPLINE) Ap12=rPoint(A, 'Ap12', ASTART, RISELINE) Ap13=rPoint(A, 'Ap13', AEND, RISELINE) Ap14=rPointP(A, 'Ap14', pntFromDistanceAndAngleP(Ap13, (1.25*IN), angleFromSlope(1.0, 1.0))) # inside crotch curve point Ap15=rPoint(A, 'Ap15', Ap13.x+(2.0*IN), RISELINE) # point of crotch Ap16=rPoint(A, 'Ap16', Ap15.x/2.0, RISELINE) # creaseline point ACREASELINE=Ap16.x Ap17=rPoint(A, 'Ap17', Ap16.x, KNEELINE) Ap18=rPoint(A, 'Ap18', Ap16.x-(4.0*IN), KNEELINE) # outside knee Ap19=rPoint(A, 'Ap19', Ap16.x+(4.0*IN), KNEELINE) # inside knee Ap20=rPoint(A, 'Ap20', Ap16.x, HEMLINE) Ap21=rPoint(A, 'Ap21', Ap20.x-(3.5*IN), HEMLINE) # outside hem Ap22=rPoint(A, 'Ap22', Ap20.x+(3.5*IN), HEMLINE) # inside hem # front waist AW AW1=rPointP(A,'AW1', Ap3) # front center seam at waist AW2=rPointP(A, 'AW2', pntIntersectLinesP(Ap3, Ap4, Ap8, Ap7)) # inside dart leg at waist # calculate dart DART_LEG_LENGTH=lineLengthP(Ap8, AW2) angle1=angleP(Ap8, Ap5) # angle of center dart line angle2=angleP(Ap8, Ap7) # angle of inside dart leg angle3=angle1 - angle2 # half-angle of dart angle4=angle1 + angle3 # angle of outside dart leg angle5=angle1 + (2*angle3) # angle of sewn dart fold, towards side seam AW4=rPointP(A, 'AW4', pntFromDistanceAndAngleP(Ap8, DART_LEG_LENGTH, angle4)) # outside dart leg at waist pnt1=pntFromDistanceAndAngleP(Ap8, DART_LEG_LENGTH, angle5) # point along sewn dart fold pnt2=pntIntersectLinesP(Ap8, pnt1, Ap4, AW4 ) # where sewn dart fold will cross waistline AW3=rPointP(A, 'AW3', pntOnLineP(Ap8, Ap5, lineLengthP(Ap8, pnt2))) # center dart line at waist AW5=rPointP(A, 'AW5', Ap4) # side waist #front waist control points distance=(lineLengthP(AW4, AW5)/3.0) cAW5b=cPoint(A, 'cAW5b', AW5.x+distance, AW5.y) cAW5a=cPointP(A, 'cAW5a', pntOnLineP(AW4, cAW5b, distance)) # front dart AD AD1=rPointP(A, 'AD1', Ap8) # point of dart AD2=rPointP(A, 'AD2', pntOffLineP(AW3, Ap8, (5/8*IN))) # center dart line at cuttingline AD3=rPointP(A, 'AD3', pntIntersectLines(AW4.x, AW4.y-(5/8.0)*IN, AW5.x, AW5.y-(5/8.0)*IN, Ap8.x, Ap8.y, AW4.x, AW4.y)) # outside dart leg AD4=rPointP(A, 'AD4', pntIntersectLines(AW1.x, AW1.y-(5/8.0)*IN, AW2.x, AW2.y-(5/8.0)*IN, Ap8.x, Ap8.y, AW2.x, AW2.y)) #inside dart leg # front side seam AS AS1=rPointP(A, 'AS1', Ap10) AS2=rPointP(A, 'AS2', Ap12) AS3=rPointP(A, 'AS3', Ap18) AS4=rPointP(A, 'AS4', Ap21) # front side seam control points #if (FRONTNORMALTHIGH): if (FRONT_NORMAL_WAIST): cAS3b=cPointP(A, 'cAS3b', pntOffLineP(AS3, AS4, (lineLengthP(AS3, AS1)/2.0))) # b/w AS1 & AS3 pnts=pointList(AW5, AS1, AS3) c1, c2=myGetControlPoints('FrontSideSeam', pnts) cAS1a=cPoint(A, 'cAS1a', c1[0].x, c1[0].y) #b/w AW5 & AS2 cAS1b=cPoint(A, 'cAS1b', AS1.x, c2[0].y) #b/w AW5 & AS1 cAS3a=cPoint(A, 'cAS3a', AS1.x, c1[1].y) #b/w AS1 & AW5 else: cAS2a=cPoint(A, 'cAS2a', min(AS2.x, AW5.x), AW5.y+(lineLengthP(AW5, AS2)/3.0)) # waistline slightly less than hipline (ex: 1.25") use AS2 else AW5 cAS3b=cPointP(A, 'cAS3b', pntOffLineP(AS3, AS4, (lineLengthP(AS2, AS3)/3.0))) # b/w AS2 & AS3 pnts=pointList(cAS2a, AS2, cAS3b) c1, c2=myGetControlPoints('BackSideSeam', pnts) cAS2b=cPoint(A, 'cAS2b', c2[0].x, c2[0].y) #b/w AW5 & AS2 cAS3a=cPoint(A, 'cAS3a', c1[1].x, c1[1].y) #b/w AS2 & AS3 # front inseam AI AI1=rPointP(A, 'AI1', Ap22) AI2=rPointP(A, 'AI2', Ap19) AI3=rPointP(A, 'AI3', Ap15) #front inseam control points cAI3a=cPointP(A, 'cAI3a', pntOffLineP(AI2, AI1, (lineLengthP(AI2, AI3)/2.0))) #b/w AI2 & AI3 cAI3b=cPointP(A, 'cAI3b', pntOnLineP(AI3, cAI3a, (lineLengthP(AI2, AI3)/3.0))) #b/w AI2 & AI3 #front center seam AC AC1=rPointP(A, 'AC1', Ap14) if (AW1.x > Ap9.x): FRONTLARGERWAIST=1 else: FRONTLARGERWAIST=0 if (FRONT_NORMAL_WAIST): AC2=rPointP(A, 'AC2', Ap9) # straight line for upper front center seam, control points for AC1 & AC2 only, with calculated control point cAC2b to smooth into straight line cAC2b=cPointP(A, 'cAC2b', pntOffLine(AC2.x, AC2.y, AW1.x, AW1.y, (lineLengthP(AC1, AC2)/2.0))) pnts=pointList(AI3, AC1, cAC2b) c1, c2=myGetControlPoints('FrontCenterSeam', pnts) cAC1a=cPoint(A, 'cAC1a', c1[0].x, c1[0].y) #b/w AI3 & AC1 cAC1b=cPoint(A, 'cAC1b', c2[0].x, c2[0].y) #b/w AI3 & AC1 cAC2a=cPoint(A, 'cAC2a', c1[1].x, c1[1].y) #b/w AC1 & AC2 else: if (FRONTLARGERWAIST): # curve through AI3,AC2, straight to AW1 # move AC2 point towards center (x) AC2=rPoint(A, 'AC2', Ap9.x + (abs(AW1.x - Ap9.x)/4.0), Ap9.y) cAC2b=cPointP(A, 'cAC2b', pntIntersectLinesP(AC2, AW1, AS1, Ap11)) #intersection with Hipline else: # curve through AI3, AC2, then straight to AW1 AC2=rPointP(A, 'AC2', Ap9) cAC2b=cPointP(A, 'cAC2b', pntOffLineP(AC2, AW1, (lineLengthP(AC2, AC1)/3.0))) cAC2a=cPointP(A, 'cAC2a', pntOnLineP(Ap14, Ap13, (lineLengthP(Ap14, Ap13)/4.0))) # points to create Jeans Waistband pattern 'C' AWB1=rPointP(A, 'AWB1', pntOnLineP(AW1, AC2, WAISTBAND)) # waistband below center waist if FRONT_NORMAL_WAIST: pnt=pntOnLineP(AW5, cAS1a, WAISTBAND) else: pnt=pntOnLineP(AW5, cAS2a, WAISTBAND) AWB4=rPointP(A, 'AWB4', pnt) # waistband line 1in. below side waist AWB2=rPointP(A, 'AWB2', pntIntersectLinesP(AWB1, AWB4, Ap8, Ap7)) # waistband line at inside dart leg AWB3=rPointP(A, 'AWB3', pntIntersectLinesP(AWB1, AWB4, Ap8, Ap6)) # waistband line at outside dart leg #front grainline AG & label location AG1=rPoint(A, 'AG1', Ap16.x, HIPLINE) AG2=rPoint(A, 'AG2', Ap16.x, Ap18.y+abs(Ap21.y-Ap18.y)/2.0) (A.label_x, A.label_y)=(AG2.x, AG2.y-(2.0*IN)) #grid 'Agrid' path Agrid=path() # vertical Agrid addToPath(Agrid, 'M', AStart, 'L', ARise, 'M', Ap5, 'L', Ap8, 'M', Ap16, 'L', Ap20, 'M', Ap3, 'L', Ap2, 'M', AEnd, 'L', Ap13) # horizontal Agrid addToPath(Agrid, 'M', AStart, 'L', AEnd, 'M', AWaist, 'L', Ap1,'M', AHip, 'L', Ap11) addToPath(Agrid, 'M', ARise, 'L', Ap15, 'M', Ap18, 'L', Ap19, 'M', AWB1, 'L', AWB2, 'M', AWB3, 'L', AWB4) # diagonal grid addToPath(Agrid, 'M', Ap3, 'L', Ap4, 'M', Ap13, 'L', Ap14) # dart 'd' path d=path() addToPath(d, 'M', AD1, 'L', AD2, 'M', AD3, 'L', AD1, 'L', AD4) # seamline 's' & cuttingline 'c' paths s=path() c=path() paths=pointList(s, c) for p in paths: # - addToPath(p, 'M', AW1, 'L', AW2, 'L', AW3, 'L', AW4, 'C', cAW5a, cAW5b, AW5) --> waistband from waist to 1" below waist # - waistband from 1" below waist to 2" below waist addToPath(p, 'M', AW1, 'L', AW2, 'L', AW3, 'L', AW4, 'C', cAW5a, cAW5b, AW5) #if (FRONTNORMALTHIGH): if (FRONT_NORMAL_WAIST): addToPath(p, 'C', cAS1a, cAS1b, AS1) else: addToPath(p, 'C', cAS2a, cAS2b, AS2) #else: #addToPath(p, 'C', cAS1a, cAS1b, AS1, 'C', cAT1a, cAT1b, AT1) addToPath(p, 'C', cAS3a, cAS3b, AS3, 'L', AS4, 'L', AI1, 'L', AI2, 'C', cAI3a, cAI3b, AI3) if (FRONT_NORMAL_WAIST): cubicCurveP(p, cAC1a, cAC1b, AC1) addToPath(p, 'C', cAC2a, cAC2b, AC2, 'L', AW1) # add grainline, dart, seamline & cuttingline paths to pattern A.add(grainLinePath("grainLine", "Jeans Front Grainline", AG1, AG2)) A.add(Path('reference','grid', 'Jeans Front Gridline', Agrid, 'gridline_style')) A.add(Path('pattern', 'dartline', 'Jeans Front Dartline', d, 'dart_style')) A.add(Path('pattern', 'seamLine', 'Jeans Front Seamline', s, 'seamline_path_style')) A.add(Path('pattern', 'cuttingLine', 'Jeans Front Cuttingline', c, 'cuttingline_style')) # Jeans Back 'B' jeans.add(PatternPiece('pattern', 'back', letter='B', fabric=2, interfacing=0, lining=0)) B=jeans.back BSTART=0.0 BEND=(BACK_HIP_ARC + 2*SEAM_EASE) BStart=rPoint(B, 'BStart', BSTART, BSTART) BEnd=rPoint(B, 'BEnd', BEND, BStart.y) BWaist=rPoint(B, 'BWaist', BStart.x, WAISTLINE) BHip=rPoint(B, 'BHip', BStart.x, HIPLINE) BRise=rPoint(B, 'BRise', BStart.x, RISELINE+ 2*SEAM_EASE) BSRise=rPoint(B, 'BSRise', BEnd.x, RISELINE - SIDE_RISE) # Waist: # dart BA=rPoint(B, 'BA', BEND/2.0, BStart.y) # dart midpoint BB=rPoint(B, 'BB', BA.x + (BACK_DART_WIDTH/2.0), BA.y) # dart outside leg BC=rPoint(B, 'BC', BA.x - (BACK_DART_WIDTH/2.0), BA.y) # dart inside leg BD=rPoint(B, 'BD', BA.x, BA.y + BACK_DART_LENGTH) # dart point # side seam at waist pnt=Pnt() pnt.x, pnt.y = BEnd.x, BWaist.y P=intersectLineCircle(pnt, BWaist, BB, (3/5.0)*BACK_WAIST_WIDTH) #P.intersections is number of intersections, P.p1 is x,y of 1st intersection, P.p2 is x,y of 2nd if it exists. BE=rPoint(B, 'BE', min(BEnd.x, P.p2.x), BWaist.y) # get 2nd intersection point # back waist control points b/w BB & BE distance=(lineLengthP(BB, BE)/3.0) cBEb=cPoint(B, 'cBEb', BE.x-distance, BE.y) cBEa=cPointP(B, 'cBEa', pntOnLineP(BB, cBEb, distance)) # dart fold CENTER_ANGLE = angleP(BD, BA) # angle of dart center line SIDE_ANGLE = angleP(BD, BB) # angle of dart outside leg HALF_DART_ANGLE = CENTER_ANGLE - SIDE_ANGLE # angle of half-dart FOLD_ANGLE = CENTER_ANGLE + (2 * HALF_DART_ANGLE) # angle of center line after dart is folded towards side seam = "dart fold" pnt1=pntFromDistanceAndAngleP(BD, DART_LEG_LENGTH, FOLD_ANGLE) BH=rPointP(B, 'BH', pntOffLineP(BC, BE, (2/5.0)*BACK_WAIST_WIDTH)) BF=rPointP(B, 'BF', pntIntersectLinesP(BD, pnt1, BH, BC)) # where sewn dart fold will cross waistline BG=rPointP(B, 'BG', pntOnLineP(BD, BA, lineLengthP(BD, BF))) # center dart line at waist P=intersectLineCircle(BRise, BStart, BH, RISELINE*2/3.0) BI = rPoint(B, 'BI', P.p2.x, P.p2.y) BJ=rPoint(B, 'BJ', BEnd.x, HIPLINE) BK=rPoint(B, 'BK', BEnd.x, RISELINE) BL=rPoint(B, 'BL', BStart.x - BACK_CROTCH_LENGTH, BRise.y) # crotch point BCenterLeg=rPoint(B, 'BCenterLeg', BEnd.x - abs(BEnd.x - BL.x)/2.0, BRise.y) BKnee=rPoint(B,'BKnee', BCenterLeg.x , BCenterLeg.y + (HEMLINE - BCenterLeg.y)/2.0 - 1.0*IN) BO=rPoint(B, 'BO', BKnee.x - (BACK_KNEE_WIDTH/2.0), BKnee.y) BP=rPoint(B, 'BP', BKnee.x + (BACK_KNEE_WIDTH/2.0), BKnee.y) BHem=rPoint(B, 'BHem', BCenterLeg.x, HEMLINE) BQ=rPoint(B, 'BQ', BHem.x - BACK_HEM_WIDTH/2.0, HEMLINE) BR=rPoint(B, 'BR', BHem.x + BACK_HEM_WIDTH/2.0, HEMLINE) BS=rPointP(B, 'BS', pntIntersectLines(BC.x, BC.y - SEAM_ALLOWANCE, BH.x, BH.y - SEAM_ALLOWANCE, BD.x, BD.y, BC.x, BC.y)) # dart inside leg at cuttingline BT=rPointP(B, 'BT', pntOffLineP(BG, BD, SEAM_ALLOWANCE)) # dart center at cuttingline BU=rPointP(B, 'BU', pntIntersectLines(BB.x, BB.y - SEAM_ALLOWANCE, BE.x, BE.y - SEAM_ALLOWANCE, BD.x, BD.y, BB.x, BB.y)) # dart outside leg at cuttingline BG1=rPoint(B, 'BG1', BCenterLeg.x, (BKnee.y - BStart.y)/2.0) # grainline end 1 BG2=rPoint(B, 'BG2', BCenterLeg.x, BKnee.y + (HEMLINE - BKnee.y)/2.0) # grainline end 2 #back label location (B.label_x, B.label_y)=(BG1.x, BG1.y + (2.0*IN)) # test for waist > hip if (BH.x < BI.x): BACKLARGERWAIST=1 else: BACKLARGERWAIST=0 if (BACK_NORMAL_WAIST): # case 1: normal waist -- Side Seamline from waist to hem is: BE, BJ, BP, BR -- skipBKRise & BN Thigh cBPb=cPointP(B, 'cBPb', pntOffLineP(BP, BR, (lineLengthP(BP, BJ)/2.0))) # b/w BJ Hip & BP Knee, longer distance (1/2) pnts=pointList(BE, BJ, BP) c1, c2=myGetControlPoints('BackSideSeam', pnts) cBJa=cPoint(B, 'cBJa', c1[0].x, c1[0].y) #b/w BE & BJ cBJb=cPoint(B, 'cBJb', BJ.x, c2[0].y) #b/w BE & BJ -- vertical control line above BJ -- BJ is widest point of curve cBPa=cPoint(B, 'cBNa', BJ.x, c1[1].y) #b/w BJ & BP -- vertical control line below BJ -- BJ is widest point of curve else: # case 2: larger waist -- Side Seamline from waist to hem: BE, BK, BP, BR -- skip BJ Hip & BN Thigh cBKa=cPoint(B, 'cBKa', BE.x, BE.y+(lineLengthP(BE, BK)/3.0)) # vertical control line, normal distance (1/3) cBPb=cPointP(B, 'cBPb', pntOffLineP(BP, BR, (lineLengthP(BP, BK)/3.0))) # b/w BK & BP, normal distance (1/3) pnts=pointList(cBKa, BK, cBPb) # control the curves which ease out of and into BE & BP by using their nearest control points cBKa & cBPb c1, c2=myGetControlPoints('BackSideSeam', pnts) cBKb=cPoint(B, 'cBKb', c2[0].x, c2[0].y) #b/w BE & BK cBPa=cPoint(B, 'cBPa', c1[1].x, c1[1].y) #b/w BK & BP # inseam control points distance=(lineLengthP(BL, BO)/3.0) cBLa=cPointP(B, 'cBLa', pntOffLineP(BO, BQ, distance)) #b/w BO & BL cBLb=cPointP(B, 'cBLb', pntOnLineP(BL, cBLa, distance)) #b/w BO & BL # center seam control points BL to BH cBIa=cPointP(B, 'cBIa', pntOnLineP(BL, BK, lineLengthP(BL, BI)/3.0)) #b/w BL & BI -- horizontal control line, normal distance (.33) if (BACKLARGERWAIST): # curve from BL to BI and BH cBIb=cPointP(B, 'cBIb', BI.x, BI.y + lineLengthP(BL, BI)/3.0) # b/w BL & BI -- vertical control line, normal distance cBHa=cPoint(B, 'cBHa', BI.x, BI.y - lineLengthP(BI, BH)/3.0) #b/w BI & BH -- vertical control line, normal distance (.33) cBHb=cPoint(B, 'cBHb', BH.x, BH.y + lineLengthP(BI, BH)/2.0) #b/w BI & BH -- vertical control line, longer distance (.5) else: # curve from BL to BI, then straight to BH cBIb=cPointP(B, 'cBIb', pntOffLineP(BI, BH, lineLengthP(BI, BL)*(0.6))) # b/w BL & BI, longer distance (.6) # back points to create Jeans Waistband pattern # back waistband, center section rise=-(BH.y - BC.y)# rise of line BC dart inside leg at waist to BH center seam -- negate this b/c y increases from top to bottom of drawing run=(BH.x - BC.x) # trun of line BH-BC -- rise/run = slope of line BC-BH angle1=angleFromSlope(-run, rise) # negative inverse of rise/run --> angle of line perpendicular to BC-BH pnt1=pntFromDistanceAndAngleP(BH, WAISTBAND, angle1) # top of waistband at BH center seam pnt2=pntFromDistanceAndAngleP(BC, WAISTBAND, angle1) # top of waistband at BC dart inside leg #BW=rPointP(B, 'BW', pntIntersectLinesP(pnt1, pnt2, BC, BD)) BV=rPointP(B, 'BV', pnt1) BW=rPointP(B, 'BW', pnt2) # back waistband, side section rise=-(BB.y - BE.y)# rise of line BB dart outside leg to BE side seam at waist -- negate this b/c y increases from top to bottom of drawing run=(BB.x - BE.x) # run of line BB-BE -- rise/run = slope of line BB-BE angle1=angleFromSlope(-run, rise) # negative inverse of rise/run --> angle of line perpendicular to BB-BE' pnt1=pntFromDistanceAndAngleP(BE, WAISTBAND, angle1) # top of waistband at BB dart outside leg pnt2=pntFromDistanceAndAngleP(BB, WAISTBAND, angle1) # top of waistband at BE side seam at waist BX=rPointP(B, 'BX', pnt2) BY=rPointP(B, 'BY', pnt1) # grid 'Bgrid' path Bgrid=path() # vertical grid addToPath(Bgrid, 'M', BStart, 'L', BRise, 'M', BCenterLeg, 'L', BHem, 'M', BEnd, 'L', BJ) # horizontal grid addToPath(Bgrid, 'M', BStart, 'L', BEnd, 'M', BE, 'L', BWaist, 'M', BHip, 'L', BJ, 'M', BL, 'L', BK, 'M', BO, 'L', BP, 'M', BQ, 'L', BR) # diagonal grid addToPath(Bgrid, 'M', BH, 'L', BV, 'L', BW, 'L', BC, 'L', BD, 'L', BB, 'L', BX, 'L', BY, 'L', BE) addToPath(Bgrid, 'M', BS, 'L', BT, 'L', BU, 'M', BH, 'L', BE, 'L', BB) # dart 'd' path d=path() addToPath(d, 'M', BS, 'L', BD, 'L', BU) # seamline 's' & cuttingline 'c' paths s=path() c=path() paths=pointList(s, c) for p in paths: addToPath(p, 'M', BH, 'L', BC, 'L', BG, 'L', BB, 'C', cBEa, cBEb, BE) # waistline (BH to BE) # sideseam to hem to inseam to crotch point (BE to BL) if (BACK_NORMAL_WAIST): addToPath(p, 'C', cBJa, cBJb, BJ) # normal waist curves from BE to BJ else: addToPath(p, 'C', cBKa, cBKb, BK) # large waist curves from BE to BK addToPath(p, 'C', cBPa, cBPb, BP, 'L', BR, 'L', BQ, 'L', BO, 'C', cBLa, cBLb, BL) if (BACKLARGERWAIST): addToPath(p, 'C', cBIa, cBIb, BI, 'C', cBHa, cBHb, BH) else: addToPath(p, 'C', cBIa, cBIb, BI, 'L', BH) # add grid, dart, grainline, seamline & cuttingline paths to pattern B.add(grainLinePath("grainLine", "Jeans Back Grainline", BG1, BG2)) B.add(Path('reference','Bgrid', 'Trousers Back Gridline', Bgrid, 'gridline_style')) B.add(Path('pattern', 'dartline', 'Jeans Back Dartline', d, 'dart_style')) B.add(Path('pattern', 'seamLine', 'Jeans Back Seamline', s, 'seamline_path_style')) B.add(Path('pattern', 'cuttingLine', 'Jeans Back Cuttingline', c, 'cuttingline_style')) # Jeans Waistband 'C' jeans.add(PatternPiece('pattern', 'LeftWaistband', letter='C', fabric=2, interfacing=1, lining=0)) C=jeans.LeftWaistband CSTART=0.0 CEND=(FRONT_WAIST_ARC+BACK_WAIST_ARC) CStart=rPoint(C, 'CStart', BSTART, BSTART) CEnd=rPoint(C, 'CEnd', BEND, BSTART) # Left Waistband # join side sections at side seam with vertical line through CX1 CX1=rPoint(C,'CX1', AWB4.x, AWB4.y-WAISTBAND) # reference point to center the waistband # front waistband, side section connector_pnts=pointList(AWB4, CX1, AWB4, AW1) # connector0-centerpoint, connector0-connector1 --> connector0-connector1 will be rotated to align with connector0-centerpoint old_pnts=pointList(AWB4, AW5, AW4, AWB3) new_pnts=connectObjects(connector_pnts, old_pnts) # front waistband, side section new points C8=rPoint(C, 'C8', new_pnts[0].x, new_pnts[0].y) C3=rPoint(C, 'C3', new_pnts[1].x, new_pnts[1].y) C2=rPoint(C, 'C2', new_pnts[2].x, new_pnts[2].y) C9=rPoint(C, 'C9', new_pnts[3].x, new_pnts[3].y) # back waistband, side section connector_pnts=pointList(AWB4, CX1, BY, BE) # connector0-centerpoint, connector2-connector3 --> connector2-connector3 will be rotated to align with connector0-centerpoint old_pnts=pointList(BY, BE, BB, BX) new_pnts=connectObjects(connector_pnts, old_pnts) # back waistband, side section new points # new_pnts[0] =C8, new_pnts[1] =C3 --> duplicates from previous section C4=rPoint(C, 'C4', new_pnts[2].x, new_pnts[2].y) C7=rPoint(C, 'C7', new_pnts[3].x, new_pnts[3].y) # connect front center section to new front side section connector_pnts=pointList(C9, C2, AWB2, AW2) old_pnts=pointList(AWB2, AW2, AW1, AWB1) new_pnts=connectObjects(connector_pnts, old_pnts) C1=rPoint(C, 'C1', new_pnts[2].x, new_pnts[2].y) C10=rPoint(C, 'C10', new_pnts[3].x, new_pnts[3].y) # connect back center section to new back side section connector_pnts=pointList(C7, C4, BW, BC) old_pnts=pointList(BW, BC, BH, BV) new_pnts=connectObjects(connector_pnts, old_pnts) C5=rPoint(C, 'C5', new_pnts[2].x, new_pnts[2].y) C6=rPoint(C, 'C6', new_pnts[3].x, new_pnts[3].y) cC3a=cPointP(C, 'cC3a', pntOffLineP(C2, C1, lineLengthP(C2, C3)/3.0)) #b/w C2 & C3 cC4b=cPointP(C, 'cC4b', pntOffLineP(C4, C5, lineLengthP(C4, C3)/4.0)) #b/w C4 & C3 pnts=pointList(cC3a, C3, cC4b) c1, c2=myGetControlPoints('LeftWaistbandTopEdge', pnts) cC3b=cPointP(C, 'cC3b', pntOnLineP(C3, c2[0], lineLengthP(C2, C3)/3.0)) #b/w C2 & C3 cC4a=cPointP(C, 'cC4a', pntOnLineP(C3, c1[1], lineLengthP(C4, C3)/3.0)) #b/w C4 & C3 cC8a=cPointP(C, 'cC8a', pntOffLineP(C7, C6, lineLengthP(C7, C8)/3.0)) #b/w C7 & C8 cC9b=cPointP(C, 'cC9b', pntOffLineP(C9, C10, lineLengthP(C9, C8)/3.0)) #b/w C9 & C8 pnts=pointList(cC8a, C8, cC9b) c1, c2=myGetControlPoints('LeftWaistbandLowerEdge', pnts) cC8b=cPointP(C, 'cC8b', pntOnLineP(C8, c2[0], lineLengthP(C7, C8)/3.0)) #b/w C7 & C8 cC9a=cPointP(C, 'cC9a', pntOnLineP(C8, c1[1], lineLengthP(C9, C8)/3.0)) #b/w C8 & C9 #grainline points & label location CG1=rPoint(C, 'CG1', C2.x+(1.0*IN), C2.y + (0.5*IN)) CG2=rPoint(C, 'CG2', CG1.x + (1.5*IN), CG1.y) (C.label_x, C.label_y)=(CG2.x, CG2.y) #grid 'Cgrid' path Cgrid=path() addToPath(Cgrid, 'M', C2, 'L', C9, 'M',C3,'L',C8,'M', C4, 'L', C7) # seamline 's' & cuttingline 'c' paths s=path() c=path() paths=pointList(s, c) for p in paths: addToPath(p, 'M', C1, 'L', C2, 'C', cC3a, cC3b, C3, 'C', cC4a, cC4b, C4, 'L', C5) addToPath(p, 'L', C6, 'L', C7, 'C', cC8a, cC8b, C8, 'C', cC9a, cC9b, C9, 'L', C10, 'L', C1) # add grainline, seamline & cuttingline paths to pattern C.add(grainLinePath("grainLine", "Left Waistband Grainline", CG1, CG2)) C.add(Path('reference','grid', 'Left Waistband Reference Grid', Cgrid, 'gridline_style')) C.add(Path('pattern', 'seamLine', 'Left Waistband Seamline', s, 'seamline_path_style')) C.add(Path('pattern', 'cuttingLine', 'Left Waistband Cuttingline', c, 'cuttingline_style')) #call draw once for the entire pattern doc.draw() return
def pattern(self): """ Method defining a pattern design. This is where the designer places all elements of the design definition """ CM=CM_TO_PX IN=IN_TO_PX #The following attributes are set before calling this method: #self.cd - Client Data, which has been loaded from the client data file #self.styledefs - the style difinition dictionary, loaded from the styles file #self.markerdefs - the marker definition dictionary #self.cfg - configuration settings from the main app framework #TODO - find a way to get this administrative cruft out of this pattern method cd=self.cd #client data is prefaced with cd. self.cfg['clientdata']=cd #TODO - also extract these from this file to somewhere else printer='36" wide carriage plotter' if (printer=='36" wide carriage plotter'): self.cfg['paper_width']=(36 * IN) self.cfg['border']=(5*CM)#document borders BORDER=self.cfg['border'] self.cfg['verbose']=('1')#document borders BORDER=self.cfg['border'] #TODO - abstract these into configuration file(s) metainfo={'companyName':'Seamly Patterns', #mandatory 'designerName':'Susan Spencer',#mandatory 'patternName':'Steampunk Trousers',#mandatory 'patternNumber':'1870-M-T-1' #mandatory } self.cfg['metainfo']=metainfo #attributes for the entire svg document docattrs={'currentscale' : "0.5 : 1", 'fitBoxtoViewport' : "True", 'preserveAspectRatio' : "xMidYMid meet", } doc=Document(self.cfg, name='document', attributes=docattrs) #Set up the Title Block and Test Grid for the top of the document TB=TitleBlock('notes', 'titleblock', 0, 0, stylename='titleblock_text_style') doc.add(TB) TG=TestGrid('notes', 'testgrid', self.cfg['paper_width']/3.0, 0, stylename='cuttingline_style') doc.add(TG) #Begin the pattern ... #pattern values pattern_pieces=7 patternOutsideLeg=112*CM patternInsideLeg=80*CM patternWaist=86*CM patternHip=102*CM patternKnee=50*CM patternHem=43*CM patternRise=abs(patternOutsideLeg - patternInsideLeg)-(0.5*CM) #client values #rise=abs(cd.outside_leg - cd.inside_leg) - (0.5*CM) scale=cd.hip_circumference/2.0 #scale is 1/2 body circumference of reference measurement scale_1_4=scale/4.0 scale_1_8=scale/8.0 #client ratios waistRatio=(cd.waist_circumference/patternWaist) WAISTEASE=((2.54*CM)/4.0)*waistRatio #horizontal ease is distributed across 4 patterns frontWaistWidth=(cd.front_waist_width/2.0)+WAISTEASE backWaistWidth=(cd.back_waist_width/2.0)+WAISTEASE hipRatio=(cd.hip_circumference/patternHip) HIPEASE=((6.5*CM)/4.0)*hipRatio # horizontal ease frontHipHeight=cd.front_hip_height*hipRatio frontHipWidth=(cd.front_hip_width/2.0)+HIPEASE frontAbdomenHeight=cd.front_abdomen_height ABDOMENEASE=HIPEASE frontAbdomenWidth=(cd.front_abdomen_width/2.0)+ABDOMENEASE kneeWidth=(patternKnee/2.0)*hipRatio hemWidth=(patternHem/2.0)*hipRatio insideLegRatio=(cd.inside_leg/patternInsideLeg) insideLeg=cd.inside_leg outsideLegRatio=(cd.outside_leg/patternOutsideLeg) outsideLeg=(cd.outside_leg) riseRatio=(cd.rise/patternRise) rise=cd.rise #Begin Trousers trousers=Pattern('trousers') doc.add(trousers) #TODO - move next two lines into Pattern class? trousers.styledefs.update(self.styledefs) trousers.markerdefs.update(self.markerdefs) # Begin Trousers Front pattern trousers.add(PatternPiece('pattern', 'front', 'A', fabric=2, interfacing=0, lining=0)) # trousers.front tf=trousers.front #Points A=rPoint(tf, 'A', scale_1_8 + (0.5*CM*hipRatio), 8.0*CM) # start pattern 8cm down from y=0 A1=rPoint(tf, 'A1', A.x, A.y + (2.0*CM*riseRatio) )# start front center line 10cm down from y=0 B=rPoint(tf, 'B', A.x, A1.y + (3.8*CM*riseRatio) )# waistband width, waistline C=rPoint(tf, 'C', A.x, B.y + frontHipHeight-(2.0*CM*riseRatio)) # hipline D=rPoint(tf, 'D', A.x, B.y + rise-(2.0*CM*riseRatio)) # riseline E=rPoint(tf, 'E', A.x, D.y + (insideLeg/2.0)-(5.5*CM*insideLegRatio))# thigh curve ends at 5.5cm above kneeline.--> Knee F=rPoint(tf,'F', A.x, D.y + insideLeg - (1.0*CM*insideLegRatio))# hemline is 1cm above floor I=rPoint(tf, 'I', A.x, B.y + abs(C.y - B.y)/2.0) # midpoint b/w waistline and hipline p2=rPoint(tf, 'p2', D.x - scale_1_8 - (0.5*CM*hipRatio), D.y) length=(D.x - p2.x)/2.25 x, y=pointAlongLine(D.x, D.y, (D.x - 100), (D.y - 100), length) # 100pt is arbitrary distance to create 45degree angle p3=rPoint(tf, 'p3', x, y) p7=rPoint(tf, 'p7', B.x + frontWaistWidth, B.y-(2.0*CM*riseRatio)) # sideseam waist p8=rPoint(tf, 'p8', p7.x, A.y) #sideseam top waistband p9=rPoint(tf, 'p9', I.x + frontHipWidth-(0.5*CM*(min(1, hipRatio))), I.y) #sideseam midpoint b/w hipline & riseline, hipwidth-0.5cm p10=rPoint(tf, 'p10', C.x + frontHipWidth, C.y) m=((p9.y-p7.y)/(p9.x-p7.x))/3.0 b=p7.y - (m*p7.x) x=p7.x-abs(p9.x-p7.x) y=(m*x)+b p11=rPoint(tf, 'p11', p10.x - (0.5*CM*(min(1, hipRatio))), D.y) p16=rPoint(tf, 'p16', p2.x + (abs(p11.x - p2.x)/2.0), p2.y) # midpoint of horizontal riseline marks vertical creaseline p4=rPoint(tf, 'p4', p16.x - (kneeWidth/2.0), E.y) p5=rPoint(tf, 'p5', p16.x - (hemWidth/2.0), F.y) x, y=getXOnLineAtY(D.y, p4, p5) p6=rPoint(tf, 'p6', x, y) p12=rPoint(tf, 'p12', p4.x + kneeWidth, p4.y) p13=rPoint(tf, 'p13', p5.x + hemWidth, p5.y) p14=rPoint(tf, 'p14', p16.x, F.y) p15=rPoint(tf, 'p15', p14.x, p14.y - (2.0*CM*insideLegRatio)) x, y=getXOnLineAtY(D.y, p12, p13) p30=rPoint(tf, 'p30', x, y) length=abs(D.y -A.y) x, y=pointAlongLine(p16.x, p16.y, p15.x, p15.y, -length) G=rPoint(tf, 'G', x, y) distance=HEM_ALLOWANCE x, y=pointAlongLine(p5.x, p5.y, p4.x, p4.y, distance) K=rPoint(tf, 'K', x, y) x, y=pointAlongLine(p13.x, p13.y, p12.x, p12.y, distance) L=rPoint(tf, 'L', x, y) M=rPoint(tf, 'M', p15.x, p15.y - HEM_ALLOWANCE) Knee=rPoint(tf, 'Knee', p16.x, E.y) #control points for waistband top distance=((math.sqrt(((p8.x - A1.x)**2) + ((p8.y - A1.y)**2)))/3.0) x, y=pointAlongLine(A1.x, A1.y, p8.x, A1.y, distance) c8a=cPoint(tf, 'c8a', x, y) #b/w A1 & p8 x, y=pointAlongLine(p8.x, p8.y, c8a.x, c8a.y, distance) c8b=cPoint(tf, 'c8b', x, y) #b/w A1 & p8 distance=((math.sqrt(((p7.x - B.x)**2) + ((p7.y - B.y)**2)))/3.0) x, y=pointAlongLine(B.x, B.y, p7.x, B.y, distance) c7a=cPoint(tf, 'c7a', x, y) #b/w B & p7 x, y=pointAlongLine(p7.x, p7.y, c7a.x, c7a.y, distance) c7b=cPoint(tf, 'c7b', x, y) #b/w B & p7 #control points for side seam distance = ((math.sqrt(((p12.x - p10.x)**2) + ((p12.y - p10.y)**2))) / 2.0) x, y=pointAlongLine(p12.x, p12.y, p13.x, p13.y, -distance) c12b=cPoint(tf, 'c12b', x, y) #b/w p10 & p12 pointlist=pointList(p7, p9, p10, p12, p13) fcp, scp=myGetControlPoints('SideSeam', pointlist) c9a=cPoint(tf, 'c9a', fcp[0].x, fcp[0].y) #b/w p7 & p9 c9b=cPoint(tf, 'c9b', scp[0].x, scp[0].y) #b/w p7 & p9 c10a=cPoint(tf, 'c10a', fcp[1].x, fcp[1].y) #b/w p9 & p10 c10b=cPoint(tf, 'c10b', scp[1].x, scp[1].y) #b/w p9 & p10 c12a=cPoint(tf, 'c12a', fcp[2].x, fcp[2].y) #b/w p10 & p12 #control points for hemallowance pointlist=pointList(L, M, K) fcp, scp=myGetControlPoints('HemAllowance', pointlist) c5=cPoint(tf, 'c5', fcp[0].x, fcp[0].y) #b/w L & M c6=cPoint(tf, 'c6', scp[0].x, scp[0].y) #b/w L & M c7=cPoint(tf, 'c7', fcp[1].x, fcp[1].y) #b/w M & K c8=cPoint(tf, 'c8', scp[1].x, scp[1].y) #b/w M & K #control points for inseam curve distance= ((math.sqrt(((p4.x - p2.x)**2) + ((p4.y - p2.y)**2))) / 2.0) x, y=pointAlongLine(p4.x, p4.y, p5.x, p5.y, -distance) c9=cPoint(tf, 'c9', x, y) # b/w p4 & p2 pointlist=pointList(p4, c9, p2) fcp, scp=myGetControlPoints('Inseam', pointlist) c10=cPoint(tf, 'c10', scp[1].x, scp[1].y) # b/w p4 & p2 #control points at front fly curve Ca=cPoint(tf, 'Ca', C.x, C.y-(5.0*CM*riseRatio)) dx = abs(Ca.x - p3.x) dy = abs(Ca.y - p3.y) Cb = cPoint(tf, 'Cb', C.x - dx, C.y - dy) pointlist=pointList(p2, p3, Ca, Cb) fcp, scp=myGetControlPoints('Inseam', pointlist) c11a=cPoint(tf, 'c11a', fcp[0].x, fcp[0].y) # b/w p2 & p3 c11b=cPoint(tf, 'c11b', scp[0].x, scp[0].y) # b/w p2 & p3 c11c=cPoint(tf, 'c11c', fcp[1].x, fcp[1].y) # b/w p3 & Ca c11d=cPoint(tf, 'c11d', scp[1].x, scp[1].y) #b/w p3 & Ca #TODO - improve intersectionOfLines function to accept vertical lines #control points for hemline pointlist=pointList(p13, p15, p5) fcp, scp=myGetControlPoints('HemLine', pointlist) fcp, scp=myGetControlPoints('HemLine', pointlist) c13=cPoint(tf, 'c13', fcp[0].x, fcp[0].y) #b/w 13 & 15 c14=cPoint(tf, 'c14', scp[0].x, scp[0].y) #b/w 13 & 15 c15=cPoint(tf, 'c15', fcp[1].x, fcp[1].y) #b/w 15 & 5 c16=cPoint(tf, 'c16', scp[1].x, scp[1].y) #b/w 15 & 5 #fly stitch line f1=rPoint(tf, 'f1', C.x + (5.0*CM*hipRatio), C.y-(2.54*CM*riseRatio)) f2=rPoint(tf, 'f2', f1.x, A1.y) c17=cPoint(tf, 'c17', p3.x+ (abs(f1.x-p3.x) / 2.0), p3.y) #b/w p3 & f1 c18=cPoint(tf, 'c18', f1.x, f1.y + (abs(f1.y-p3.y) / 2.0))#b/w p3 & f1 # Trousers Front Grid lines g=path() #vertical grid moveP(g, A) lineP(g, F) moveP(g, p6) lineP(g, p5) moveP(g, p30) lineP(g, p13) moveP(g, G) lineP(g, p14) #horizontal grid moveP(g, A) lineP(g, p8) moveP(g, I) lineP(g, p9) moveP(g, C) lineP(g, p10) moveP(g, p2) lineP(g, p11) moveP(g, p4) lineP(g, p12) moveP(g, p5) lineP(g, p13) #diagonal grid moveP(g, D) lineP(g, p3) # Trousers Front Gridline path tf.add(Path('reference','grid', 'Trousers Front Gridline', g, 'gridline_style')) #trousers front waist line wl=path() moveP(wl, B) cubicCurveP(wl, c7a, c7b, p7) #trousers front waist line path tf.add(Path('pattern', 'waistLine', 'Trousers Front Waist line', wl, 'dart_style')) #trousers front fly line fl=path() moveP(fl, p3) cubicCurveP(fl, c17, c18, f1) lineP(fl, f2) #trousers front fly line path tf.add(Path('pattern', 'flyLine', 'Trousers Front Fly line', fl, 'dart_style')) #Trousers Front Grainline & Label Location g1=rPoint(tf, 'g1', p16.x, C.y) g2=rPoint(tf, 'g2', p16.x, (p4.y + (abs(p14.y - p4.y) / 2.0))) # Trousers Front Cuttingline & Seamline c=path() s=path() paths=pointList(c, s) for p in paths: # print p.get_d # Trousers Front Waistband moveP(p, A1) cubicCurveP(p, c8a, c8b, p8) lineP(p, p7) #Trousers Front Sideseam cubicCurveP(p, c9a, c9b, p9) cubicCurveP(p, c10a, c10b, p10) cubicCurveP(p, c12a, c12b, p12) lineP(p, p13) #Trousers Front Hemline cubicCurveP(p, c13, c14, p15) cubicCurveP(p, c15, c16, p5) #Trousers Front Inseam lineP(p, p4) cubicCurveP(p, c9, c10, p2) #Trousers Front Centerseam cubicCurveP(p, c11a, c11b, p3) cubicCurveP(p, c11c, c11d, Ca) lineP(p, A1) # Trousers Front Seamline & Cuttingline paths (tf.label_x, tf.label_y)=( p16.x + (2.0*CM*hipRatio), p16.y) tf.add(grainLinePath("grainLine", "Trousers Front Grainline", g1, g2)) tf.add(Path('pattern', 'seamLine', 'Trousers Front Seamline', s, 'seamline_path_style')) tf.add(Path('pattern', 'cuttingLine', 'Trousers Front Cuttingline', c, 'cuttingline_style')) #Trousers Front Waistband Pattern trousers.add(PatternPiece('pattern', 'FrontWaistBand', 'B', fabric=1, interfacing=1, lining=0)) # trousers.frontwaistband tfwb=trousers.FrontWaistBand #Trousers Front Waistband Grainline & Label distance=(4.0*CM*riseRatio) g1=rPoint(tfwb, 'g1', B.x + (12*CM*waistRatio), B.y - (1.0*CM*riseRatio)) x, y=pointFromDistanceAndAngle(g1.x, g1.y, distance, 45.0) g2=rPoint(tfwb, 'g2', x, y) # Front Waistband Seamline & Cuttingline c=path() s=path() paths=pointList(c, s) for p in paths: moveP(p, A1) cubicCurveP(p, c8a, c8b, p8) lineP(p, p7) cubicCurveP(p, c7b, c7a, B) lineP(p, A1) # create paths & label location (tfwb.label_x, tfwb.label_y)=(A1.x + (3.0*CM*waistRatio), A1.y + (0.5*CM*riseRatio)) tfwb.add(grainLinePath('grainLine', "Trousers Front Waistband Grainline", g1, g2)) tfwb.add(Path('pattern', 'seamLine', 'Trousers Front Waistband Seamline', s, 'seamline_path_style')) tfwb.add(Path('pattern', 'cuttingLine', 'Trousers Front Waistband Cuttingline', c, 'cuttingline_style')) #Trousers Front Fly Pattern trousers.add(PatternPiece('pattern', 'frontFly', letter='C', fabric=3, interfacing=2, lining=0)) tff=trousers.frontFly #Trousers Front Fly Grainline & Label Location g1=rPoint(tff, 'g1', A1.x + (2.5*CM*waistRatio), A1.y + (10.0*CM*riseRatio)) g2=rPoint(tff, 'g2', g1.x, g1.y + (10.0*CM*riseRatio)) # Trousers Front Fly Seamline & Cuttingline s = path() c = path() paths=pointList(s, c) for p in paths: moveP(p, A1) lineP(p, Ca) cubicCurveP(p, c11d, c11c, p3) cubicCurveP(p, c17, c18, f1) lineP(p, f2) lineP(p, A1) # create paths & label location (tff.label_x, tff.label_y)=(A1.x + (1.0*CM*waistRatio), A1.y + (3.0*CM*riseRatio)) tff.add(grainLinePath("grainLine", "Trousers Front Fly Grainline", g1, g2)) tff.add(Path('pattern', 'seamLine', 'Trousers Front Fly Seamline', s, 'seamline_path_style')) tff.add(Path('pattern', 'cuttingLine', 'Trousers Front Fly Cuttingline', c, 'cuttingline_style')) #Trousers Front Hemlining Pattern trousers.add(PatternPiece('pattern', 'frontHemLining', letter='D', fabric=2, interfacing=0, lining=0)) tfh = trousers.frontHemLining #Trousers Front Hemlining Grainline & Label Location distance=(4.0*CM*riseRatio) g1=rPoint(tfh, 'g1', p15.x, p15.y - (1.0*CM*insideLegRatio)) x, y=pointFromDistanceAndAngle(g1.x, g1.y, distance, 45.0) g2=rPoint(tfh, 'g2', x, y) #Trousers Front Hemlining Seamline & Grainline s=path() c=path() paths=pointList(s, c) for p in paths: moveP(p, p5) lineP(p, K) cubicCurveP(p, c8, c7, M) cubicCurveP(p, c6, c5, L) lineP(p, p13) cubicCurveP(p, c13, c14, p15) cubicCurveP(p, c15, c16, p5) # create paths & label location (tfh.label_x, tfh.label_y)=(K.x + (2.0*CM*hipRatio), K.y + (1.0*CM*insideLegRatio)) tfh.add(grainLinePath("grainLine", "Trousers Front Hemlining Grainline", g1, g2)) tfh.add(Path('pattern', 'seamLine', 'Trousers Front Hemlining Seamline', s, 'seamline_path_style')) tfh.add(Path('pattern', 'cuttingLine', 'Trousers Front Hemlining Cuttingline', c, 'cuttingline_style')) #Trousers Back Pattern trousers.add(PatternPiece('pattern', 'back', letter='E', fabric=2, interfacing=0, lining=0)) tb=trousers.back #Points #back center points p17=rPoint(tb, 'p17', p2.x - (3.0*CM*hipRatio), p2.y)# extends back crotch measurement by 3cm x, y=intersectionOfLines(p17.x, p17.y, p2.x, p2.y, p5.x, p5.y, p4.x, p4.y) p18=rPoint(tb, 'p18', x, y) p19=rPoint(tb, 'p19', A.x +(5.0*CM*waistRatio), A.y) #back waist points distance=(2.0*CM*riseRatio) x, y=pointAlongLine(p19.x, p19.y, C.x, C.y, -distance) # extend center back seam up by 2cm to find waistline p20=rPoint(tb, 'p20', x, y)# waistline at back center seam r=(backWaistWidth) + (2.0*CM*waistRatio) x1, y1, y=p20.x, p20.y, B.y-(2.0*CM*riseRatio) x=abs(math.sqrt(r**2 - (y - y1)**2) + x1) p21=rPoint(tb, 'p21', x, y)# waistline at side seamside seam -->backwaistwidth + 2cm away from p20 distance=-(3.8*CM*riseRatio) x, y=pointAlongLine(p20.x, p20.y, p19.x, p19.y, distance) #waistband center back W=rPoint(tb, 'W', x, y) distance=(backWaistWidth) + (2.0*CM*waistRatio) x1=W.x + (p21.x - p20.x)#find x of a point through W at same slope as waistline p20p21 y1=W.y + (p21.y - p20.y) #find y of point through W at same slope as waistline p20p21 x, y=pointAlongLine(W.x, W.y, x1, y1, distance)#adds line from W parallel to p20p21 to find p22 p22=rPoint(tb, 'p22', x, y)# top of waistband at side seam (4cm from waistline) distance=-(5.0*CM*riseRatio) x, y=pointAlongLine(p20.x, p20.y, p19.x, p19.y, distance) p23=rPoint(tb, 'p23', x, y)# top of waistband at center back seam (5cm from waistline) distance=(4.5*CM*waistRatio) x, y=pointAlongLine(p23.x, p23.y, p22.x, p22.y, distance) p24=rPoint(tb, 'p24', x, y)# back button distance=(2.5*CM*riseRatio) x, y=pointAlongLine(p24.x, p24.y, p23.x, p23.y, distance, 90) p25=rPoint(tb, 'p25', x, y) #back waistband highpoint #back waist dart distance=(9.5*CM*waistRatio) x, y=pointAlongLine(p22.x, p22.y, p23.x, p23.y, distance) H=rPoint(tb, 'H', x, y)# back dart center near top of waistband distance=(11.5*CM*riseRatio) x, y=pointAlongLine(H.x, H.y, p22.x, p22.y, distance, 90) P=rPoint(tb, 'P', x, y)# back dart point distance=(1.3*CM*waistRatio)/2.0 x, y=pointAlongLine(H.x, H.y, p22.x, p22.y, distance) Q=rPoint(tb, 'Q', x, y)# inside dart point near top of waistband x, y=pointAlongLine(H.x, H.y, p22.x, p22.y, -distance) R=rPoint(tb, 'R', x, y)#outside dart point near top of waistband x, y=intersectionOfLines(H.x, H.y, P.x, P.y, p20.x, p20.y, p21.x, p21.y) S=rPoint(tb, 'S', x, y)# back dart center at waistline distance=(2*CM*waistRatio)/2.0 x, y=pointAlongLine(S.x, S.y, p21.x, p21.y, distance) T=rPoint(tb, 'T', x, y)# inside dart point at waistline x, y=pointAlongLine(S.x, S.y, p21.x, p21.y, -distance) U=rPoint(tb, 'U', x, y)# outside dart point at waistline #side seam points p26=rPoint(tb, 'p26', p9.x + (4.5*CM*hipRatio), p9.y)# add to abdomenline at side seam p27=rPoint(tb, 'p27', p10.x + (3.0*CM*hipRatio), p10.y)# add to hipline at side seam p28=rPoint(tb, 'p28', p11.x + (2.0*CM*hipRatio), p11.y)# add to riseline at side seam x, y=intersectionOfLines(p12.x, p12.y, p13.x, p13.y, p28.x, p28.y, Knee.x, Knee.y)#intersection of lines p12p13 and p28Knee #back hem allowance p29=rPoint(tb, 'p29', p14.x, p14.y + (1.3*CM*insideLegRatio))# lowered back trouser hem O=rPoint(tb, 'O', p29.x, p29.y - HEM_ALLOWANCE)# lowered back trouser hemallowance #control points for back center curve distance=math.sqrt((abs(C.x-p18.x)**2)+(abs(C.y-p18.y)**2))/2 x, y=pointAlongLine(C.x, C.y, p19.x, p19.y, -distance) cCb=cPoint(tb, 'cCb', x, y)#b/w p18 & C pointlist=pointList(p17, p18, cCb) fcp, scp=myGetControlPoints('BackCenterSeam', pointlist) c18a=cPoint(tb, 'c18a', fcp[0].x, fcp[0].y) #b/w p17 & p18 c18b=cPoint(tb, 'c18b', scp[0].x, scp[0].y) #b/w p17 & p18 distance=math.sqrt((abs(C.x-p18.x)**2)+(abs(C.y-p18.y)**2))/3.0 x, y=pointAlongLine(fcp[1].x, fcp[1].y, p18.x, p18.y, distance) cCa=cPoint(tb, 'cCa', fcp[1].x, fcp[1].y) #b/w p18 & C #control points waistband distance=lineLengthP(p25, p22)/3.0 x, y=pointAlongLine( p22.x, p22.y, W.x, W.y, distance) c22b=cPoint(tb, 'c22b', x, y)# b/w p25 & p22 x, y=pointAlongLine( p25.x, p25.y, c22b.x, c22b.y, distance) c22a=cPoint(tb, 'c22a', x, y)# b/w p25 & p22 #control points waistline distance=lineLengthP(p20, p21)/3.0 x, y=pointAlongLine( p21.x, p21.y, p19.x, p19.y, distance) c21b=cPoint(tb, 'c21b', x, y) # b/w p20 & p21 x, y=pointAlongLine( p20.x, p20.y, c21b.x, c21b.y, distance) c21a=cPoint(tb, 'c21a', x, y) # b/w p20 & p21 #control points for back side seam #distance = (math.sqrt(((p12.x -p28.x)**2) + ((p12.y - p28.y)**2)) / 2.5) distance = (math.sqrt(((p12.x -p27.x)**2) + ((p12.y - p27.y)**2)) / 2.5) x, y=pointAlongLine(p12.x, p12.y, p13.x, p13.y, -distance) c25b=cPoint(tb, 'c25b', x, y) #b/w p27 & p12 pointlist=pointList(p21, p26, p27, p12) fcp, scp=myGetControlPoints('BackSideSeam', pointlist) c23a=cPoint(tb, 'c23a', fcp[0].x, fcp[0].y) #b/w p21 & p26 c23b=cPoint(tb, 'c23b', scp[0].x, scp[0].y) #b/w p21 & p26 c24a=cPoint(tb, 'c24a', fcp[1].x, fcp[1].y) #b/w p26 & p27 c24b=cPoint(tb, 'c24b', scp[1].x, scp[1].y) #b/w p26 & p27 c25a=cPoint(tb, 'c25a', fcp[2].x, fcp[2].y) #b/w p27 & p12 #control points hem line pointlist=pointList(p13, p29, p5) fcp, scp=myGetControlPoints('HemLine', pointlist) c27=cPoint(tb, 'c27', fcp[0].x, fcp[0].y)#b/w p13 & p29 c28=cPoint(tb, 'c28', scp[0].x, scp[0].y)#b/w p13 & p29 c29=cPoint(tb, 'c29', fcp[1].x, fcp[1].y)#b/w p29 & p5 c30=cPoint(tb, 'c30', scp[1].x, scp[1].y)#b/w p29 & p5 #control points hem allowance pointlist=pointList(L, O, K) fcp, scp=myGetControlPoints('HemAllowance', pointlist) c31=cPoint(tb, 'c31', fcp[0].x, fcp[0].y)#b/w L & O c32=cPoint(tb, 'c32', scp[0].x, scp[0].y)#b/w L & O c33=cPoint(tb, 'c33', fcp[1].x, fcp[1].y)#b/w O & K c34=cPoint(tb, 'c34', scp[1].x, scp[1].y)#b/w O & K #control points inseam distance=(math.sqrt(((p4.x - p17.x)**2) + ((p4.y - p17.y)**2)) / 2.0) x, y=pointAlongLine(p4.x, p4.y, p5.x, p5.y, -distance) c35a=cPoint(tb, 'c35a', x, y) #b/w p4 & p17 pointlist=pointList(p4, c35a, p17) fcp, scp=myGetControlPoints('BackInseam', pointlist) c35b=cPoint(tb, 'c35b', scp[1].x, scp[1].y)#b/w p4 & p17 #Trousers Back Grid gr=path() #vertical grid moveP(gr, C) lineP(gr, A) moveP(gr, p5) lineP(gr, p6) moveP(gr, p30) lineP(gr, p13) moveP(gr, p14) lineP(gr, G) #horizontal grid moveP(gr, A) lineP(gr, p22) moveP(gr, B) lineP(gr, p21) moveP(gr, I) lineP(gr, p26) moveP(gr, C) lineP(gr, p27) moveP(gr, p17) lineP(gr, p28) moveP(gr, p4) lineP(gr, p12) moveP(gr, p5) lineP(gr, p13) #diagonal grid moveP(gr, W) lineP(gr, p22) moveP(gr, p17) lineP(gr, Knee) lineP(gr, p28) moveP(gr, p23) lineP(gr, p22) moveP(gr, p25) lineP(gr, p24) tb.add(Path('reference','grid', 'Trousers Back Gridline', gr, 'gridline_style')) #Trousers Back Waistline marking line wl=path() moveP(wl, p20) cubicCurveP(wl, c21a, c21b, p21) tb.add(Path('pattern', 'waistLine', 'Trousers Back Waistline', wl, 'dart_style')) #Trousers Back Dart marking lines d=path() moveP(d, H) lineP(d, P) moveP(d, Q) lineP(d, T) lineP(d, P) moveP(d, R) lineP(d, U) lineP(d, P) tb.add(Path('pattern', 'dart', 'Trousers Back Dart', d, 'dart_style')) #Trousers Back Grainline & Label Location g1=rPoint(tb, 'g1', p16.x, C.y) g2=rPoint(tb, 'g2', p16.x, p4.y + (abs(p14.y - p4.y)*(0.5))) #Trousers Back Seamline & Cuttingline s=path() c=path() paths=pointList(s, c) for p in paths: moveP(p, p17) cubicCurveP(p, c18a, c18b, p18) cubicCurveP(p, cCa, cCb, C) lineP(p, p23) lineP(p, p25) cubicCurveP(p, c22a, c22b, p22) lineP(p, p21) cubicCurveP(p, c23a, c23b, p26) cubicCurveP(p, c24a, c24b, p27) cubicCurveP(p, c25a, c25b, p12) lineP(p, p13) cubicCurveP(p, c27, c28, p29) cubicCurveP(p, c29, c30, p5) lineP(p, p4) cubicCurveP(p, c35a, c35b, p17) # create paths & label location tb.label_x, tb.label_y=p16.x + (3.0*CM*hipRatio), p16.y tb.add(grainLinePath("grainLine", "Trousers Back Grainline", g1, g2)) tb.add(Path('pattern', 'seamLine', 'Trousers Back Seamline', s, 'seamline_path_style')) tb.add(Path('pattern', 'cuttingLine', 'Trousers Back Cuttingline', c, 'cuttingline_style')) #Trousers Back Waistlining Pattern trousers.add(PatternPiece('pattern', 'backWaistLining', letter='F', fabric=1, interfacing=1, lining=0)) tbwl = trousers.backWaistLining #Trousers Back Waistlining Dart d=path() moveP(d, H) lineP(d, S) moveP(d, Q) lineP(d, T) moveP(d, R) lineP(d, U) tbwl.add(Path('pattern', 'dart', 'Trousers Back Waistlining Dart', d, 'dart_style')) #Trousers Back Waistlining Grainline & Label location rise=(p23.y - p20.y) run=(p23.x - p20.x) angle=angleFromSlope(rise, run)-45.0 distance=(5.0*CM*riseRatio) g1=rPoint(tbwl, 'g1', p23.x + (4.0*CM*waistRatio), p23.y+(1.0*CM*riseRatio)) x, y=pointFromDistanceAndAngle(g1.x, g1.y, distance, angle) g2=rPoint(tbwl, 'g2', x, y) #Trousers Back Waistlining Seamline & Cuttingline s=path() c=path() paths=pointList(s, c) for p in paths: moveP(p, p23) lineP(p, p25) cubicCurveP(p, c22a, c22b, p22) lineP(p, p21) lineP(p, p19) lineP(p, p23) # create paths & label location (tbwl.label_x, tbwl.label_y)=(p25.x, p25.y + (3.0*CM*riseRatio)) tbwl.add(grainLinePath("grainLine", "Trousers Back Waistband Grainline", g1, g2)) tbwl.add(Path('pattern', 'seamLine', 'Trousers Back Waistlining Seamline', s, 'seamline_path_style')) tbwl.add(Path('pattern', 'cuttinLine', 'Trousers Back Waistlining Cuttingline', c, 'cuttingline_style')) #Trouser Back Hemlining Pattern trousers.add(PatternPiece('pattern', 'backHemLining', letter='G', fabric=2, interfacing=0, lining=0)) tbhl = trousers.backHemLining # Trouser Back Hem Lining Grainline & Label Location distance=(4.0*CM*riseRatio) g1=rPoint(tbhl, 'g1', O.x, p29.y - (1.0*CM*insideLegRatio)) x, y=pointFromDistanceAndAngle(g1.x, g1.y, distance, 45.0) g2=rPoint(tbhl, 'g2', x, y) # Trouser Back Hem Lining Seamline & CuttingLine s=path() c=path() paths=pointList(s, c) for p in paths: moveP(p, K) cubicCurveP(p, c34, c33, O) cubicCurveP(p, c32, c31, L) lineP(p, p13) cubicCurveP(p, c27, c28, p29) cubicCurveP(p, c29, c30, p5) lineP(p, K) # create paths & label location (tbhl.label_x, tbhl.label_y)=(K.x + (2.0*CM*hipRatio), K.y + (2.0*CM*insideLegRatio)) tbhl.add(grainLinePath("grainLine", "Trousers Back Hemlining Grainline", g1, g2)) tbhl.add(Path('pattern', 'seamLine', 'seamLine', s, 'seamline_path_style')) tbhl.add(Path('pattern', 'cuttingLine', 'cuttingline', c, 'cuttingline_style')) #call draw once for the entire pattern doc.draw() return