knit_graphs.basic_knit_graph_generators module

Module of functions that generate basic knit graph swatches.

This module provides utility functions for creating common knitting patterns and structures as knit graphs. These functions serve as building blocks for testing and demonstration purposes.

co_loops(width)[source]

Create a cast-on row of loops forming the foundation for knitting patterns.

Parameters:

width (int) – The number of loops to create in the cast-on row.

Returns:

A tuple containing the knit graph with one course of the specified width and the yarn used to create it.

Return type:

tuple[Knit_Graph, Yarn]

jersey_swatch(width, height)[source]

Generate a rectangular knit swatch with all knit stitches in a flat sheet structure.

This creates a basic stockinette/jersey pattern where all stitches are worked as knit stitches from back to front.

Parameters:
  • width (int) – The number of stitches per course (horizontal row).

  • height (int) – The number of courses (vertical rows) in the swatch.

Returns:

A knit graph representing a flat rectangular swatch with all knit stitches.

Return type:

Knit_Graph

jersey_tube(tube_width, height)[source]

Generate a tubular knit structure with all knit stitches worked in the round.

This creates a seamless tube by knitting in the round, where the front and back sections are connected by floats to maintain the circular structure.

Parameters:
  • tube_width (int) – The number of stitches per course on the front side of the tube.

  • height (int) – The number of courses (vertical rows) in the tube.

Returns:

A knit graph representing a seamless tube with all knit stitches.

Return type:

Knit_Graph

kp_rib_swatch(width, height)[source]

Generate a knit-purl ribbing swatch with alternating wales of knit and purl stitches.

This creates a 1x1 ribbing pattern where knit and purl wales alternate, maintaining their stitch type throughout the height of the swatch for a stretchy, textured fabric.

Parameters:
  • width (int) – The number of stitches per course (horizontal row).

  • height (int) – The number of courses (vertical rows) in the swatch.

Returns:

A knit graph representing a ribbed swatch with alternating knit and purl wales.

Return type:

Knit_Graph

seed_swatch(width, height)[source]

Generate a seed stitch swatch with a checkerboard pattern of knit and purl stitches.

This creates a textured fabric where each stitch alternates between knit and purl both horizontally and vertically, creating a bumpy, non-curling fabric texture.

Parameters:
  • width (int) – The number of stitches per course (horizontal row).

  • height (int) – The number of courses (vertical rows) in the swatch.

Returns:

A knit graph representing a seed stitch swatch with checkerboard knit-purl pattern.

Return type:

Knit_Graph

lace_mesh(width, height)[source]

Generate a mesh pattern with alternating left and right leaning decrease paired to yarn-overs. These pairings create a basic lace pattern with eyelets formed around the increases.

Parameters:
  • width (int) – The number of stitches per course (horizontal row).

  • height (int) – The number of courses (vertical rows) in the swatch.

Returns:

A knit graph representing a mesh swatch.

Return type:

Knit_Graph

twist_cable(width, height)[source]

Generate a twisted cable pattern with alternating crossing directions and purl separators.

This creates a cable pattern with 1x1 twists that alternate direction every two rows, separated by purl wales to make the cable structure more prominent.

Parameters:
  • width (int) – The number of stitches per course (horizontal row).

  • height (int) – The number of courses (vertical rows) in the swatch.

Returns:

A knit graph representing a twisted cable pattern with alternating crossing directions.

Return type:

Knit_Graph