#title: Sheet Twisted-Tuck Cast-On (python with knitout module)
# Casts on a sheet by knitting twisted tucks on all needles; slow!

import knitout
K = knitout.Writer('1 2 3 4 5 6');
K.addHeader('Machine', 'Kniterate');

#Parameters:
min = 1 #needle number of left edge
max = 20 #needle number of right edge
carrier = "3" #carrier name

#Bring in carrier:
K.ingripper(carrier)

#Use a twisted tuck to cast on every stitch.
#Note: this requires a new pass for every stitch, so is pretty slow!
#There are both faster and fancier cast-ons.
#On Kniterate machines, carriers start on the left, so will start with leftmost needle.
for n in range(min, max+1, 1):
	#tuck alternating needles, making sure to do the left edge:
	K.tuck("-", 'f' + str(n), carrier)

#knit two plain rows to allow cast-on stitches to relax and bring carrier to the right:
for n in range(max, min-1, -1):
	K.knit("-", 'f' + str(n), carrier)
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)

#...now can knit on [min,max].

K.write('sheet-twisted-tuck-cast-on.kniterate.k')
