Mostly Linux & Python syntax notes and hyperlinks.

Tuesday, March 29, 2016

Pseudocode for Vintage Shell Crochet Hat

Link to original pattern: http://crochet.about.com/library/blshellhat1.htm

This pattern begins with a repeating sub-pattern that takes up 4 stitches of the previous row.
Hence, you need to start with a row of 4*M stitches
In the original pattern, M=6, so you start with 24 base stitches.

U.S. Terms for crochet stitches
dc = double crochet (UK tc)
sc = single crochet   (UK dc)

# if no input number, assume i=1
# general method
def stitch(stitch_name,int i=1):
    crochet i stitch_name stitches

def chain(int i=1):
    stitch(chain,i)

def dc(int i=1):
    stitch(double-crochet, i)

def sc(int i=1):
    stitch(single-crochet, i)

def skip(i):
    skip i stitches from previous row before the next stitch in this row

  
#The definition of "shell" varies with pattern. In this pattern:
def shell(int i, stitch previous_row_stitch):
    dc(i) into the same previous_row_stitch

def flip_work():
    #Rows are worked away from the direction of the dominant hand,
    #If you're right-handed, this means: from right to left


#Turning chains are chains made at the end of the row.
def dc_turning_chain(int i=3):
    chain(i)
    flip_work()

    
#initial loop
def initial_loop(int M):
    chain(M-1)
    join the loop together

# single crochet into all the stitches of the previous row
def end_hat(int i)
    sc(i)

# Pattern = loop of 5 chain-stitches
#           1 row  of dc(24)        =       24 stitches
#           1 row  of sc + shell(3) = 4*6 = 24 stitches
#           2 rows of sc + shell(5) = 6*6 = 36 stitches
#           3 rows of sc + shell(7) = 8*7 = 56 stitches
# dc_turning_chain(3) between each row
# end with single-crochets

# M=6, N=3
def vintage_hat(int M, int N):
    
    initial_loop(M)     # chain 5 & join
    dc_turning_chain()  # chain 3 & turn work

    # 24 double-crochets into the loop
    dc(M*4) into the loop, ignoring the chain stitches themselves

    # now you have M*4 stitches to start the pattern

    # The repeating pattern is as follows:
    # skip 1, sc, skip 1, shell

    # First row:
    for R = 1 to M: #repeat until end of row
        skip(1)
        sc()
        skip(1)
        shell(3) # = 2*1+1 = 3 dc into stitch below

    # Now you should still have 24 stitches in the circle
    #
    for S = 2 to N:
        for row=1 to S:
            repeat until end of row:
                skip(1)
                sc()   into center of previous shell
                shell(2*S+1) into previous row's sc  
            end of row: dc_turning_chain(3)
   shell_size=2*N+1  #=2*3+1=7
   pattern_size=shell_size+1 #=8
   number_of_stitches=pattern_size * M  #=8*6
   end_hat()

No comments:

Post a Comment