-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathraglan_sweater.py
More file actions
119 lines (88 loc) · 3.62 KB
/
raglan_sweater.py
File metadata and controls
119 lines (88 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
from basic_blocks import *
SLEEVE_WRIST_CIRCUMFERENCE = 0.2
SLEEVE_LOWER_LENGTH = 0.5
SLEEVE_ARMPIT_WIDTH = 0.5
ARMPIT_DECREASE = 0.05
SLEEVE_UPPER_HEIGHT = 0.25
SLEEVE_NECK_WIDTH = 0.1
BODY_WIDTH = 0.5
BODY_HEIGHT = 0.5
ARMPIT_WIDTH = 0.4
BODY_UPPER_HEIGHT = 0.25
BODDY_FRONT_NECK_WIDTH = 0.15
BODY_BACK_NECK_WIDTH = 0.1
# Defaults are for front panel
class RaglanBodyPannel(KnitBlock):
def setup(self, chestCircumferenceIn, bottomRibbingIn=2, ribbingBlock=None,
bottomLengthPct=0.5, widthPct=0.5, armpitDecreasePct=0.05, upperHeightPct=0.25,
neckWidthPct=0.15):
self.chestCircumference = chestCircumferenceIn
self.armpitDecreasePct = armpitDecreasePct
if not ribbingBlock:
ribbingBlock = self
remainingBottomLength = bottomLengthPct * chestCircumferenceIn
if bottomRibbingIn > 0:
self.bottomRibbing = Trapezoid.fromKnitBlock(ribbingBlock)
self.bottomRibbing.setup(bottomRibbingIn, chestCircumferenceIn * widthPct)
remainingBottomLength = remainingBottomLength - bottomRibbingIn
self.bottom = Trapezoid.fromKnitBlock(self)
self.bottom.setup(remainingBottomLength,
chestCircumferenceIn * widthPct)
self.top = Trapezoid.fromKnitBlock(self)
self.top.setup(chestCircumferenceIn * upperHeightPct,
chestCircumferenceIn * (widthPct - (2.0 * armpitDecreasePct)),
chestCircumferenceIn * neckWidthPct)
def printInstructions(self, name):
print "Raglan "+name+" panel"
runningRC = 0
if self.bottomRibbing:
self.bottomRibbing.printCastOn("for 1x1 ribbing")
runningRC = self.bottomRibbing.printInstructions(runningRC)
print "Transfer stitches to main bed"
else:
self.bottom.printCastOn()
runningRC = self.bottom.printInstructions(runningRC)
print "Cast off "+str(self.convertWidth(self.armpitDecreasePct * self.chestCircumference))+" on each side"
self.top.printInstructions(runningRC)
def printHalfInstructions(self, side, name="front"):
print "Raglan cardigan "+name+" "+side+" side"
runningRC = 0
if self.bottomRibbing:
self.bottomRibbing.printHalfCastOn("for 1x1 ribbing")
runningRC = self.bottomRibbing.printHalfInstructions(runningRC)
print "Transfer stitches to main bed"
else:
self.bottom.printHalfCastOn()
runningRC = self.bottom.printHalfInstructions(runningRC, side)
print "Cast off "+str(self.convertWidth(self.armpitDecreasePct * self.chestCircumference))+" on "+side+" side"
self.top.printHalfInstructions(runningRC, side)
class RaglanCardigan(KnitBlock):
def setup(self, chestCircumferenceIn):
self.sleeve = Sleeve.fromKnitBlock(self)
self.sleeve.setup(chestCircumferenceIn, lowerSleeveWidthPct=0.5, armpitDecreasePct=0.05, upperHeightPct=0.25)
self.front = RaglanBodyPannel.fromKnitBlock(self)
self.front.setup(chestCircumferenceIn)
self.back = RaglanBodyPannel.fromKnitBlock(self)
self.back.setup(chestCircumferenceIn, neckWidthPct=0.1)
def printInstructions(self):
self.sleeve.printInstructions()
print "\n"
self.back.printInstructions("back")
print "\n"
self.front.printHalfInstructions("left")
print "\n"
self.front.printHalfInstructions("right")
if __name__ == "__main__":
newSleeve = Sleeve(4, 5.5)
newSleeve.setup(38, lowerSleeveWidthPct=0.5, armpitDecreasePct=0.05, upperHeightPct=0.25)
newSleeve.printInstructions()
front = RaglanBodyPannel.fromKnitBlock(newSleeve)
front.setup(38)
print "\nWHOLE\n"
front.printInstructions("front")
print "\nHALF\n"
front.printHalfInstructions("left")
print "\nINTEGRATED\n"
sweater = RaglanCardigan(4, 5.5)
sweater.setup(38)
sweater.printInstructions()