Language Reference

Pseudo-stitches

The stitches listed below are not actual stitches. They are interpreted as stitches by the parser, and are passed to the knit() function. However, they do not create a new stitch. Instead, they somehow manipulate the pattern or the existing stitches.

Turn work

A turn keyword indicates that the queue of live stitches should be reversed. In other words, the last stitch knitted will be the next stitch knitted into. When knitting in the round, the last stitch knitted that's still on the stitch holder is the one that's knitted into next.

Fix stitch

The fix keyword instructs the physics engine to fix the last stitch in space. Usage is fix(x,y,z) where x, y, and z are floating point numbers indicating the absolute position in space to fix the stitch. This keyword must be a single token, so there must be no spaces between fix and ).

Slip stitch

The s keyword indicates that the next live edge should be slipped onto the destination stitch holder. In other words, it's just a slip stitch. This "stitch" isn't implemented in the stitch library because it isn't a node on its own, and the model shouldn't really treat it as one. While you could create a stitch with only a single In edge and a single Out edge and no others, and the relative positions of the edges were both zero, the model would still treat this as an additional edge with mass.

Place Marker

Use the pm keyword to place a stitch-marker in the work. The toMarker keyword can then be used to repeat an instruction or block of instructions until the marker is reached.

A marker is an edgeNode with an empty edge; it doesn't really point to anything. It's just a placeholder, and dequeues will ignore it.

Flow

The following keywords impact procedure control flow. Below is an example that uses these keywords.
 procName: { k 2 p 3 } toEnd return
 
 main: call procName

Procedures

Procedures are indicated by a keyword followed by a colon. The keyword will be the name of the procedure, which will continue until the 'return' keyword. The new procedure can then be called using the 'call' keyword.

Call

Previously defined procedures can be called using the 'call' keyword. The subprocedure will execute and control flow will continue after the 'call'.

Return

The 'return' keyword indicates the end of a subprocedure. When this keyword is seen, control will return to after the 'call' that caused this subprocedure to run.

Blocks

Instruction blocks are indicated by curly braces. Traditionally, the asterisk character has been used to indicate that a certain section of a pattern should be repeated. However, using the same character for the beginning and end of a block can be ambiguous if there is more than one block in a procedure. Using the curly braces allows us to nest loops, and more efficiently represent complicated instructions, at the risk of making the pattern less readable to non-programming knitters.

toEdge

The toEdge keyword indicates that an instruction or block of instructions should be repeated until the edge of the work is reached. This keyword should mainly be seen in patterns worked flat, rather than in the round. Adding a number after this keyword tells the program that the block should be repeated until that many stitches before the edge.

toRowEnd

The toRowEnd keyword indicates that an instruction or block of instructions should be repeated until the end of the row. This keyword should mainly be seen in patterns worked in the round, rather than flat. Adding a number after this keyword tells the program that the block should be repeated until that many stitches before the end of the row.

toMarker

The toMarker keyword indicates that an instruction or block of instructions should be repeated until a manually placed marker is reached. Adding a number after this keyword tells the program that the block should be repeated until that many stitches before the marker.

Variables

Below are variables that can be set. The syntax here is
 varName value 
For example, to create a 2x2 cable, you might do something like this:
 # Slip the first two stitches onto the cable needle
 # We'll call the cable needle 1 for this example.
 toHolder 1 s 2
 # Now knit the next two stitches onto our normal holder
 toHolder 0 k 2
 # Next, we knit the two stitches on our cable needle onto
 # the default holder
 fromHolder 1 k 2
 # Finally, we resume knitting from our regular needle
 fromHolder 0
While this notation can be somewhat unwieldy, it can represent arbitrary complex movement of stitches between needles, such as intarsia or fair isle knitting. (Note that intarsia and fair isle are not currently supported since only one active strand of yarn is supported)

fromHolder

The fromHolder variable indicates which stitch holder to knit from. For most patterns, changing the value of this is not necessary. However, for patterns that use a cable, this variable will have to be set back and forth depending on whether stitches are being knitting from the cable needle or from the needle holding the bulk of the stitches.

toHolder

The toHolder variable indicates which stitch holder to knit stitches onto. For most patterns, changing the value of this is not necessary. However, for patterns that use a cable, this variable will have to be set back and forth depending on whether stitches are being knitted onto a cable needle or onto the needle holding the bulk of the stitches.
Generated on Sun Mar 30 14:59:45 2008 for Knitter by  doxygen 1.5.3